public class EnumerationIterator<E> extends Objectimplements Iterator <E>
Enumeration instances appear to be
Iterator instances.
| Constructor and Description |
|---|
EnumerationIterator()
Constructs a new
EnumerationIterator that will not function until
setEnumeration(Enumeration) is called.
|
EnumerationIterator(Enumeration
Constructs a new
EnumerationIterator that provides an iterator view of the given enumeration.
|
EnumerationIterator(Enumeration
Constructs a new
EnumerationIterator that will remove elements from the specified collection.
|
| Modifier and Type | Method and Description |
|---|---|
Enumeration |
getEnumeration()
Returns the underlying enumeration.
|
boolean |
hasNext()
Returns true if the underlying enumeration has more elements.
|
E |
next()
Returns the next object from the enumeration.
|
void |
remove()
Removes the last retrieved element if a collection is attached.
|
void |
setEnumeration(Enumeration
Sets the underlying enumeration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic EnumerationIterator()
EnumerationIterator that will not function until
setEnumeration(Enumeration) is called.
public EnumerationIterator(Enumeration<? extends E> enumeration)
EnumerationIterator that provides an iterator view of the given enumeration.
enumeration - the enumeration to use
public EnumerationIterator(Enumeration<? extends E> enumeration, Collection <? super E> collection)
EnumerationIterator that will remove elements from the specified collection.
enumeration - the enumeration to use
collection - the collection to remove elements from
public boolean hasNext()
hasNext in interface
Iterator<E>
NullPointerException - if the underlying enumeration is null
public E next()
next in interface
Iterator<E>
NullPointerException - if the enumeration is null
public void remove()
Functions if an associated Collection is known. If so, the first occurrence of the last returned object from this iterator will be removed from the collection.
remove in interface
Iterator<E>
IllegalStateException -
next() not called.
UnsupportedOperationException - if no associated collection
public Enumeration<? extends E> getEnumeration()
public void setEnumeration(Enumeration<? extends E> enumeration)
enumeration - the new underlying enumeration