java.lang.Object
org.bzdev.util.EnumerationIterator<E>
- Type Parameters:
E
- the type of the object produced by this iterator and the enumeration it encapsulates
- All Implemented Interfaces:
Iterator<E>
Class for an Iterator whose implementation uses an Enumeration.
The Iterator class was introduced in Java 1.2 as an improvement
over the Enumeration class. Unfortunately, some APIs require
an Enumeration and others require an Iterator. This class provides
a bridge between the two APIs.
-
Constructor Details
-
EnumerationIterator
Constructor. The Enumeration passed to the constructor will be modified as this class is used.- Parameters:
enumeration
- an instance of Enumeration
-
-
Method Details
-
next
- Specified by:
next
in interfaceIterator<E>
- Throws:
NoSuchElementException
-
hasNext
public boolean hasNext() -
remove
- Specified by:
remove
in interfaceIterator<E>
- Throws:
UnsupportedOperationException
IllegalStateException
-
iterable
Generate an Iterable based on an Enumeration so that a foreach clause can be used.- Type Parameters:
E
- the type of objects produced by the argumentenumeration
- Parameters:
enumeration
- the Enumeration- Returns:
- an Iterable that will allow the enumeration to be used by a foreach clause
-