T
- the type of items in this iterator.public class PagingIterator<T> extends CachingIterator<T>
CachingIterator
which can more easily divide the items
into pages, where optionally each page can be seen as its own
Iterator
instance for convenience using nextPage()
.Constructor and Description |
---|
PagingIterator(Iterator<T> source,
int pageSize)
Creates a new paging iterator with
source as its underlying
Iterator to lazily get items from. |
Modifier and Type | Method and Description |
---|---|
Iterator<T> |
nextPage()
Returns a new
Iterator instance which exposes the current page
as its own iterator, which fetches items lazily from the underlying
iterator. |
int |
page() |
int |
page(int newPage)
Sets the current page of the iterator.
|
add, current, hasNext, hasPrevious, next, nextIndex, position, position, previous, previousIndex, remove, set
public int page()
0
.
This value is based on the CachingIterator.position()
and the page size.public int page(int newPage)
0
means the first page.newPage
- the current page to set for the iterator, must be
non-negative. The next item returned by the iterator will be the first
item in that page.public Iterator<T> nextPage()
Iterator
instance which exposes the current page
as its own iterator, which fetches items lazily from the underlying
iterator. It is discouraged to use an Iterator
returned from
this method at the same time as using methods like CachingIterator.next()
or
CachingIterator.previous()
, where the results may be unpredictable. So either
use only nextPage()
(in conjunction with page(int)
if
necessary) or go with regular CachingIterator.next()
/CachingIterator.previous()
.Iterator
.Copyright © 2002–2014 The Neo4j Graph Database Project. All rights reserved.