Class EnumerationIterator<E>
- java.lang.Object
 - 
- org.apache.commons.collections4.iterators.EnumerationIterator<E>
 
 
- 
- All Implemented Interfaces:
 java.util.Iterator<E>
public class EnumerationIterator<E> extends java.lang.Object implements java.util.Iterator<E>Adapter to makeEnumerationinstances appear to beIteratorinstances.- Since:
 - 1.0
 
 
- 
- 
Constructor Summary
Constructors Constructor Description EnumerationIterator()Constructs a newEnumerationIteratorthat will not function untilsetEnumeration(Enumeration)is called.EnumerationIterator(java.util.Enumeration<? extends E> enumeration)Constructs a newEnumerationIteratorthat provides an iterator view of the given enumeration.EnumerationIterator(java.util.Enumeration<? extends E> enumeration, java.util.Collection<? super E> collection)Constructs a newEnumerationIteratorthat will remove elements from the specified collection. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Enumeration<? extends E>getEnumeration()Returns the underlying enumeration.booleanhasNext()Returns true if the underlying enumeration has more elements.Enext()Returns the next object from the enumeration.voidremove()Removes the last retrieved element if a collection is attached.voidsetEnumeration(java.util.Enumeration<? extends E> enumeration)Sets the underlying enumeration. 
 - 
 
- 
- 
Constructor Detail
- 
EnumerationIterator
public EnumerationIterator()
Constructs a newEnumerationIteratorthat will not function untilsetEnumeration(Enumeration)is called. 
- 
EnumerationIterator
public EnumerationIterator(java.util.Enumeration<? extends E> enumeration)
Constructs a newEnumerationIteratorthat provides an iterator view of the given enumeration.- Parameters:
 enumeration- the enumeration to use
 
- 
EnumerationIterator
public EnumerationIterator(java.util.Enumeration<? extends E> enumeration, java.util.Collection<? super E> collection)
Constructs a newEnumerationIteratorthat will remove elements from the specified collection.- Parameters:
 enumeration- the enumeration to usecollection- the collection to remove elements from
 
 - 
 
- 
Method Detail
- 
hasNext
public boolean hasNext()
Returns true if the underlying enumeration has more elements.- Specified by:
 hasNextin interfacejava.util.Iterator<E>- Returns:
 - true if the underlying enumeration has more elements
 - Throws:
 java.lang.NullPointerException- if the underlying enumeration is null
 
- 
next
public E next()
Returns the next object from the enumeration.- Specified by:
 nextin interfacejava.util.Iterator<E>- Returns:
 - the next object from the enumeration
 - Throws:
 java.lang.NullPointerException- if the enumeration is null
 
- 
remove
public void remove()
Removes the last retrieved element if a collection is attached.Functions if an associated
Collectionis known. If so, the first occurrence of the last returned object from this iterator will be removed from the collection.- Specified by:
 removein interfacejava.util.Iterator<E>- Throws:
 java.lang.IllegalStateException-next()not called.java.lang.UnsupportedOperationException- if no associated collection
 
- 
getEnumeration
public java.util.Enumeration<? extends E> getEnumeration()
Returns the underlying enumeration.- Returns:
 - the underlying enumeration
 
 
- 
setEnumeration
public void setEnumeration(java.util.Enumeration<? extends E> enumeration)
Sets the underlying enumeration.- Parameters:
 enumeration- the new underlying enumeration
 
 - 
 
 -