TagLib documentation

org.alweb.doff.util
Class Pagination

java.lang.Object
  extended by org.alweb.doff.util.Pagination

public class Pagination
extends Object

Provides an utility class to handle pagination. This class can't be sent to views to display pagination tag. You can also use this class into your model classes in order to retrieve the items at correct indices.

The page index starts at 1 and goes to the page count. But item indices starts from 0 to item count - 1.

Since:
1.7
Author:
Alexis Toulotte

Field Summary
static int DEFAULT_MAX_ITEM_COUNT_PER_PAGE
          The default max item count per page.
 
Constructor Summary
Pagination(int itemCount)
          Constructs a new pagination object from the count of items.
Pagination(Integer itemCount, Integer maxItemCountPerPage)
          Constructs a new pagination object from the count of items and the max item count in a page.
 
Method Summary
 int getHighIndex()
          Returns the high item index on the current page.
 int[] getIndices()
          Returns an array of indices of items on current page.
 int getItemCount()
          Returns the item count specified at constructor on at setter.
 int getItemCountAtPage()
          Returns the item count on the current page.
 int getLowIndex()
          Returns the low item index on the current page.
 int getMaxItemCountPerPage()
          Returns the max visible item count in a page.
 int getPageCount()
          Returns the page count of the pagination.
 int getPageIndex()
          Returns the current page index.
 boolean isEmpty()
          Determines if this pagination doesn't contain any item.
 boolean onFirstPage()
          Determines if current page index is the first one.
 boolean onLastPage()
          Determines if current page index is the last one.
 void setItemCount(Integer count)
          Sets the item count of this pagination.
 void setMaxItemCountPerPage(Integer count)
          Sets the max visible item count in a page.
 void setPageIndex(Integer index)
          Sets the current page index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_ITEM_COUNT_PER_PAGE

public static final int DEFAULT_MAX_ITEM_COUNT_PER_PAGE
The default max item count per page.

Since:
1.7.2
See Also:
Constant Field Values
Constructor Detail

Pagination

public Pagination(int itemCount)
Constructs a new pagination object from the count of items. The max item per page will be 20. The page index will be set to 1.

See Also:
DEFAULT_MAX_ITEM_COUNT_PER_PAGE

Pagination

public Pagination(Integer itemCount,
                  Integer maxItemCountPerPage)
Constructs a new pagination object from the count of items and the max item count in a page. The page index will be set to 1.

Method Detail

getHighIndex

public int getHighIndex()
Returns the high item index on the current page. Item's indices starts from 0 to item count - 1.

See Also:
getLowIndex(), getItemCountAtPage()

getIndices

public int[] getIndices()
Returns an array of indices of items on current page.

See Also:
getLowIndex(), getHighIndex(), getItemCountAtPage()

getItemCount

public int getItemCount()
Returns the item count specified at constructor on at setter.

See Also:
setItemCount(Integer), isEmpty()

getItemCountAtPage

public int getItemCountAtPage()
Returns the item count on the current page. On first pages this method will return the max item count in a page. If pagination doesn't contains any item, this method will return 0.

See Also:
getMaxItemCountPerPage()

getLowIndex

public int getLowIndex()
Returns the low item index on the current page. Item's indices starts from 0 to item count - 1.

See Also:
getHighIndex()

getMaxItemCountPerPage

public int getMaxItemCountPerPage()
Returns the max visible item count in a page.

See Also:
setMaxItemCountPerPage(Integer)

getPageCount

public int getPageCount()
Returns the page count of the pagination. If pagination doesn't contains any item, this method returns 0.


getPageIndex

public int getPageIndex()
Returns the current page index.


isEmpty

public boolean isEmpty()
Determines if this pagination doesn't contain any item.

See Also:
getItemCount()

onFirstPage

public boolean onFirstPage()
Determines if current page index is the first one.


onLastPage

public boolean onLastPage()
Determines if current page index is the last one.


setItemCount

public void setItemCount(Integer count)
Sets the item count of this pagination. Page index will be modified after this call in order to adjust indices.

See Also:
getItemCount()

setMaxItemCountPerPage

public void setMaxItemCountPerPage(Integer count)
Sets the max visible item count in a page. Page index will be modified after this call in order to adjust indices.

See Also:
getMaxItemCountPerPage()

setPageIndex

public void setPageIndex(Integer index)
Sets the current page index. Page index will be modified after this call in order to adjust indices.


TagLib documentation