public class DefaultPagingCalculator extends Object implements PagingCalculator
PagingCalculator
implementation.PagingCalculator.Sizeable
DEFAULT_PAGE_SIZE
Constructor and Description |
---|
DefaultPagingCalculator(PagingCalculator.Sizeable sizeable)
Creates a new
DefaultPagingCalculator , with the default page
size (PagingCalculator.DEFAULT_PAGE_SIZE ), setting the current
page to the first one. |
DefaultPagingCalculator(PagingCalculator.Sizeable sizeable,
int maxPageSize)
Creates a new
DefaultPagingCalculator , setting the current page
to the first one. |
DefaultPagingCalculator(PagingCalculator.Sizeable sizeable,
int maxPageSize,
long currentPage)
Creates a new
DefaultPagingCalculator . |
Modifier and Type | Method and Description |
---|---|
long |
getCurrentPage()
Returns the number of the currently loaded page of data (zero
based).
|
int |
getCurrentPageSize()
Returns the number of elements of the current page.
|
long |
getInitialIndex()
Returns the index of the initial element of the current page into all the
elements.
|
protected long |
getLastIndex() |
int |
getMaxPageSize()
Returns the current maximum number of values per page.
|
long |
getNumPages()
Returns the number of pages available, calculated with the total number
of elements and the maximum number of elements per page.
|
long |
getTotalSize()
Returns the number of elements of the entire set of data.
|
void |
setCurrentPage(long currentPage)
Sets the current page number (zero based), and loads the elements for
that page.
|
void |
setMaxPageSize(int maxPageSize)
Sets the current maximum number of elements per page.
|
public DefaultPagingCalculator(PagingCalculator.Sizeable sizeable)
DefaultPagingCalculator
, with the default page
size (PagingCalculator.DEFAULT_PAGE_SIZE
), setting the current
page to the first one.public DefaultPagingCalculator(PagingCalculator.Sizeable sizeable, int maxPageSize)
DefaultPagingCalculator
, setting the current page
to the first one.maxPageSize
- the maximum page sizepublic DefaultPagingCalculator(PagingCalculator.Sizeable sizeable, int maxPageSize, long currentPage)
DefaultPagingCalculator
.maxPageSize
- the maximum page sizecurrentPage
- the current pagepublic int getMaxPageSize()
PagingCalculator
getMaxPageSize
in interface PagingCalculator
public void setMaxPageSize(int maxPageSize)
PagingCalculator
setMaxPageSize
in interface PagingCalculator
maxPageSize
- the maximum number of values per pagepublic long getCurrentPage()
PagingCalculator
getCurrentPage
in interface PagingCalculator
public void setCurrentPage(long currentPage)
PagingCalculator
setCurrentPage
in interface PagingCalculator
currentPage
- the page to loadpublic long getInitialIndex()
PagingCalculator
getInitialIndex
in interface PagingCalculator
protected long getLastIndex()
public long getNumPages()
PagingCalculator
getNumPages
in interface PagingCalculator
public int getCurrentPageSize()
PagingCalculator
getCurrentPageSize
in interface PagingCalculator
public long getTotalSize()
PagingCalculator
getTotalSize
in interface PagingCalculator