|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.web.util.PagingCursor
public class PagingCursor
Paging cursor. A utility for maintaining paged indexes for a collection of N items. There are two types of cursor: a) Paged This type of cursor is driven from a page number and page size. Random access within the collection is possible by jumping straight to a page. A simple scroll through the collection is supported by iterating through each next page. b) Rows This type of cursor is driven from a skip row count and maximum number of rows. Random access is not supported. The collection of items is simply scrolled through from start to end by iterating through each next set of rows. In either case, a paging cursor provides a start row and end row which may be used to extract the items for the page from the collection of N items. A zero (or less) page size or row maximum means "unlimited". Zero or one based Page and Rows indexes are supported. By default, Pages are 1 based and Rows are 0 based. At any time, -1 is returned to represent "out of range" i.e. for next, previous, last page and next skip count. Pseudo-code for traversing through a collection of N items (10 at a time): PagingCursor cursor = new PagingCursor(); Page page = cursor.createPageCursor(N, 10, 1); while (page.isInRange()) { for (long i = page.getStartRow(); i <= page.getEndRow(); i++) { ...collection[i]... } page = cursor.createPageCursor(N, 10, page.getNextPage()); } Rows rows = cursor.createRowsCursor(N, 10, 0); while (rows.isInRange()) { for (long i = page.getStartRow(); i <= page.getEndRow(); i++) { ...collection[i]... } rows = cursor.createRowsCursor(N, 10, rows.getNextSkipRows()); }
Nested Class Summary | |
---|---|
static class |
PagingCursor.Page
Page based Cursor |
static class |
PagingCursor.Rows
Rows based Cursor |
Constructor Summary | |
---|---|
PagingCursor()
|
Method Summary | |
---|---|
PagingCursor.Page |
createPageCursor(long totalRows,
int rowsPerPage,
int page)
Create a Page based Cursor |
PagingCursor.Page |
createPageCursor(long totalRows,
int rowsPerPage,
int page,
boolean zeroBasedPage,
boolean zeroBasedRow)
Create a Page based Cursor |
PagingCursor.Rows |
createRowsCursor(long totalRows,
long maxRows,
long skipRows)
Create a Rows based Cursor |
PagingCursor.Rows |
createRowsCursor(long totalRows,
long maxRows,
long skipRows,
boolean zeroBasedRow)
Create a Rows based Cursor |
boolean |
isZeroBasedPage()
Is zero based page index? Note: scoped to this paging cursor instance |
boolean |
isZeroBasedRow()
Is zero based row index? Note: scoped to this paging cursor instance |
void |
setZeroBasedPage(boolean zeroBasedPage)
Sets zero based page index Note: scoped to this paging cursor instance |
void |
setZeroBasedRow(boolean zeroBasedRow)
Sets zero based row index Note: scoped to this paging cursor instance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PagingCursor()
Method Detail |
---|
public void setZeroBasedPage(boolean zeroBasedPage)
zeroBasedPage
- true => 0 based, false => 1 basedpublic boolean isZeroBasedPage()
public void setZeroBasedRow(boolean zeroBasedRow)
zeroBasedRow
- true => 0 based, false => 1 basedpublic boolean isZeroBasedRow()
public PagingCursor.Page createPageCursor(long totalRows, int rowsPerPage, int page)
totalRows
- total rows in collectionrowsPerPage
- page sizepage
- page number (0 or 1 based)
public PagingCursor.Page createPageCursor(long totalRows, int rowsPerPage, int page, boolean zeroBasedPage, boolean zeroBasedRow)
totalRows
- total rows in collectionrowsPerPage
- page sizepage
- page number (0 or 1 based)zeroBasedPage
- true => 0 based, false => 1 basedzeroBasedRow
- true => 0 based, false => 1 based
public PagingCursor.Rows createRowsCursor(long totalRows, long maxRows, long skipRows)
totalRows
- total rows in collectionmaxRows
- maximum number of rows in pageskipRows
- number of rows to skip (0 - none)
public PagingCursor.Rows createRowsCursor(long totalRows, long maxRows, long skipRows, boolean zeroBasedRow)
totalRows
- total rows in collectionmaxRows
- maximum number of rows in pageskipRows
- number of rows to skip (0 - none)zeroBasedRow
- true => 0 based, false => 1 based
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |