Class Pager

java.lang.Object
com.erudika.para.core.utils.Pager

public class Pager extends Object
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
    Constructor
    Description
    No-args constructor.
    Pager(int limit)
    Default constructor with limit.
    Pager(long page, int limit)
    Default constructor with a page and count.
    Pager(long page, String sortby, boolean desc, int limit)
    Default constructor with a page, count, sortby, desc and limit.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    The total number of results for a query.
    Returns the last key from last page.
    int
    Limits the maximum number of results to return in one page.
    Name of this pager object (optional).
    long
    Page number.
    Selects the field names to be returned.
    The name of the field used when sorting the results.
    boolean
    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
    setSortby(String sortby)
    Sets the value of sortby.
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 number
      limit - the results limit
    • Pager

      public Pager(long page, String sortby, boolean desc, int limit)
      Default constructor with a page, count, sortby, desc and limit.
      Parameters:
      page - the page number
      sortby - name of property to sort by
      desc - sort order
      limit - the results limit
  • Method Details

    • getLastKey

      public String getLastKey()
      Returns the last key from last page. Used for scanning and pagination.
      Returns:
      the last key to continue from
    • setLastKey

      public void setLastKey(String lastKey)
      Sets the last key from last page. Used for scanning and pagination.
      Parameters:
      lastKey - last id
    • getName

      public String getName()
      Name of this pager object (optional). Used to distinguish between multiple pagers.
      Returns:
      the name
    • setName

      public void setName(String name)
      Set the value of name.
      Parameters:
      name - the name (optional)
    • getSortby

      public String getSortby()
      The name of the field used when sorting the results.
      Returns:
      the name of the field or "timestamp" as the default sorting
    • setSortby

      public void setSortby(String sortby)
      Sets the value of sortby.
      Parameters:
      sortby - the sort field
    • 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

      public List<String> getSelect()
      Selects the field names to be returned.
      Returns:
      a set of field names
    • setSelect

      public void setSelect(List<String> select)
      Sets the fields that are selected to appear in the response from the API.
      Parameters:
      select - a set of field names
    • toString

      public String toString()
      Overrides:
      toString in class Object