bucket.core.actions
Class PaginationSupport

java.lang.Object
  extended by bucket.core.actions.PaginationSupport
All Implemented Interfaces:
PaginationSupport
Direct Known Subclasses:
ManualTotalPaginationSupport, UsernameToUserTranslatingPaginationSupport

public class PaginationSupport
extends Object
implements PaginationSupport

Where there are a _very_ large number of items to paginate (in othe order of 10,000's), loading them all up in memory from the db and then handing them out to the user in a .subList fashion is not very efficient In this scenario we only want to use this bean to compute our next and previous indexes. Hence please use this bean in one of two ways (a) set _items_ on this bean and have the bean slice and dice up the uber collection for you and serve it to you with getPage() OR (b) set the total on this bean _only_ and leave the items _alone_. this is recommended for really large collections where its not ideal to load them all up.


Field Summary
static int DEFAULT_COUNT_ON_EACH_PAGE
           
static int DEFAULT_PAGE_SIZE
           
 
Constructor Summary
PaginationSupport()
           
PaginationSupport(int pageSize)
           
 
Method Summary
 int getCountOnEachPage()
          Deprecated. since 3.0 (at least). Please use getPageSize()
 int getEndIndex()
          Deprecated. since 3.0 (at least). Please use getNiceEndIndex()
 List getItems()
           
 int getNextIndex()
          Deprecated. since 3.0 (at least). Please use getNextStartIndex()
 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.
 List getPage()
          Returns a subset of the list of items passed in, based on startIndex and the page size
 int getPageSize()
          Returns the number of items available on the current page.
 int getPreviousIndex()
          Deprecated. since 3.0 (at least). Please use getPreviousStartIndex()
 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
 void setItems(List items)
           
 void setPageSize(int pageSize)
           
 void setStartIndex(int startIndex)
           
 void setTotal(int total)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PAGE_SIZE

public static int DEFAULT_PAGE_SIZE

DEFAULT_COUNT_ON_EACH_PAGE

public static int DEFAULT_COUNT_ON_EACH_PAGE
Constructor Detail

PaginationSupport

public PaginationSupport()

PaginationSupport

public PaginationSupport(int pageSize)
Method Detail

getCountOnEachPage

public int getCountOnEachPage()
Deprecated. since 3.0 (at least). Please use getPageSize()


getItems

public List getItems()

setItems

public void setItems(List 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()
Deprecated. since 3.0 (at least). Please use getNiceEndIndex()

This implementation always returned the nice end index. The correct end index would have been one less. Deprecating this and introduce a new method that has a more accurate name.


getStartIndex

public int getStartIndex()
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()
Deprecated. since 3.0 (at least). Please use getNextStartIndex()


getNextStartIndex

public int getNextStartIndex()
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()
Deprecated. since 3.0 (at least). Please use getPreviousStartIndex()


getPreviousStartIndex

public int getPreviousStartIndex()
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 List getPage()
Returns a subset of the list of items passed in, based on startIndex and the page size

Specified by:
getPage in interface PaginationSupport
Returns:
a subset of the list of items passed in, based on startIndex and the page size

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

setTotal

public void setTotal(int total)

setPageSize

public void setPageSize(int pageSize)

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-2011 Atlassian. All Rights Reserved.