|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.web.util.paging.Paging
public class Paging
Paging. 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) Windowed 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. Pseudo-code for traversing through a collection of N items (10 at a time): Paging paging = new Paging(); Cursor page = paging.createCursor(N, paging.createPage(1, 10)); while (page.isInRange()) { for (long i = page.getStartRow(); i <= page.getEndRow(); i++) { ...collection[i]... } page = paging.createCursor(N, paging.createPage(page.getNextPage(), page.getPageSize()); } Cursor window = paging.createCursor(N, paging.createWindow(0, 10)); while (window.isInRange()) { for (long i = window.getStartRow(); i <= window.getEndRow(); i++) { ...collection[i]... } window = paging.createCursor(N, paging.createWindow(window.getNextPage(), window.getPageSize()); }
Nested Class Summary | |
---|---|
static class |
Paging.PageType
|
Constructor Summary | |
---|---|
Paging()
|
Method Summary | |
---|---|
Cursor |
createCursor(int totalRows,
Page page)
Create a Cursor |
Page |
createPage(int pageNumber,
int pageSize)
Create a Page |
PagedResults |
createPagedResult(java.lang.Object result,
Cursor cursor)
Create a Paged Result Set |
PagedResults |
createPagedResults(java.lang.Object[] results,
Cursor cursor)
Create a Paged Result Set |
Page |
createPageOrWindow(java.lang.Integer pageNumber,
java.lang.Integer pageSize,
java.lang.Integer skipCount,
java.lang.Integer maxItems)
Create a Page or Window |
Page |
createPageOrWindow(java.util.Map args)
Create a Page or Window from standardised request arguments For Paged based index (take precedence over window based index, if both are specified): - request args pageNo => page number index pageSize => size of page For Window based index (as defined by CMIS): - request args (take precedence over header values if both are specified) skipCount => row number start index maxItems => size of page |
Page |
createUnlimitedPage()
Create an unlimited Page |
Page |
createWindow(int skipRows,
int maxRows)
Create a Window |
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 Paging()
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 Page createPageOrWindow(java.util.Map args)
args
- request args
public Page createPageOrWindow(java.lang.Integer pageNumber, java.lang.Integer pageSize, java.lang.Integer skipCount, java.lang.Integer maxItems)
pageNumber
- page number (optional and paired with pageSize)pageSize
- page size (optional and paired with pageNumber)skipCount
- skipCount (optional and paired with maxItems)maxItems
- maxItems (optional and paired with skipCount)
public Page createPage(int pageNumber, int pageSize)
pageNumber
- page numberpageSize
- page size
public Page createUnlimitedPage()
public Page createWindow(int skipRows, int maxRows)
skipRows
- number of rows to skipmaxRows
- maximum number of rows in window
public Cursor createCursor(int totalRows, Page page)
totalRows
- total number of rows in cursor (< 0 for don't know)page
- the page / window within cursor
public PagedResults createPagedResults(java.lang.Object[] results, Cursor cursor)
results
- the results for the page within the cursorcursor
- the cursor
public PagedResults createPagedResult(java.lang.Object result, Cursor cursor)
results
- the results for the page within the cursorcursor
- the cursor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |