Class 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 [alex@erudika.com]
    • Constructor Detail

      • 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 Detail

      • 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