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