org.clapper.util.misc
Class EnumerationIterator<T>
- java.lang.Object
-
- org.clapper.util.misc.EnumerationIterator<T>
-
- All Implemented Interfaces:
- java.lang.Iterable<T>, java.util.Iterator<T>
public class EnumerationIterator<T> extends java.lang.Object implements java.util.Iterator<T>, java.lang.Iterable<T>The EnumerationIterator class is an adapter that makes a java.util.Enumeration object look and behave like a java.util.Iterator objects. The EnumerationIterator class implements the Iterator interface and wraps an existing Enumeration object. This class is the conceptual opposite of the Collections.enumeration() method in the java.util package.
You can also use an instance of this class to wrap an Enumeration for use in a JDK 1.5-style for each loop. For instance:
Vector
v = ... for (String s : new EnumerationIterator (v.elements())) ... - See Also:
Iterator,Enumeration
-
-
Constructor Summary
Constructors Constructor and Description EnumerationIterator(java.util.Enumeration<T> enumeration)Allocate a new EnumerationIterator object that will forward its calls to the specified Enumeration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanhasNext()Determine whether the underlying Enumeration has more elements.java.util.Iterator<T>iterator()Returns this iterator.Tnext()Get the next element from the underlying Enumeration.voidremove()Removes from the underlying collection the last element returned by the iterator.
-
-
-
Constructor Detail
-
EnumerationIterator
public EnumerationIterator(java.util.Enumeration<T> enumeration)
Allocate a new EnumerationIterator object that will forward its calls to the specified Enumeration.- Parameters:
enumeration- The Enumeration to which to forward calls
-
-
Method Detail
-
hasNext
public boolean hasNext()
Determine whether the underlying Enumeration has more elements.
-
iterator
public java.util.Iterator<T> iterator()
Returns this iterator. Necessary for the Iterable interface.- Specified by:
iteratorin interfacejava.lang.Iterable<T>- Returns:
- this object
-
next
public T next() throws java.util.NoSuchElementException
Get the next element from the underlying Enumeration.- Specified by:
nextin interfacejava.util.Iterator<T>- Returns:
- the next element from the underlying Enumeration
- Throws:
java.util.NoSuchElementException- No more elements exist- See Also:
Iterator.next()
-
remove
public void remove() throws java.lang.IllegalStateException, java.lang.UnsupportedOperationExceptionRemoves from the underlying collection the last element returned by the iterator. Not supported by this class.- Specified by:
removein interfacejava.util.Iterator<T>- Throws:
java.lang.IllegalStateException- doesn'tjava.lang.UnsupportedOperationException- unconditionally
-
-
DMelt 3.0 © DataMelt by jWork.ORG