|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecti2p.susi.util.Folder<O>
public class Folder<O>
Folder object manages a array Object[] to support paging and sorting. You create a folder object, set the contents with setElements(), add Comparators with addSorter(), choose one with sortBy() and and then fetch the content of the current page with currentPageIterator(). All public methods are synchronized.
Nested Class Summary | |
---|---|
static class |
Folder.SortOrder
|
Field Summary | |
---|---|
static int |
DEFAULT_PAGESIZE
|
static String |
PAGESIZE
|
Constructor Summary | |
---|---|
Folder()
|
Method Summary | |
---|---|
void |
addElement(O element)
Add an element only if it does not already exist |
void |
addElements(Collection<O> elems)
Add elements only if it 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. |
String |
getCurrentSortBy()
|
Folder.SortOrder |
getCurrentSortingDirection()
|
O |
getElementAtPosXonCurrentPage(int x)
Returns the element on the current page on the given position. |
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 |
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 |
setSortingDirection(Folder.SortOrder direction)
Sets the sorting direction of the folder. |
void |
sortBy(String id)
Activates sorting by the choosen Comparator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PAGESIZE
public static final int DEFAULT_PAGESIZE
Constructor Detail |
---|
public Folder()
Method Detail |
---|
public int getCurrentPage()
public void setCurrentPage(int currentPage)
currentPage
- The current page to set.public int getSize()
public int getPages()
public int getPageSize()
public void setPageSize(int pageSize)
pageSize
- The page size to set.public void setElements(O[] elements)
elements
- Array of Os.public void removeElement(O element)
element
- to removepublic void removeElements(Collection<O> elems)
elems
- to removepublic void addElement(O element)
element
- to addpublic void addElements(Collection<O> elems)
elems
- to addepublic Iterator<O> currentPageIterator()
public void nextPage()
public void previousPage()
public void firstPage()
public void lastPage()
public void addSorter(String id, Comparator<O> sorter)
id
- ID to identify the Comparator with @link sortBy()sorter
- a Comparator to sort the Array given by @link setElements()public void sortBy(String id)
id
- ID to identify the Comparator stored with @link addSorter()public String getCurrentSortBy()
public Folder.SortOrder getCurrentSortingDirection()
public O getElementAtPosXonCurrentPage(int x)
x
- Position of the element on the current page.
public void setSortingDirection(Folder.SortOrder direction)
direction
- @link UP or @link DOWNpublic O getFirstElement()
public O getLastElement()
public O getNextElement(O element)
element
-
public O getPreviousElement(O element)
element
-
public boolean isLastPage()
public boolean isFirstPage()
public boolean isLastElement(O element)
element
- public boolean isFirstElement(O element)
element
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |