bucket.core.actions
Class PagerPaginationSupport

java.lang.Object
  extended by bucket.core.actions.PagerPaginationSupport
All Implemented Interfaces:
PaginationSupport

public class PagerPaginationSupport
extends java.lang.Object
implements PaginationSupport

This class stores its items using a Pager - which cannot report the total size of the result. The Pager.getCurrentPage() returns a list of objects currently loaded in memory, which can return a List.size(). This number is imprecise, however, and is used as functional approximation. For various reasons explained in the {#link Pager} javadoc, the only way to gain an accurate total size from a {#link Pager} is by using its iterator and keeping count of each object. If you have a regular, average sized list of items then use PaginationSupport.


Field Summary
static int DEFAULT_COUNT_ON_EACH_PAGE
           
 int[] nextStartIndexes
           
 java.util.List page
           
 java.lang.Integer pagerSize
           
 int[] previousStartIndexes
           
 
Constructor Summary
PagerPaginationSupport()
           
PagerPaginationSupport(int countOnEachPage)
           
 
Method Summary
 int getCountOnEachPage()
           
 int getEndIndex()
           
 com.atlassian.user.search.page.Pager getItems()
           
 int getNextIndex()
           
 int getNextStartIndex()
          Returns the next start index.
 int[] getNextStartIndexes()
          Returns an array of start indexes for pages that appear after the current page If there are no further pages, null is returned
 int getNiceEndIndex()
          Returns an end index for use in the UI.
 int getNiceStartIndex()
          Returns a start index for use in the UI.
 java.util.List getPage()
          returns a subset of the list of items passed in, based on startIndex and the max result per page
 int getPageSize()
          Returns the number of items available on the current page.
 int getPreviousIndex()
           
 int getPreviousStartIndex()
          Returns the previous start index.
 int[] getPreviousStartIndexes()
          Returns an array of start indexes for pages that appear before the current page If there are no preceding pages, null is returned
 int getStartIndex()
          Returns the start index.
 int getStartIndexValue()
          Always return the start index value, regardless of whether the pagination has any total.
 int getTotal()
          Returns the total number of items in the list
 boolean isTryNext()
           
 void setItems(com.atlassian.user.search.page.Pager items)
           
 void setStartIndex(int startIndex)
           
 void setTryNext(boolean tryNext)
           
 void skipTo(int indexPosition)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COUNT_ON_EACH_PAGE

public static int DEFAULT_COUNT_ON_EACH_PAGE

page

public java.util.List page

pagerSize

public java.lang.Integer pagerSize

nextStartIndexes

public int[] nextStartIndexes

previousStartIndexes

public int[] previousStartIndexes
Constructor Detail

PagerPaginationSupport

public PagerPaginationSupport()

PagerPaginationSupport

public PagerPaginationSupport(int countOnEachPage)
Method Detail

getCountOnEachPage

public int getCountOnEachPage()

getItems

public com.atlassian.user.search.page.Pager getItems()

setItems

public void setItems(com.atlassian.user.search.page.Pager items)

setStartIndex

public void setStartIndex(int startIndex)

getNiceEndIndex

public int getNiceEndIndex()
Description copied from interface: PaginationSupport
Returns an end index for use in the UI. It returns the end index - 1

Specified by:
getNiceEndIndex in interface PaginationSupport
Returns:
a nice end index

getEndIndex

public int getEndIndex()

getStartIndex

public int getStartIndex()
Description copied from interface: PaginationSupport
Returns the start index. If the start index exceeds the index of the last element, the index of the last element is returned. If the start index is less than 0, 0 is returned.

Specified by:
getStartIndex in interface PaginationSupport
Returns:
the start index.

getStartIndexValue

public int getStartIndexValue()
Always return the start index value, regardless of whether the pagination has any total.

Specified by:
getStartIndexValue in interface PaginationSupport
Returns:
the start index value, regardless of whether the pagination has any total.

getNextIndex

public int getNextIndex()

getNextStartIndex

public int getNextStartIndex()
Description copied from interface: PaginationSupport
Returns the next start index. Returns -1 if we are on the last page (there is no next page).

Specified by:
getNextStartIndex in interface PaginationSupport
Returns:
the next start index. Returns -1 if we are on the last page (there is no next page).

getPreviousIndex

public int getPreviousIndex()

getPreviousStartIndex

public int getPreviousStartIndex()
Description copied from interface: PaginationSupport
Returns the previous start index. Returns -1 if we are on the first page (there is no previous page).

Specified by:
getPreviousStartIndex in interface PaginationSupport
Returns:
the previous start index. Returns -1 if we are on the first page (there is no previous page).

getNextStartIndexes

public int[] getNextStartIndexes()
Description copied from interface: PaginationSupport
Returns an array of start indexes for pages that appear after the current page If there are no further pages, null is returned

Specified by:
getNextStartIndexes in interface PaginationSupport
Returns:
an array of start indexes for pages that appear after the current page

getPreviousStartIndexes

public int[] getPreviousStartIndexes()
Description copied from interface: PaginationSupport
Returns an array of start indexes for pages that appear before the current page If there are no preceding pages, null is returned

Specified by:
getPreviousStartIndexes in interface PaginationSupport
Returns:
an array of start indexes for pages that appear before the current page

getNiceStartIndex

public int getNiceStartIndex()
Description copied from interface: PaginationSupport
Returns a start index for use in the UI. It returns the start index + 1

Specified by:
getNiceStartIndex in interface PaginationSupport
Returns:
a nice start index

getPage

public java.util.List getPage()
returns a subset of the list of items passed in, based on startIndex and the max result per page

Specified by:
getPage in interface PaginationSupport
Returns:
a page of results

getTotal

public int getTotal()
Description copied from interface: PaginationSupport
Returns the total number of items in the list

Specified by:
getTotal in interface PaginationSupport
Returns:
total number of items in the list

skipTo

public void skipTo(int indexPosition)

isTryNext

public boolean isTryNext()

setTryNext

public void setTryNext(boolean tryNext)

getPageSize

public int getPageSize()
Description copied from interface: PaginationSupport
Returns the number of items available on the current page.

Specified by:
getPageSize in interface PaginationSupport
Returns:
the number of items available on the current page.


Copyright © 2003-2013 Atlassian. All Rights Reserved.