net.sf.jga.util
Class EnumerationIterator<T>

java.lang.Object
  extended by net.sf.jga.util.EnumerationIterator<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Iterator<T>

public class EnumerationIterator<T>
extends java.lang.Object
implements java.util.Iterator<T>, java.lang.Iterable<T>

Adapts an Enumeration to the Iterator and Iterable interfaces.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall

Constructor Summary
EnumerationIterator(java.util.Enumeration<T> enumeration)
          Builds an EnumerationIterator that adapts the given enumeration to the Iterator and Iterable interfaces.
 
Method Summary
 boolean hasNext()
          Returns true if the base enumeration has elements remaining.
 java.util.Iterator<T> iterator()
           
 T next()
          Returns the next element in the base enumeration.
 void remove()
          throws UnsupportedOperationException: Enumerations do not support the removal of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumerationIterator

public EnumerationIterator(java.util.Enumeration<T> enumeration)
Builds an EnumerationIterator that adapts the given enumeration to the Iterator and Iterable interfaces.

Throws:
java.lang.IllegalArgumentException - if the given enumeration is null.
Method Detail

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

hasNext

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

Specified by:
hasNext in interface java.util.Iterator<T>
Returns:
true if the base enumeration has elements remaining.

next

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

Specified by:
next in interface java.util.Iterator<T>
Returns:
the next element in the base enumeration.
Throws:
java.util.NoSuchElementException - if the base enumeration is at its end.

remove

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

Specified by:
remove in interface java.util.Iterator<T>
Throws:
java.lang.UnsupportedOperationException - when called.


Copyright © 2002-2006 David A. Hall. All Rights Reserved.