ZenMagick 0.9.6


org.zenmagick.rp.resultlist.ZMResultList

Class ZMResultList

ZMObject
|
+--ZMResultList

public class ZMResultList
extends ZMObject

A result list base class that handles lists that might span multiple pages.

A result list operates on any given set of results. Results do not have to have any specific properties, type specific code is delegated to filters and sorters.

Results are obtained via the ZMResultSource object. This defers the actual query to the latest possible moment. Methods may trigger the query if they depend on results; a good example would be getNumberOfResults().

Author:
DerManoMann
Version:
$Id: ZMResultList.php 2004 2009-03-02 01:43:49Z dermanomann $

Field Summary
protected mixed

$allResults_

protected mixed

$filters_

protected mixed

$page_

protected mixed

$pagination_

protected mixed

$resultSource_

protected mixed

$results_

protected mixed

$sorters_

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMResultList()

Create new result list.

Method Summary
void

addFilter(ZMResultListFilter filter)

Add a filter to this result list.

void

addSorter(ZMResultListSorter sorter)

Add a sorter to this result list.

protected array

buildResults()

Actual method to generate the viewable results.

array

getAllResults()

Get all available results.

array

getFilters(boolean active)

Get all filter.

int

getNextPageNumber()

Get the next page number.

int

getNumberOfPages()

Get the calculated number of pages.

int

getNumberOfResults()

Count all results.

int

getPageNumber()

Get the page number (1-based).

int

getPagination()

Get the configured pagination.

int

getPreviousPageNumber()

Get the previous page number.

array

getResults()

Get the results for the current page.

array

getSorters(boolean active)

Get all configured sorter.

boolean

hasFilters()

Check if any filter are active.

boolean

hasNextPage()

Check if a next page is available.

boolean

hasPreviousPage()

Check if a previous page is available.

boolean

hasResults()

Checks if there are results available.

boolean

hasSorters()

Check if any sorter are configured.

void

setPageNumber(int page)

Set the page number (1-based).

void

setPagination(int pagination)

Set the configured pagination.

void

setResultSource(ZMResultSource resultSource)

Set a source for results.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

allResults_

protected mixed $allResults_

filters_

protected mixed $filters_

page_

protected mixed $page_

pagination_

protected mixed $pagination_

resultSource_

protected mixed $resultSource_

results_

protected mixed $results_

sorters_

protected mixed $sorters_

Constructor Detail

ZMResultList

public ZMResultList()

Create new result list. /


Method Detail

addFilter

public void addFilter(ZMResultListFilter filter)

Add a filter to this result list.

Parameters:
filter - The new filter.

addSorter

public void addSorter(ZMResultListSorter sorter)

Add a sorter to this result list.

Parameters:
sorter - The new sorter.

buildResults

protected array buildResults()

Actual method to generate the viewable results.

Returns:
List of result objects.

getAllResults

public array getAllResults()

Get all available results.

Please note that depending on the actual implementation this might return the same as getResults().

Returns:
List of all available results.

getFilters

public array getFilters(boolean active)

Get all filter.

Parameters:
active - Optional flag to get only active sorters; default is false
Returns:
A list of ZMResultListFilter.

getNextPageNumber

public int getNextPageNumber()

Get the next page number.

Returns:
The next page number.

getNumberOfPages

public int getNumberOfPages()

Get the calculated number of pages.

Returns:
The number of pages; will return 0 if no results available.

getNumberOfResults

public int getNumberOfResults()

Count all results.

Returns:
The total number if results.

getPageNumber

public int getPageNumber()

Get the page number (1-based).

Returns:
The page number.

getPagination

public int getPagination()

Get the configured pagination.

Returns:
The number of results per page.

getPreviousPageNumber

public int getPreviousPageNumber()

Get the previous page number.

Returns:
The previous page number; (default: 1)

getResults

public array getResults()

Get the results for the current page.

Returns:
List of results for the current page.

getSorters

public array getSorters(boolean active)

Get all configured sorter.

Parameters:
active - Optional flag to get only active sorters; default is false
Returns:
A list of ZMResultListSorter.

hasFilters

public boolean hasFilters()

Check if any filter are active.

Returns:
true if filters are configured, false if not.

hasNextPage

public boolean hasNextPage()

Check if a next page is available.

Returns:
true if a next page is available, false if not.

hasPreviousPage

public boolean hasPreviousPage()

Check if a previous page is available.

Returns:
true if a previous page is available, false if not.

hasResults

public boolean hasResults()

Checks if there are results available.

Returns:
true if results are available, false if not.

hasSorters

public boolean hasSorters()

Check if any sorter are configured.

Returns:
true if sorter are configured, false if not.

setPageNumber

public void setPageNumber(int page)

Set the page number (1-based).

Parameters:
page - The page number.

setPagination

public void setPagination(int pagination)

Set the configured pagination.

Parameters:
pagination - The number of results per page.

setResultSource

public void setResultSource(ZMResultSource resultSource)

Set a source for results.

The advantage of using a result source is that alternative implementations are free to ignore these, modify them or replace them as needed. Providing results via the constructor means that the resources used to build that list might be wasted.

Parameters:
resultSource - A result source.

ZenMagick 0.9.6