public class RangeIteratorAdapter extends Object implements RangeIterator
Iterator
s into RangeIterator
s.
This helper class is used by the adapter classes in this package to
implement the JCR iterator interfaces on top of normal Java iterators.Modifier and Type | Field and Description |
---|---|
static RangeIterator |
EMPTY
Static instance of an empty
RangeIterator . |
Constructor and Description |
---|
RangeIteratorAdapter(Collection collection)
Creates a
RangeIterator for the given collection. |
RangeIteratorAdapter(Iterator iterator)
Creates an adapter for the given iterator of unknown size.
|
RangeIteratorAdapter(Iterator iterator,
long size)
Creates an adapter for the given iterator of the given size.
|
Modifier and Type | Method and Description |
---|---|
long |
getPosition()
Returns the current position of the iterator.
|
long |
getSize()
Returns the size of the iterator.
|
boolean |
hasNext()
Checks if this iterator has more elements.
|
Object |
next()
Returns the next element in this iterator and advances the iterator
position.
|
void |
remove()
Removes the previously retrieved element.
|
void |
skip(long n)
Skips the given number of elements.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public static final RangeIterator EMPTY
RangeIterator
.public RangeIteratorAdapter(Iterator iterator, long size)
iterator
- adapted iteratorsize
- size of the iterator, or -1 if unknownpublic RangeIteratorAdapter(Iterator iterator)
iterator
- adapted iteratorpublic RangeIteratorAdapter(Collection collection)
RangeIterator
for the given collection.collection
- the collection to iteratepublic long getPosition()
getPosition
in interface RangeIterator
public long getSize()
getSize
in interface RangeIterator
public void skip(long n) throws IllegalArgumentException, NoSuchElementException
skip
in interface RangeIterator
n
- number of elements to skipIllegalArgumentException
- if n is negativeNoSuchElementException
- if skipped past the last elementpublic boolean hasNext()
public Object next() throws NoSuchElementException
next
in interface Iterator
NoSuchElementException
- if there are no more elementspublic void remove() throws UnsupportedOperationException, IllegalStateException
remove
in interface Iterator
UnsupportedOperationException
- if removes are not permittedIllegalStateException
- if there is no previous element to removeCopyright © 2004–2021 The Apache Software Foundation. All rights reserved.