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
-
Method Summary
Modifier and TypeMethodDescriptionlong
getCount()
The total number of results for a query.Returns the last key from last page.int
getLimit()
Limits the maximum number of results to return in one page.getName()
Name of this pager object (optional).long
getPage()
Page number.Selects the field names to be returned.The name of the field used when sorting the results.boolean
isDesc()
The sort order.void
setCount
(long count) Set the value of count.void
setDesc
(boolean desc) Sets the value of desc.void
setLastKey
(String lastKey) Sets the last key from last page.void
setLimit
(int limit) Set the value of limit.void
Set the value of name.void
setPage
(long page) Set the value of page.void
Sets the fields that are selected to appear in the response from the API.void
Sets 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
-