Class Pagination


  • public class Pagination
    extends Object
    Query pagination configuration
    Since:
    6.2.0
    Author:
    osbornb
    • Constructor Detail

      • Pagination

        public Pagination​(int limit)
        Constructor
        Parameters:
        limit - upper bound number of rows
      • Pagination

        public Pagination​(int limit,
                          long offset)
        Constructor
        Parameters:
        limit - upper bound number of rows
        offset - row result starting offset
      • Pagination

        public Pagination​(int limit,
                          Long offset)
        Constructor
        Parameters:
        limit - upper bound number of rows
        offset - row result starting offset
    • Method Detail

      • find

        public static Pagination find​(String sql)
        Find the pagination offset and limit from the SQL statement
        Parameters:
        sql - SQL statement
        Returns:
        pagination or null if not found
      • replace

        public static String replace​(Pagination pagination,
                                     String sql)
        Replace the pagination limit and offset in the SQL statement
        Parameters:
        pagination - pagination settings
        sql - SQL statement
        Returns:
        modified SQL statement
      • getLimit

        public int getLimit()
        Get the limit
        Returns:
        upper bound number of rows
      • setLimit

        public void setLimit​(int limit)
        Set the limit
        Parameters:
        limit - upper bound number of rows
      • hasLimit

        public boolean hasLimit()
        Is there positive limit
        Returns:
        true if limit above 0
      • getOffset

        public Long getOffset()
        Get the offset
        Returns:
        row result starting offset
      • hasOffset

        public boolean hasOffset()
        Is there an offset
        Returns:
        true if has an offset
      • setOffset

        public void setOffset​(Long offset)
        Set the offset
        Parameters:
        offset - row result starting offset
      • incrementOffset

        public void incrementOffset()
        If the limit is positive, increment the offset
      • incrementOffset

        public void incrementOffset​(long count)
        Increment the offset by the count
        Parameters:
        count - count to increment
      • replace

        public String replace​(String sql)
        Replace the limit and offset in the SQL statement with the pagination values
        Parameters:
        sql - SQL statement
        Returns:
        modified SQL statement