public abstract class AbstractPagerImpl<T> extends java.lang.Object implements Pager<T>, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected java.lang.Long |
count |
protected java.lang.Integer |
currentIndex |
protected java.lang.Integer |
firstRecord |
protected java.util.ArrayList<java.lang.Integer> |
indices |
protected static java.lang.String |
LABEL_DIVIDER |
protected java.lang.Integer |
lastRecord |
protected static java.lang.Integer |
MAX_PAGE_LABELS |
protected java.lang.Integer |
nextIndex |
protected java.util.Map<java.lang.Integer,java.lang.String> |
pageNumbers |
protected java.lang.Integer |
pagesAvailable |
protected java.lang.Integer |
pageSize |
protected java.lang.Integer |
prevIndex |
protected java.util.List<T> |
records |
protected java.lang.String |
suggestion |
Constructor and Description |
---|
AbstractPagerImpl(java.lang.Integer currentIndex,
java.lang.Integer count,
java.lang.Integer pageSize,
java.util.List<T> records)
Deprecated.
This constructor only supports total result counts to
Integer.MAX_VALUE u
use AbstractPagerImpl(Integer currentIndex, Long count, Integer pageSize, List
instead |
AbstractPagerImpl(java.lang.Integer currentIndex,
java.lang.Integer count,
java.lang.Integer pageSize,
java.util.List<T> records,
java.lang.String suggestion)
Deprecated.
This constructor only supports total result counts to
Integer.MAX_VALUE u
use AbstractPagerImpl(Integer currentIndex, Long count, Integer pageSize, List
instead |
AbstractPagerImpl(java.lang.Integer currentIndex,
java.lang.Long count,
java.lang.Integer pageSize,
java.util.List<T> records)
Constructor
|
AbstractPagerImpl(java.lang.Integer currentIndex,
java.lang.Long count,
java.lang.Integer pageSize,
java.util.List<T> records,
java.lang.String suggestion)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected abstract java.lang.String |
createLabel(java.lang.String startLabel,
java.lang.String endLabel) |
java.lang.Long |
getCount()
Get the total number of objects in this result set (not in this page).
|
java.lang.Integer |
getCurrentIndex()
The index of this page.
|
java.lang.Integer |
getFirstRecord()
Returns the index of the first record in this result set
|
java.util.List<java.lang.Integer> |
getIndices()
Get a list of page indices for which labels are available.
|
protected java.lang.String |
getLabel(java.lang.Integer i) |
java.lang.Integer |
getLastRecord()
Returns the index of the last record in this result set
|
java.lang.Integer |
getNextIndex()
The index of the next page in this result set, or null if this is the
last page in the result set.
|
java.lang.String |
getPageNumber(int index)
Get a string label for a given page
(NOTE: Labels may not be calculated for each page in the result set,
especially if the result set is large or the operation for calculating the
label is expensive.
|
java.lang.Integer |
getPagesAvailable()
The total number of pages available for this query, or 0 if there are
no matching objects
|
java.lang.Integer |
getPageSize()
Gets the size of pages in this result set.
|
java.lang.Integer |
getPrevIndex()
The index of the previous page in this result set, or null if this is the
first page in the result set.
|
java.util.List<T> |
getRecords()
Returns the records in this page.
|
java.lang.String |
getSuggestion()
Returns a suggested query string (only applicable for free-text / lucene queries).
|
static boolean |
hasResultsInRange(java.lang.Integer numberOfResults,
java.lang.Integer pageIndex,
java.lang.Integer pageSize)
Deprecated.
The Hibernate
count function returns Long values!
Use hasResultsInRange(Long, Integer, Integer) instead. |
static boolean |
hasResultsInRange(java.lang.Long numberOfResults,
java.lang.Integer pageIndex,
java.lang.Integer pageSize)
Test if the the
numberOfResults in the range of the page specified by pageIndex and pageSize . |
static java.lang.Integer[] |
limitStartforRange(java.lang.Integer numberOfResults,
java.lang.Integer pageIndex,
java.lang.Integer pageSize)
Deprecated.
The Hibernate
count function returns Long values! Use limitStartforRange(Long, Integer, Integer) instead. |
static java.lang.Integer[] |
limitStartforRange(java.lang.Long numberOfResults,
java.lang.Integer pageIndex,
java.lang.Integer pageSize)
Test if the the
numberOfResults in the range of the page specified by pageIndex and pageSize . |
protected static java.lang.Integer MAX_PAGE_LABELS
protected static java.lang.String LABEL_DIVIDER
protected java.lang.Integer pagesAvailable
protected java.lang.Integer prevIndex
protected java.lang.Integer nextIndex
protected java.lang.Integer currentIndex
protected java.util.Map<java.lang.Integer,java.lang.String> pageNumbers
protected java.lang.Integer firstRecord
protected java.lang.Integer lastRecord
protected java.lang.Long count
protected java.util.List<T> records
protected java.lang.String suggestion
protected java.util.ArrayList<java.lang.Integer> indices
protected java.lang.Integer pageSize
@Deprecated public AbstractPagerImpl(java.lang.Integer currentIndex, java.lang.Integer count, java.lang.Integer pageSize, java.util.List<T> records, java.lang.String suggestion)
Integer.MAX_VALUE
u
use AbstractPagerImpl(Integer currentIndex, Long count, Integer pageSize, List records, String suggestion)
insteadcurrentIndex
- the page of this result set (0-based), can be nullcount
- the total number of results available for this querypageSize
- The size of pages (can be null if all results should be returned if available)records
- A list of objects in this page (can be empty if there were no results)suggestion
- a suggested query that would improve the search (only applicable for free-text / lucene queries)public AbstractPagerImpl(java.lang.Integer currentIndex, java.lang.Long count, java.lang.Integer pageSize, java.util.List<T> records, java.lang.String suggestion)
currentIndex
- the page of this result set (0-based), can be nullcount
- the total number of results available for this querypageSize
- The size of pages (can be null if all results should be returned if available)records
- A list of objects in this page (can be empty if there were no results)suggestion
- a suggested query that would improve the search (only applicable for free-text / lucene queries)@Deprecated public AbstractPagerImpl(java.lang.Integer currentIndex, java.lang.Integer count, java.lang.Integer pageSize, java.util.List<T> records)
Integer.MAX_VALUE
u
use AbstractPagerImpl(Integer currentIndex, Long count, Integer pageSize, List records, String suggestion)
insteadcurrentIndex
- the page of this result set (0-based), can be nullcount
- the total number of results available for this querypageSize
- The size of pages (can be null or 0 if all results should be returned if available)records
- A list of objects in this page (can be empty if there were no results)public AbstractPagerImpl(java.lang.Integer currentIndex, java.lang.Long count, java.lang.Integer pageSize, java.util.List<T> records)
currentIndex
- the page of this result set (0-based), can be nullcount
- the total number of results available for this querypageSize
- The size of pages (can be null or 0 if all results should be returned if available)records
- A list of objects in this page (can be empty if there were no results)protected abstract java.lang.String createLabel(java.lang.String startLabel, java.lang.String endLabel)
protected java.lang.String getLabel(java.lang.Integer i)
public java.lang.Integer getPagesAvailable()
Pager
getPagesAvailable
in interface Pager<T>
public java.lang.Integer getNextIndex()
Pager
getNextIndex
in interface Pager<T>
public java.lang.Integer getPrevIndex()
Pager
getPrevIndex
in interface Pager<T>
public java.lang.Integer getCurrentIndex()
Pager
getCurrentIndex
in interface Pager<T>
public java.lang.String getPageNumber(int index)
Pager
Pager.getIndices()
.getPageNumber
in interface Pager<T>
public java.util.List<java.lang.Integer> getIndices()
Pager
getIndices
in interface Pager<T>
public java.lang.Long getCount()
Pager
Pager.getPageSize()
then Pager.getPagesAvailable()
> 1public java.lang.Integer getFirstRecord()
Pager
getFirstRecord
in interface Pager<T>
public java.lang.Integer getLastRecord()
Pager
getLastRecord
in interface Pager<T>
public java.util.List<T> getRecords()
Pager
getRecords
in interface Pager<T>
public java.lang.String getSuggestion()
Pager
getSuggestion
in interface Pager<T>
public java.lang.Integer getPageSize()
Pager
getPageSize
in interface Pager<T>
public static boolean hasResultsInRange(java.lang.Long numberOfResults, java.lang.Integer pageIndex, java.lang.Integer pageSize)
numberOfResults
in the range of the page specified by pageIndex
and pageSize
.
When using this method in a service layer class you will also need to provide the according limit
and start
parameters for dao list methods. The PagerUtil class provides the according methods for the required calculation:
PagerUtils.limitFor(Integer)
and PagerUtils.startFor(Integer, Integer)
.
NOTE: To calculate limit
and start
for dao methods is highly recommended to use
the limitStartforRange(Long, Integer, Integer)
method instead which already includes the calculation of
limit
and start
.
numberOfResults
- pageIndex
- pageSize
- @Deprecated public static boolean hasResultsInRange(java.lang.Integer numberOfResults, java.lang.Integer pageIndex, java.lang.Integer pageSize)
count
function returns Long
values!
Use hasResultsInRange(Long, Integer, Integer)
instead.numberOfResults
in the range of the page specified by pageIndex
and pageSize
.
When using this method in a service layer class you will also need to provide the according limit
and start
parameters for dao list methods. The PagerUtil class provides the according methods for the required calculation:
PagerUtils.limitFor(Integer)
and PagerUtils.startFor(Integer, Integer)
.
NOTE: To calculate limit
and start
for dao methods is highly recommended to use
the limitStartforRange(Long, Integer, Integer)
method instead which already includes the calculation of
limit
and start
.
numberOfResults
- pageIndex
- pageSize
- public static java.lang.Integer[] limitStartforRange(java.lang.Long numberOfResults, java.lang.Integer pageIndex, java.lang.Integer pageSize)
numberOfResults
in the range of the page specified by pageIndex
and pageSize
.
And returns the according limit
and start
values as an array in case the test is successful. If there is no
result in the specified range the return value will be null
.
When using this method in a service layer class you will also need to provide the according limit
and start
parameters for dao list methods. The PagerUtil class provides the according methods for the required calculation:
PagerUtils.limitFor(Integer)
and PagerUtils.startFor(Integer, Integer)
numberOfResults
- pageIndex
- will be set to 0
if null
pageSize
- Integer
array containing limit and start: new int[]{limit, start}
or null if there is no result in the range of
pageIndex
and pageSize
.@Deprecated public static java.lang.Integer[] limitStartforRange(java.lang.Integer numberOfResults, java.lang.Integer pageIndex, java.lang.Integer pageSize)
count
function returns Long
values! Use limitStartforRange(Long, Integer, Integer)
instead.numberOfResults
in the range of the page specified by pageIndex
and pageSize
.
And returns the according limit
and start
values as an array in case the test is successful. If there is no
result in the specified range the return value will be null
.
When using this method in a service layer class you will also need to provide the according limit
and start
parameters for dao list methods. The PagerUtil class provides the according methods for the required calculation:
PagerUtils.limitFor(Integer)
and PagerUtils.startFor(Integer, Integer)
numberOfResults
- pageIndex
- pageSize
- Integer
array containing limit and start: new int[]{limit, start}
or null if there is no result in the range of
pageIndex
and pageSize
.Copyright © 2007-2020 EDIT. All Rights Reserved.