javatools.datatypes
Class IteratorForEnumeration<T>

java.lang.Object
  extended by javatools.datatypes.IteratorForEnumeration<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Iterator<T>

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

This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class provides a simple converter from Enumerations to Iterators. It accepts untyped Enumerations, but yields always typed Iterators. It can also convert an untyped Enumeration to a list.
Example:

    for(String s : new IteratorForEnumeration<String>(someUntypedEnumeration)) {
      System.out.println(s);
    }
  


Field Summary
 java.util.Enumeration<T> enumerator
          Holds the enumeration object
 
Constructor Summary
IteratorForEnumeration(java.util.Enumeration enumerator)
           
 
Method Summary
 java.util.List<T> asList()
          Returns the rest of the enumeration as a list
 boolean hasNext()
           
 java.util.Iterator<T> iterator()
           
 T next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enumerator

public java.util.Enumeration<T> enumerator
Holds the enumeration object

Constructor Detail

IteratorForEnumeration

public IteratorForEnumeration(java.util.Enumeration enumerator)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T>

next

public T next()
Specified by:
next in interface java.util.Iterator<T>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<T>

iterator

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

asList

public java.util.List<T> asList()
Returns the rest of the enumeration as a list