public class EnumerationIterator<E>
extends java.lang.Object
implements java.util.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(java.util.Enumeration<? extends E> enumeration)
Constructs a new
EnumerationIterator that provides
an iterator view of the given enumeration. |
EnumerationIterator(java.util.Enumeration<? extends E> enumeration,
java.util.Collection<? super E> collection)
Constructs a new
EnumerationIterator that will remove
elements from the specified collection. |
Modifier and Type | Method and Description |
---|---|
java.util.Enumeration<? extends E> |
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(java.util.Enumeration<? extends E> enumeration)
Sets the underlying enumeration.
|
public EnumerationIterator()
EnumerationIterator
that will not
function until setEnumeration(Enumeration)
is called.public EnumerationIterator(java.util.Enumeration<? extends E> enumeration)
EnumerationIterator
that provides
an iterator view of the given enumeration.enumeration
- the enumeration to usepublic EnumerationIterator(java.util.Enumeration<? extends E> enumeration, java.util.Collection<? super E> collection)
EnumerationIterator
that will remove
elements from the specified collection.enumeration
- the enumeration to usecollection
- the collection to remove elements frompublic boolean hasNext()
hasNext
in interface java.util.Iterator<E>
java.lang.NullPointerException
- if the underlying enumeration is nullpublic E next()
next
in interface java.util.Iterator<E>
java.lang.NullPointerException
- if the enumeration is nullpublic 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 java.util.Iterator<E>
java.lang.IllegalStateException
- next()
not called.java.lang.UnsupportedOperationException
- if no associated collectionpublic java.util.Enumeration<? extends E> getEnumeration()
public void setEnumeration(java.util.Enumeration<? extends E> enumeration)
enumeration
- the new underlying enumerationCopyright © 2010 - 2020 Adobe. All Rights Reserved