Class Paging

java.lang.Object
io.jenkins.plugins.batchcontrol.ui.Paging

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class Paging extends Object
Paging arithmetic shared by every list screen (D-44). Each section keeps its own Jelly-facing names (getPage, getPageItems, getTotal, isHasPrevious, isHasNext) and delegates the arithmetic here, so the screens cannot drift apart again.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Rows per page on every Batch Control list screen (SPEC: 50 by default).
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    The 1-based page from the page query parameter; 1 on absence or garbage.
    static int
    currentPage(String parameter)
    The 1-based page from the named query parameter; 1 on absence, garbage or a value below 1.
    static boolean
    hasNext(int page, int total)
    Whether an older page exists for a list of total rows.
    static boolean
    hasPrevious(int page)
    Whether a newer page exists (every page after the first).
    static int
    offset(int page)
    The zero-based offset of the first row of page; saturates instead of overflowing.
    static String
    query(String parameter, long page)
    #45: the query string (without the leading ?) of a pager link to page of the list paged with parameter: every other parameter of the current URL's query string, in its order (the other lists' pendingPage, activePage, endedPage), then parameter=page.
    static <T> List<T>
    slice(List<T> all, int page)
    The rows of page out of a fully materialised, already sorted list (a copy).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PAGE_SIZE

      public static final int PAGE_SIZE
      Rows per page on every Batch Control list screen (SPEC: 50 by default).
      See Also:
  • Method Details

    • currentPage

      public static int currentPage()
      The 1-based page from the page query parameter; 1 on absence or garbage.
    • currentPage

      public static int currentPage(String parameter)
      The 1-based page from the named query parameter; 1 on absence, garbage or a value below 1.
      Parameters:
      parameter - the query parameter name (a screen with two tables uses two names)
    • offset

      public static int offset(int page)
      The zero-based offset of the first row of page; saturates instead of overflowing.
    • slice

      public static <T> List<T> slice(List<T> all, int page)
      The rows of page out of a fully materialised, already sorted list (a copy).
    • query

      public static String query(String parameter, long page)
      #45: the query string (without the leading ?) of a pager link to page of the list paged with parameter: every other parameter of the current URL's query string, in its order (the other lists' pendingPage, activePage, endedPage), then parameter=page. Only the query string is read, never a form body, and each name and value is decoded and URL-encoded again, so a hostile value travels as data; the view escapes the result as an attribute value too. A pair that does not decode is dropped.
      Parameters:
      parameter - the query parameter of the paged list
      page - the 1-based page the link opens
    • hasPrevious

      public static boolean hasPrevious(int page)
      Whether a newer page exists (every page after the first).
    • hasNext

      public static boolean hasNext(int page, int total)
      Whether an older page exists for a list of total rows.