public class PagerUtils
extends java.lang.Object
class eu.etaxonomy.cdm.remote.controller.util.PagerParameter
Constructor and Description |
---|
PagerUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
hasResultsInRange(java.lang.Long numberOfResults,
java.lang.Integer pageIndex,
java.lang.Integer pageSize)
The original method
AbstractPagerImpl.hasResultsInRange(Long, Integer, Integer) is
hard to find, therefore this method has been wired also into this Utility class
this this is looked up more frequently. |
static java.lang.Integer |
limitFor(java.lang.Integer pageSize)
Returns the limit value as used in SQL/HQL statements for the given
page size.
Earlier, for null the value 0 was returned but as
it was decided that pageSize = null should not set any limitation
it was changed to return value null . |
static <T> java.util.List<T> |
pageList(java.util.List<T> fullList,
java.lang.Integer pageIndex,
java.lang.Integer pageSize)
Returns a synchronized (sub)list of fullList which contains only the items
for the given page
|
static java.lang.Integer |
startFor(java.lang.Integer pageSize,
java.lang.Integer pageIndex)
Returns the start index for the given page size and page index values
by multiplying both values (startFor = pageSize * pageIndex).
If page size is null , either null is returned
or an exception is thrown if page index is > 0. |
public static java.lang.Integer startFor(java.lang.Integer pageSize, java.lang.Integer pageIndex) throws PagerRangeException
null
, either null
is returned
or an exception is thrown if page index is > 0.
If page index is null it is assumed as 0.pageSize
- the page sizepageIndex
- the page indexPagerRangeException
- if pageSize == null and pageIndex > 0public static java.lang.Integer limitFor(java.lang.Integer pageSize)
null
the value 0 was returned but as
it was decided that pageSize = null
should not set any limitation
it was changed to return value null
. This way the current implementation
is the identity function and has no effect except for documentation.
null
should be handled in dao-s or specialized code such as
pageList(List, Integer, Integer)
.pageSize
- public static boolean hasResultsInRange(java.lang.Long numberOfResults, java.lang.Integer pageIndex, java.lang.Integer pageSize)
AbstractPagerImpl.hasResultsInRange(Long, Integer, Integer)
is
hard to find, therefore this method has been wired also into this Utility class
this this is looked up more frequently.numberOfResults
- pageIndex
- pageSize
- public static <T> java.util.List<T> pageList(java.util.List<T> fullList, java.lang.Integer pageIndex, java.lang.Integer pageSize)
fullList
- pageIndex
- page indexpageSize
- page sizeCopyright © 2007-2020 EDIT. All Rights Reserved.