net.sf.jga.util

Class EnumerationIterator<T>

public class EnumerationIterator<T> extends Object implements Iterator<T>

Adapts an Enumeration to the Iterator interface.

Copyright © 2003 David A. Hall

Author: David A. Hall

Constructor Summary
EnumerationIterator(Enumeration<T> enumeration)
Builds an EnumerationIterator that adapts the given enumeration to the Iterator interface.
Method Summary
booleanhasNext()
Returns true if the base enumeration has elements remaining.
Tnext()
Returns the next element in the base enumeration.
voidremove()
throws UnsupportedOperationException: Enumerations do not support the removal of elements.

Constructor Detail

EnumerationIterator

public EnumerationIterator(Enumeration<T> enumeration)
Builds an EnumerationIterator that adapts the given enumeration to the Iterator interface.

Throws: IllegalArgumentException if the given enumeration is null.

Method Detail

hasNext

public boolean hasNext()
Returns true if the base enumeration has elements remaining.

Returns: true if the base enumeration has elements remaining.

next

public T next()
Returns the next element in the base enumeration.

Returns: the next element in the base enumeration.

Throws: NoSuchElementException if the base enumeration is at its end.

remove

public void remove()
throws UnsupportedOperationException: Enumerations do not support the removal of elements.

Throws: UnsupportedOperationException when called.