org.pm4j.core.pm.pageable
Class PageableListImpl<T_ITEM>

java.lang.Object
  extended by org.pm4j.core.pm.pageable.PageableListImpl<T_ITEM>
Type Parameters:
T_ITEM - The type of items handled by this set.
All Implemented Interfaces:
PageableCollection<T_ITEM>

public class PageableListImpl<T_ITEM>
extends java.lang.Object
implements PageableCollection<T_ITEM>

Implements a PageableCollection based on an List of items to handle.

Author:
olaf boede

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.pm4j.core.pm.pageable.PageableCollection
PageableCollection.Filter<T>
 
Constructor Summary
PageableListImpl(java.util.Collection<T_ITEM> objects)
           
PageableListImpl(int pageSize, boolean multiSelect)
          Creates an empty collection.
 
Method Summary
 void deSelect(T_ITEM item)
          Removes the given item from the set of selected items.
 PageableCollection.Filter<?> getBackingItemFilter()
           
 int getCurrentPageIdx()
           
 java.util.List<T_ITEM> getItemsOnPage()
           
 int getNumOfItems()
           
 int getPageSize()
           
 java.util.Collection<T_ITEM> getSelectedItems()
           
 boolean isMultiSelect()
           
 boolean isSelected(T_ITEM item)
           
 void onUpdateCollection()
          Gets called whenever the collection behind this instance was updated.
 void select(T_ITEM item)
          Adds the given item to the set of selected items.
 void setBackingItemFilter(PageableCollection.Filter<?> filter)
          Provides a filter that will be applied to the items of the backing collection.
 void setCurrentPageIdx(int pageIdx)
           
 void setItemFilter(PageableCollection.Filter<?> filter)
          Provides a filter that will be applied to the items of this collection.
 void setMultiSelect(boolean isMultiSelect)
          Defines the selection behavior.
 void setPageSize(int newSize)
           
 void sortBackingItems(java.util.Comparator<?> sortComparator)
          Provides a sort comparator that will be applied to the items of the backing collection.
 void sortItems(java.util.Comparator<?> sortComparator)
          Sorts the items of this collection based on the given operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageableListImpl

public PageableListImpl(java.util.Collection<T_ITEM> objects)
Parameters:
objects - The set of objects to iterate over.
pageSize - The page size to use.

PageableListImpl

public PageableListImpl(int pageSize,
                        boolean multiSelect)
Creates an empty collection.

Parameters:
pageSize - The page size.
multiSelect - The multi selection behavior definition.
Method Detail

getItemsOnPage

public java.util.List<T_ITEM> getItemsOnPage()
Specified by:
getItemsOnPage in interface PageableCollection<T_ITEM>
Returns:
The set of item to display on the current page.

getNumOfItems

public int getNumOfItems()
Specified by:
getNumOfItems in interface PageableCollection<T_ITEM>
Returns:
The total number of object within this set.

getPageSize

public int getPageSize()
Specified by:
getPageSize in interface PageableCollection<T_ITEM>
Returns:
The number of items to reserve space for on the current page.

setPageSize

public void setPageSize(int newSize)
Specified by:
setPageSize in interface PageableCollection<T_ITEM>
Parameters:
newSize - The new page size. Should be greater than zero.

getCurrentPageIdx

public int getCurrentPageIdx()
Specified by:
getCurrentPageIdx in interface PageableCollection<T_ITEM>
Returns:
The current page number. Starts with one.

setCurrentPageIdx

public void setCurrentPageIdx(int pageIdx)
Specified by:
setCurrentPageIdx in interface PageableCollection<T_ITEM>
Parameters:
pageIdx - Navigates to the specified page.

Valid range: 1 .. #getTotalPageNum().


sortItems

public void sortItems(java.util.Comparator<?> sortComparator)
Description copied from interface: PageableCollection
Sorts the items of this collection based on the given operator.

Specified by:
sortItems in interface PageableCollection<T_ITEM>
Parameters:
sortComparator - The item comparator to use.
May be null to switch sorting off.

sortBackingItems

public void sortBackingItems(java.util.Comparator<?> sortComparator)
Description copied from interface: PageableCollection
Provides a sort comparator that will be applied to the items of the backing collection.

In case of a simple collection (without backing collection), the comparator will be applied to the items of this collection.

Specified by:
sortBackingItems in interface PageableCollection<T_ITEM>
Parameters:
sortComparator - The item comparator to use.
May be null to switch sorting off.

setItemFilter

public void setItemFilter(PageableCollection.Filter<?> filter)
Description copied from interface: PageableCollection
Provides a filter that will be applied to the items of this collection.

Specified by:
setItemFilter in interface PageableCollection<T_ITEM>
Parameters:
filter - The item filter to use.
May be null to switch filtering off.

setBackingItemFilter

public void setBackingItemFilter(PageableCollection.Filter<?> filter)
Description copied from interface: PageableCollection
Provides a filter that will be applied to the items of the backing collection.

In case of a simple collection (without backing collection), the filter will be applied to the items of this collection.

Specified by:
setBackingItemFilter in interface PageableCollection<T_ITEM>
Parameters:
filter - The item filter to use.
May be null to switch filtering off.

getBackingItemFilter

public PageableCollection.Filter<?> getBackingItemFilter()
Specified by:
getBackingItemFilter in interface PageableCollection<T_ITEM>
Returns:
The current filter definition for the backing collection.

isSelected

public boolean isSelected(T_ITEM item)
Specified by:
isSelected in interface PageableCollection<T_ITEM>
Parameters:
item - The item to check.
Returns:
true if the item was selected.

select

public void select(T_ITEM item)
Description copied from interface: PageableCollection
Adds the given item to the set of selected items.

Has no effect if the item is already selected.

Specified by:
select in interface PageableCollection<T_ITEM>
Parameters:
item - The item to select.

deSelect

public void deSelect(T_ITEM item)
Description copied from interface: PageableCollection
Removes the given item from the set of selected items.

Has no effect if the item was not selected.

Specified by:
deSelect in interface PageableCollection<T_ITEM>
Parameters:
item - The item to deselect.

isMultiSelect

public boolean isMultiSelect()
Specified by:
isMultiSelect in interface PageableCollection<T_ITEM>
Returns:
true if more than one item can be selected.

setMultiSelect

public void setMultiSelect(boolean isMultiSelect)
Description copied from interface: PageableCollection
Defines the selection behavior.

Specified by:
setMultiSelect in interface PageableCollection<T_ITEM>

getSelectedItems

public java.util.Collection<T_ITEM> getSelectedItems()
Specified by:
getSelectedItems in interface PageableCollection<T_ITEM>
Returns:
The set of selected items.

onUpdateCollection

public void onUpdateCollection()
Description copied from interface: PageableCollection
Gets called whenever the collection behind this instance was updated.

Specified by:
onUpdateCollection in interface PageableCollection<T_ITEM>