org.apache.commons.collections.iterators

Class IteratorEnumeration

public class IteratorEnumeration extends Object implements Enumeration

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

Since: Commons Collections 1.0

Version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $

Author: James Strachan

Constructor Summary
IteratorEnumeration()
Constructs a new IteratorEnumeration that will not function until setIterator is invoked.
IteratorEnumeration(Iterator iterator)
Constructs a new IteratorEnumeration that will use the given iterator.
Method Summary
IteratorgetIterator()
Returns the underlying iterator.
booleanhasMoreElements()
Returns true if the underlying iterator has more elements.
ObjectnextElement()
Returns the next element from the underlying iterator.
voidsetIterator(Iterator iterator)
Sets the underlying iterator.

Constructor Detail

IteratorEnumeration

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

IteratorEnumeration

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

Parameters: iterator the iterator to use

Method Detail

getIterator

public Iterator getIterator()
Returns the underlying iterator.

Returns: the underlying iterator

hasMoreElements

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

Returns: true if the underlying iterator has more elements

nextElement

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

Returns: the next element from the underlying iterator.

Throws: java.util.NoSuchElementException if the underlying iterator has no more elements

setIterator

public void setIterator(Iterator iterator)
Sets the underlying iterator.

Parameters: iterator the new underlying iterator

Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.