Class Page


  • public final class Page
    extends java.lang.Object
    Object representing a page parameter. A description of a web-service request page has two properties, start and size. The default page is one starting at the beginning and with the maximum available size. This class also has facilities for advancing between pages.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Page DEFAULT
      The default page size (from the beginning to the maximum page size)
    • Constructor Summary

      Constructors 
      Constructor Description
      Page​(int start)
      Construct a new page, specifying a start point.
      Page​(int start, int size)
      Construct a new page, specifying a start point and a size.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Page advance​(int steps)
      Advance to a new page my a given number of steps.
      boolean equals​(java.lang.Object other)  
      Page first()
      Get the first page.
      java.lang.Integer getSize()
      Get the maximum size of this page.
      int getStart()
      Get the start index of this page.
      int hashCode()  
      Page last​(int total)
      Get the last page.
      Page next()
      Get the next page.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT

        public static final Page DEFAULT
        The default page size (from the beginning to the maximum page size)
    • Constructor Detail

      • Page

        public Page​(int start,
                    int size)
        Construct a new page, specifying a start point and a size.
        Parameters:
        start - The index of the first result to retrieve.
        size - The maximum size of the page of results you want back.
      • Page

        public Page​(int start)
        Construct a new page, specifying a start point.
        Parameters:
        start - The index of the first result to retrieve.
    • Method Detail

      • getStart

        public int getStart()
        Get the start index of this page.
        Returns:
        The index.
      • getSize

        public java.lang.Integer getSize()
        Get the maximum size of this page.
        Returns:
        the size.
      • advance

        public Page advance​(int steps)
        Advance to a new page my a given number of steps. If this is the first page, and 2 is given as an argument, an object representing the third page will be returned. The new page will have the same size, but an adjusted starting point. The adjusted starting point will never be negative. Negative arguments can be given to go back. An argument of 0 will return the caller.
        Parameters:
        steps - The number of pages to advance. 1 gives the next page.
        Returns:
        A new page, or this page, if the argument is 0.
      • first

        public Page first()
        Get the first page. The new page will have the same size as this page, but a starting position of 0.
        Returns:
        The first page.
      • next

        public Page next()
        Get the next page. The new page will have the same size as this page, but a starting position of start + size.
        Returns:
        The next page.
      • last

        public Page last​(int total)
        Get the last page. The new page will have the same size as this page, but a starting position such that start + size >= total. If this page has no size (ie. it is an open-ended page) then the caller will be returned.
        Parameters:
        total - The total size of the result set.
        Returns:
        A page that includes the last result row.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object