|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections4.iterators.ListIteratorWrapper<E>
public class ListIteratorWrapper<E>
Converts an Iterator
into a ResettableListIterator
.
For plain Iterator
s 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 Iterator
s.
This class implements ResettableListIterator from Commons Collections 3.2.
Constructor Summary | |
---|---|
ListIteratorWrapper(Iterator<? extends E> iterator)
Constructs a new ListIteratorWrapper that will wrap
the given iterator. |
Method Summary | |
---|---|
void |
add(E obj)
Throws UnsupportedOperationException
unless the underlying Iterator is a ListIterator . |
boolean |
hasNext()
Returns true if there are more elements in the iterator. |
boolean |
hasPrevious()
Returns true if there are previous elements in the iterator. |
E |
next()
Returns the next element from the iterator. |
int |
nextIndex()
Returns the index of the next element. |
E |
previous()
Returns the the previous element. |
int |
previousIndex()
Returns the index of the previous element. |
void |
remove()
Throws UnsupportedOperationException if previous() has ever been called. |
void |
reset()
Resets this iterator back to the position at which the iterator was created. |
void |
set(E obj)
Throws UnsupportedOperationException
unless the underlying Iterator is a ListIterator . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListIteratorWrapper(Iterator<? extends E> iterator)
ListIteratorWrapper
that will wrap
the given iterator.
iterator
- the iterator to wrap
NullPointerException
- if the iterator is nullMethod Detail |
---|
public void add(E obj) throws UnsupportedOperationException
UnsupportedOperationException
unless the underlying Iterator
is a ListIterator
.
add
in interface ListIterator<E>
obj
- the object to add
UnsupportedOperationException
- if the underlying iterator is not of
type ListIterator
public boolean hasNext()
hasNext
in interface Iterator<E>
hasNext
in interface ListIterator<E>
public boolean hasPrevious()
hasPrevious
in interface ListIterator<E>
hasPrevious
in interface OrderedIterator<E>
public E next() throws NoSuchElementException
next
in interface Iterator<E>
next
in interface ListIterator<E>
NoSuchElementException
- if there are no more elementspublic int nextIndex()
nextIndex
in interface ListIterator<E>
public E previous() throws NoSuchElementException
previous
in interface ListIterator<E>
previous
in interface OrderedIterator<E>
NoSuchElementException
- if there are no previous elementspublic int previousIndex()
previousIndex
in interface ListIterator<E>
public void remove() throws UnsupportedOperationException
UnsupportedOperationException
if previous()
has ever been called.
remove
in interface Iterator<E>
remove
in interface ListIterator<E>
UnsupportedOperationException
- alwayspublic void set(E obj) throws UnsupportedOperationException
UnsupportedOperationException
unless the underlying Iterator
is a ListIterator
.
set
in interface ListIterator<E>
obj
- the object to set
UnsupportedOperationException
- if the underlying iterator is not of
type ListIterator
public void reset()
reset
in interface ResettableIterator<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |