com.taco.util
Class EnumerationToIteratorAdapter

java.lang.Object
  extended by 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.
 
Constructor Summary
EnumerationToIteratorAdapter(java.util.Enumeration e)
          Construct a new instance based on the argument enumeration.
 
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
 

Field Detail

_e

protected java.util.Enumeration _e
The Enumeration that this adapter is based on.

Constructor Detail

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.

Method Detail

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