Class Pager
java.lang.Object
com.erudika.para.core.utils.Pager
This class stores pagination data. It limits the results for queries in the
DAO
and Search objects and also counts the total number of results that are returned.- Author:
- Alex Bogdanovski [[email protected]]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetCount()The total number of results for a query.Returns the last key from last page.intgetLimit()Limits the maximum number of results to return in one page.getName()Name of this pager object (optional).longgetPage()Page number.Selects the field names to be returned.The name of the field used when sorting the results.booleanisDesc()The sort order.voidsetCount(long count) Set the value of count.voidsetDesc(boolean desc) Sets the value of desc.voidsetLastKey(String lastKey) Sets the last key from last page.voidsetLimit(int limit) Set the value of limit.voidSet the value of name.voidsetPage(long page) Set the value of page.voidSets the fields that are selected to appear in the response from the API.voidSets the value of sortby.toString()
-
Constructor Details
-
Pager
public Pager()No-args constructor. -
Pager
public Pager(int limit) Default constructor with limit.- Parameters:
limit- the results limit
-
Pager
public Pager(long page, int limit) Default constructor with a page and count.- Parameters:
page- the page numberlimit- the results limit
-
Pager
Default constructor with a page, count, sortby, desc and limit.- Parameters:
page- the page numbersortby- name of property to sort bydesc- sort orderlimit- the results limit
-
-
Method Details
-
getLastKey
Returns the last key from last page. Used for scanning and pagination.- Returns:
- the last key to continue from
-
setLastKey
Sets the last key from last page. Used for scanning and pagination.- Parameters:
lastKey- last id
-
getName
Name of this pager object (optional). Used to distinguish between multiple pagers.- Returns:
- the name
-
setName
-
getSortby
The name of the field used when sorting the results.- Returns:
- the name of the field or "timestamp" as the default sorting
-
setSortby
-
isDesc
public boolean isDesc()The sort order. Default: descending (true)- Returns:
- true if descending
-
setDesc
public void setDesc(boolean desc) Sets the value of desc.- Parameters:
desc- true if descending order
-
getLimit
public int getLimit()Limits the maximum number of results to return in one page.- Returns:
- the max number of results in one page
-
setLimit
public void setLimit(int limit) Set the value of limit.- Parameters:
limit- the max number of results in one page
-
getCount
public long getCount()The total number of results for a query.- Returns:
- total count of results
-
setCount
public void setCount(long count) Set the value of count.- Parameters:
count- total count
-
getPage
public long getPage()Page number. Usually starts from 1...- Returns:
- the page number
-
setPage
public void setPage(long page) Set the value of page.- Parameters:
page- the page number
-
getSelect
-
setSelect
-
toString
-