Iterator into a ResettableListIterator.
For plain Iterators this is accomplished by caching the returned
elements. This class can also be used to simply add
ResettableIterator
functionality to a given ListIterator.
The ListIterator interface has additional useful methods
for navigation - previous() and the index methods.
This class allows a regular Iterator to behave as a
ListIterator. It achieves this by building a list internally
of as the underlying iterator is traversed.
The optional operations of ListIterator are not supported for plain Iterators.
This class implements ResettableListIterator from Commons Collections 3.2.
| Modifier and Type | Field and Description |
|---|---|
| private static final String | CANNOT_REMOVE_MESSAGE
Message used when set or add are called. |
| private int | currentIndex
The current index of this iterator. |
| private final Iterator | iterator
The underlying iterator being decorated. |
| private final List | list
The list being used to cache the iterator. |
| private boolean | removeState
recall whether the wrapped iterator's "cursor" is in such a state as to allow remove() to be called |
| private static final String | UNSUPPORTED_OPERATION_MESSAGE
Message used when set or add are called. |
| private int | wrappedIteratorIndex
The current index of the wrapped iterator. |
| Access | Constructor and Description |
|---|---|
| public | ListIteratorWrapper(final Iterator<? extends E>
the iterator to wrap iterator)Constructs a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(final E
the object to add obj)Implements java. UnsupportedOperationException
unless the underlying Iterator is a ListIterator.
|
| public boolean | Returns: true if there are more elementsImplements java. |
| public boolean | Returns: true if there are previous elementsImplements java. |
| public E | Returns: the next element from the iteratorImplements java. |
| public int | Returns: the index of the next elementImplements java. |
| public E | Returns: the previous elementImplements java. |
| public int | Returns: the index of the previous elementImplements java. |
| public void | remove()
Overrides default java. Implements java. UnsupportedOperationException if previous() has ever been called.
|
| public void | reset()
Implements org. |
| public void | set(final E
the object to set obj)Implements java. UnsupportedOperationException
unless the underlying Iterator is a ListIterator.
|
| CANNOT_REMOVE_MESSAGE | back to summary |
|---|---|
| private static final String CANNOT_REMOVE_MESSAGE Message used when set or add are called. | |
| currentIndex | back to summary |
|---|---|
| private int currentIndex The current index of this iterator. | |
| iterator | back to summary |
|---|---|
| private final Iterator<? extends E> iterator The underlying iterator being decorated. | |
| list | back to summary |
|---|---|
| private final List<E> list The list being used to cache the iterator. | |
| removeState | back to summary |
|---|---|
| private boolean removeState recall whether the wrapped iterator's "cursor" is in such a state as to allow remove() to be called | |
| UNSUPPORTED_OPERATION_MESSAGE | back to summary |
|---|---|
| private static final String UNSUPPORTED_OPERATION_MESSAGE Message used when set or add are called. | |
| wrappedIteratorIndex | back to summary |
|---|---|
| private int wrappedIteratorIndex The current index of the wrapped iterator. | |
| ListIteratorWrapper | back to summary |
|---|---|
| public ListIteratorWrapper(final Iterator<? extends E> iterator) Constructs a new
| |
| add | back to summary |
|---|---|
| public void add(final E obj) throws UnsupportedOperationException Implements java. Throws
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Returns true if there are more elements in the iterator.
| |
| hasPrevious | back to summary |
|---|---|
| public boolean hasPrevious() Implements java. Returns true if there are previous elements in the iterator.
| |
| next | back to summary |
|---|---|
| public E next() throws NoSuchElementException Implements java. Returns the next element from the iterator.
| |
| nextIndex | back to summary |
|---|---|
| public int nextIndex() Implements java. Returns the index of the next element.
| |
| previous | back to summary |
|---|---|
| public E previous() throws NoSuchElementException Implements java. Returns the previous element.
| |
| previousIndex | back to summary |
|---|---|
| public int previousIndex() Implements java. Returns the index of the previous element.
| |
| remove | back to summary |
|---|---|
| public void remove() throws UnsupportedOperationException Overrides default java. Implements java. Throws
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Resets this iterator back to the position at which the iterator was created.
| |
| set | back to summary |
|---|---|
| public void set(final E obj) throws UnsupportedOperationException Implements java. Throws
| |