javatools.datatypes
Class IterableForIterator<T>

java.lang.Object
  extended by javatools.datatypes.IterableForIterator<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class IterableForIterator<T>
extends java.lang.Object
implements 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 allows to use an iterator in a for-each-loop.
Example:

   for(String s : new Scanner("Scan this string")) {
      // Compiletime error, because Scanner is an Iterator but not Iterable
   }

   for(String s : new IterableForIterator<String>(new Scanner("Scan this string"))) {
     // works fine
   }


Field Summary
 java.util.Iterator<T> iterator
           
 
Constructor Summary
IterableForIterator(java.util.Iterator<T> iterator)
           
 
Method Summary
 java.util.Iterator<T> iterator()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iterator

public java.util.Iterator<T> iterator
Constructor Detail

IterableForIterator

public IterableForIterator(java.util.Iterator<T> iterator)
Method Detail

iterator

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