O - type of objects stored in this folderpublic class Folder<O> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Folder.SortOrder
Enumeration defining sort direction for folder elements.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PAGESIZE |
static String |
PAGESIZE |
| Constructor and Description |
|---|
Folder() |
| 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
Re-sorts the array if a sorter is set and any elements are actually added.
|
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.
|
String |
getCurrentSortBy() |
Folder.SortOrder |
getCurrentSortingDirection() |
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 size of the folder.
|
boolean |
isFirstElement(O element)
Returns true, if elements.equals( firstElementOfTheSortedArray ).
|
boolean |
isFirstPage()
Returns true, if folder shows points to the first page.
|
boolean |
isLastElement(O element)
Returns true, if elements.equals( lastElementOfTheSortedArray ).
|
boolean |
isLastPage()
Returns true, if folder shows points to 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
|
void |
removeElements(Collection<O> elems)
Remove elements
|
void |
setCurrentPage(int currentPage)
Sets the current page to the given parameter.
|
void |
setElements(O[] elements)
Set the array of objects the folder should manage.
|
void |
setPageSize(int pageSize)
Set page size.
|
void |
setSortBy(String id,
Folder.SortOrder direction)
Activates sorting by the choosen Comparator.
|
void |
sort()
Sorts the elements according the order given by @link addSorter()
and @link setSortBy().
|
public static final int DEFAULT_PAGESIZE
public static final String PAGESIZE
public boolean addElement(O element)
element - to addpublic int addElements(List<O> elems)
elems - to addpublic void addSorter(String id, Comparator<O> sorter)
id - ID to identify the Comparator with @link setSortBy()sorter - a Comparator to sort the Array given by @link setElements()public 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 - public int getPageOf(O element)
element - public int getPages()
public int getPageSize()
public O getPreviousElement(O element)
element - public int getSize()
public boolean isFirstElement(O element)
element - public boolean isFirstPage()
public boolean isLastElement(O element)
element - public boolean isLastPage()
public void lastPage()
public void nextPage()
public void previousPage()
public void removeElement(O element)
element - to removepublic void removeElements(Collection<O> elems)
elems - to removepublic void setCurrentPage(int currentPage)
currentPage - The current page to set.public void setElements(O[] elements)
elements - Array of Os.public void setPageSize(int pageSize)
pageSize - The page size to set.public void setSortBy(String id, Folder.SortOrder direction)
id - ID to identify the Comparator stored with @link addSorter()direction - UP or DOWN. UP is reverse sort.public void sort()