org.apache.commons.collections.iterators
Class IteratorEnumeration<E>

java.lang.Object
  extended by org.apache.commons.collections.iterators.IteratorEnumeration<E>
All Implemented Interfaces:
Enumeration<E>

public class IteratorEnumeration<E>
extends Object
implements Enumeration<E>

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

Since:
Commons Collections 1.0
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:55 $
Author:
Matt Hall, John Watkinson, James Strachan

Constructor Summary
IteratorEnumeration()
          Constructs a new IteratorEnumeration that will not function until setIterator is invoked.
IteratorEnumeration(Iterator<E> iterator)
          Constructs a new IteratorEnumeration that will use the given iterator.
 
Method Summary
 Iterator<E> getIterator()
          Returns the underlying iterator.
 boolean hasMoreElements()
          Returns true if the underlying iterator has more elements.
 E nextElement()
          Returns the next element from the underlying iterator.
 void setIterator(Iterator<E> iterator)
          Sets the underlying iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorEnumeration

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


IteratorEnumeration

public IteratorEnumeration(Iterator<E> iterator)
Constructs a new IteratorEnumeration that will use the given iterator.

Parameters:
iterator - the iterator to use
Method Detail

hasMoreElements

public boolean hasMoreElements()
Returns true if the underlying iterator has more elements.

Specified by:
hasMoreElements in interface Enumeration<E>
Returns:
true if the underlying iterator has more elements

nextElement

public E nextElement()
Returns the next element from the underlying iterator.

Specified by:
nextElement in interface Enumeration<E>
Returns:
the next element from the underlying iterator.
Throws:
NoSuchElementException - if the underlying iterator has no more elements

getIterator

public Iterator<E> getIterator()
Returns the underlying iterator.

Returns:
the underlying iterator

setIterator

public void setIterator(Iterator<E> iterator)
Sets the underlying iterator.

Parameters:
iterator - the new underlying iterator


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.