com.taco.util
Class EnumerationToIteratorAdapter
java.lang.Object
com.taco.util.EnumerationToIteratorAdapter
- All Implemented Interfaces:
- java.util.Iterator
public class EnumerationToIteratorAdapter
- extends java.lang.Object
- implements java.util.Iterator
An adapter from an Enumeration
to an Iterator
.
This is useful when using legacy classes that have methods that return
Enumeration
. The remove()
method throws an
UnsupportedOperationException because Enumeration
does not
have a corresponding method.
- Author:
- Jeff Tsay
Field Summary |
protected java.util.Enumeration |
_e
The Enumeration that this adapter is based on. |
Method Summary |
boolean |
hasNext()
|
java.lang.Object |
next()
|
void |
remove()
Throw an UnsupportedOperationException , since
enumerations don't have this ability. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_e
protected java.util.Enumeration _e
- The
Enumeration
that this adapter is based on.
EnumerationToIteratorAdapter
public EnumerationToIteratorAdapter(java.util.Enumeration e)
- Construct a new instance based on the argument enumeration. The
enumeration will be modified by this class so if it is necessary to
keep the original state of the enumeration, the enumeration should be
cloned before passing it to this enumeration.
hasNext
public final boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator
next
public final java.lang.Object next()
- Specified by:
next
in interface java.util.Iterator
remove
public void remove()
- Throw an
UnsupportedOperationException
, since
enumerations don't have this ability.
- Specified by:
remove
in interface java.util.Iterator