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

public Class IteratorEnumeration<E>

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

Adapter to make an Iterator instance appear to be an Enumeration instance.
Since
1.0

Field Summary

Modifier and TypeField and Description
private Iterator<? extends E>
iterator

The iterator being decorated.

Constructor Summary

AccessConstructor and Description
public
IteratorEnumeration()

Constructs a new IteratorEnumeration that will not function until setIterator is invoked.

public
IteratorEnumeration(final Iterator<? extends E>
the iterator to use
iterator
)

Constructs a new IteratorEnumeration that will use the given iterator.

Method Summary

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

Returns:

the underlying iterator
getIterator
()

Returns the underlying iterator.

public boolean

Returns:

true if the underlying iterator has more elements
hasMoreElements
()

Implements java.util.Enumeration.hasMoreElements.

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

Returns:

the next element from the underlying iterator.
nextElement
()

Implements java.util.Enumeration.nextElement.

Returns the next element from the underlying iterator.
public void
setIterator(final Iterator<? extends E>
the new underlying iterator
iterator
)

Sets the underlying iterator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iteratorback to summary
private Iterator<? extends E> iterator

The iterator being decorated.

Constructor Detail

IteratorEnumerationback to summary
public IteratorEnumeration()

Constructs a new IteratorEnumeration that will not function until setIterator is invoked.

IteratorEnumerationback to summary
public IteratorEnumeration(final Iterator<? extends E> iterator)

Constructs a new IteratorEnumeration that will use the given iterator.

Parameters
iterator:Iterator<? extends E>

the iterator to use

Method Detail

getIteratorback to summary
public Iterator<? extends E> getIterator()

Returns the underlying iterator.

Returns:Iterator<? extends E>

the underlying iterator

hasMoreElementsback to summary
public boolean hasMoreElements()

Implements java.util.Enumeration.hasMoreElements.

Returns true if the underlying iterator has more elements.

Returns:boolean

true if the underlying iterator has more elements

Annotations
@Override
nextElementback to summary
public E nextElement()

Implements java.util.Enumeration.nextElement.

Returns the next element from the underlying iterator.

Returns:E

the next element from the underlying iterator.

Annotations
@Override
Exceptions
NoSuchElementException:
if the underlying iterator has no more elements
setIteratorback to summary
public void setIterator(final Iterator<? extends E> iterator)

Sets the underlying iterator.

Parameters
iterator:Iterator<? extends E>

the new underlying iterator