Class IteratorEnumeration
java.lang.Object
org.apache.commons.collections.iterators.IteratorEnumeration
- All Implemented Interfaces:
Enumeration
Adapter to make an
Iterator
instance appear to be
an Enumeration
instance.- Since:
- Commons Collections 1.0
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- Author:
- James Strachan
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newIteratorEnumeration
that will not function untilsetIterator
is invoked.IteratorEnumeration
(Iterator iterator) Constructs a newIteratorEnumeration
that will use the given iterator. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying iterator.boolean
Returns true if the underlying iterator has more elements.Returns the next element from the underlying iterator.void
setIterator
(Iterator iterator) Sets the underlying iterator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Enumeration
asIterator
-
Constructor Details
-
IteratorEnumeration
public IteratorEnumeration()Constructs a newIteratorEnumeration
that will not function untilsetIterator
is invoked. -
IteratorEnumeration
Constructs a newIteratorEnumeration
that will use the given iterator.- Parameters:
iterator
- the iterator to use
-
-
Method Details
-
hasMoreElements
public boolean hasMoreElements()Returns true if the underlying iterator has more elements.- Specified by:
hasMoreElements
in interfaceEnumeration
- Returns:
- true if the underlying iterator has more elements
-
nextElement
Returns the next element from the underlying iterator.- Specified by:
nextElement
in interfaceEnumeration
- Returns:
- the next element from the underlying iterator.
- Throws:
NoSuchElementException
- if the underlying iterator has no more elements
-
getIterator
Returns the underlying iterator.- Returns:
- the underlying iterator
-
setIterator
Sets the underlying iterator.- Parameters:
iterator
- the new underlying iterator
-