Top Description Fields Constructors Methods
org.apache.commons.collections4.iterators

public Class EnumerationIterator<E>

extends Object
implements Iterator<E>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Imports
java.util.Collection, .Enumeration, .Iterator

Adapter to make Enumeration instances appear to be Iterator instances.
Since
1.0

Field Summary

Modifier and TypeField and Description
private final Collection<? super E>
collection

The collection to remove elements from

private Enumeration<? extends E>
enumeration

The enumeration being converted

private E
last

The last object retrieved

Constructor Summary

AccessConstructor and Description
public
EnumerationIterator()

Constructs a new EnumerationIterator that will not function until setEnumeration(Enumeration) is called.

public
EnumerationIterator(final Enumeration<? extends E>
the enumeration to use
enumeration
)

Constructs a new EnumerationIterator that provides an iterator view of the given enumeration.

public
EnumerationIterator(final Enumeration<? extends E>
the enumeration to use
enumeration
,
final Collection<? super E>
the collection to remove elements from
collection
)

Constructs a new EnumerationIterator that will remove elements from the specified collection.

Method Summary

Modifier and TypeMethod and Description
public Enumeration<? extends E>

Returns:

the underlying enumeration
getEnumeration
()

Returns the underlying enumeration.

public boolean

Returns:

true if the underlying enumeration has more elements
hasNext
()

Implements java.util.Iterator.hasNext.

Returns true if the underlying enumeration has more elements.
public E

Returns:

the next object from the enumeration
next
()

Implements java.util.Iterator.next.

Returns the next object from the enumeration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes the last retrieved element if a collection is attached.
public void
setEnumeration(final Enumeration<? extends E>
the new underlying enumeration
enumeration
)

Sets the underlying enumeration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectionback to summary
private final Collection<? super E> collection

The collection to remove elements from

enumerationback to summary
private Enumeration<? extends E> enumeration

The enumeration being converted

lastback to summary
private E last

The last object retrieved

Constructor Detail

EnumerationIteratorback to summary
public EnumerationIterator()

Constructs a new EnumerationIterator that will not function until setEnumeration(Enumeration) is called.

EnumerationIteratorback to summary
public EnumerationIterator(final Enumeration<? extends E> enumeration)

Constructs a new EnumerationIterator that provides an iterator view of the given enumeration.

Parameters
enumeration:Enumeration<? extends E>

the enumeration to use

EnumerationIteratorback to summary
public EnumerationIterator(final Enumeration<? extends E> enumeration, final Collection<? super E> collection)

Constructs a new EnumerationIterator that will remove elements from the specified collection.

Parameters
enumeration:Enumeration<? extends E>

the enumeration to use

collection:Collection<? super E>

the collection to remove elements from

Method Detail

getEnumerationback to summary
public Enumeration<? extends E> getEnumeration()

Returns the underlying enumeration.

Returns:Enumeration<? extends E>

the underlying enumeration

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the underlying enumeration has more elements.

Returns:boolean

true if the underlying enumeration has more elements

Annotations
@Override
Exceptions
NullPointerException:
if the underlying enumeration is null
nextback to summary
public E next()

Implements java.util.Iterator.next.

Returns the next object from the enumeration.

Returns:E

the next object from the enumeration

Annotations
@Override
Exceptions
NullPointerException:
if the enumeration is null
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Removes the last retrieved element if a collection is attached.

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.

Annotations
@Override
Exceptions
IllegalStateException:
next() not called.
UnsupportedOperationException:
if no associated collection
setEnumerationback to summary
public void setEnumeration(final Enumeration<? extends E> enumeration)

Sets the underlying enumeration.

Parameters
enumeration:Enumeration<? extends E>

the new underlying enumeration