O - type of objects stored in this folderpublic class Folder<O> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class | Folder.SortOrderEnumeration defining sort direction for folder elements. |
| Modifier and Type | Field and Description |
|---|---|
static int | DEFAULT_PAGESIZEDefault page size for folder display |
static String | PAGESIZEProperty key for page size configuration |
| Constructor and Description |
|---|
Folder()Default constructor |
| Modifier and Type | Method and Description |
|---|---|
boolean | addElement(O element)Add an element only if it does not already exist. |
int | addElements(List<O> elems)Add elements only if they do not already exist. |
void | addSorter(String id,
Comparator<O> sorter)Adds a new sorter to the folder. |
Iterator<O> | currentPageIterator()Returns an iterator containing the elements on the current page. |
void | firstPage()Sets folder to display first page. |
int | getCurrentPage()Returns the current page number. |
String | getCurrentSortBy()Get the ID of the current sort comparator. |
Folder.SortOrder | getCurrentSortingDirection()Get the current sorting direction. |
O | getFirstElement()Returns the first element of the sorted folder. |
O | getLastElement()Returns the last element of the sorted folder. |
O | getNextElement(O element)Retrieves the next element in the sorted array. |
int | getPageOf(O element)Returns the page this element is on, using the current sort, or 1 if not found. |
int | getPages()Returns the number of pages in the folder. |
int | getPageSize()Returns page size. |
O | getPreviousElement(O element)Retrieves the previous element in the sorted array. |
int | getSize()Returns the number of elements in the folder. |
boolean | isFirstElement(O element)Returns true if the element is the first in the sorted array. |
boolean | isFirstPage()Returns true if the current page is the first page. |
boolean | isLastElement(O element)Returns true if the element is the last in the sorted array. |
boolean | isLastPage()Returns true if the current page is the last page. |
void | lastPage()Sets folder to display last page. |
void | nextPage()Turns folder to next page. |
void | previousPage()Turns folder to previous page. |
void | removeElement(O element)Remove an element from the folder. |
void | removeElements(Collection<O> elems)Remove elements from the folder. |
void | setCurrentPage(int currentPage)Set the current page number. |
void | setElements(O[] elements)Set the array of objects the folder should manage. |
void | setPageSize(int pageSize)Set page size and recalculate page counts. |
void | setSortBy(String id,
Folder.SortOrder direction)Activates sorting by the chosen Comparator. |
void | sort()Sorts the elements according to the order given by addSorter(String, Comparator)
and setSortBy(String, SortOrder). |
public static final int DEFAULT_PAGESIZE
public static final String PAGESIZE
public boolean addElement(O element)
element - the elementpublic int addElements(List<O> elems)
elems - the list of elements to addpublic void addSorter(String id, Comparator<O> sorter)
setSortBy(String, SortOrder) with the given id.id - identifier for this comparator, used with setSortBy(String, SortOrder)sorter - a Comparator to sort the elementspublic Iterator<O> currentPageIterator()
public void firstPage()
public int getCurrentPage()
public String getCurrentSortBy()
public Folder.SortOrder getCurrentSortingDirection()
public O getFirstElement()
public O getLastElement()
public O getNextElement(O element)
element - the current elementpublic int getPageOf(O element)
element - the elementpublic int getPages()
public int getPageSize()
PAGESIZE property value, or DEFAULT_PAGESIZE.public O getPreviousElement(O element)
element - the current elementpublic int getSize()
public boolean isFirstElement(O element)
element - the elementpublic boolean isFirstPage()
public boolean isLastElement(O element)
element - the elementpublic boolean isLastPage()
public void lastPage()
public void nextPage()
public void previousPage()
public void removeElement(O element)
element - the elementpublic void removeElements(Collection<O> elems)
elems - the collection of elements to removepublic void setCurrentPage(int currentPage)
currentPage - the page number to set (1-based)public void setElements(O[] elements)
elements - Array of Os.public void setPageSize(int pageSize)
pageSize - the new page sizepublic void setSortBy(String id, Folder.SortOrder direction)
addSorter(String, Comparator).
Set the sorting direction of the folder.
Warning: this does not do the actual sort, only addElements() and setElements() do.id - identifier for the Comparatordirection - UP or DOWN. UP is reverse sort.public void sort()
addSorter(String, Comparator)
and setSortBy(String, SortOrder).