org.vivoweb.harvester.util
Class IterableAdaptor<T>

java.lang.Object
  extended by org.vivoweb.harvester.util.IterableAdaptor<T>
Type Parameters:
T - type
All Implemented Interfaces:
java.lang.Iterable<T>

public class IterableAdaptor<T>
extends java.lang.Object
implements java.lang.Iterable<T>

Adapts Enumerations and Iterators to be Iterable


Constructor Summary
IterableAdaptor(java.util.Enumeration<T> en)
          sometimes you have an Enumeration and you want an Iterable
IterableAdaptor(java.util.Iterator<T> it)
          sometimes you have an Iterator but you want to use a for
 
Method Summary
static
<T> java.lang.Iterable<T>
adapt(java.util.Enumeration<T> enin)
          sometimes you have an Enumeration and you want an Iterable
static
<T> java.lang.Iterable<T>
adapt(java.util.Iterator<T> itin)
          sometimes you have an Iterator but you want to use a for
protected  java.util.Enumeration<T> getEn()
          Accessor for en
 java.util.Iterator<T> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterableAdaptor

public IterableAdaptor(java.util.Enumeration<T> en)
sometimes you have an Enumeration and you want an Iterable

Parameters:
en - enumeration to adapt

IterableAdaptor

public IterableAdaptor(java.util.Iterator<T> it)
sometimes you have an Iterator but you want to use a for

Parameters:
it - iterator to adapt
Method Detail

getEn

protected final java.util.Enumeration<T> getEn()
Accessor for en

Returns:
en

iterator

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

adapt

public static <T> java.lang.Iterable<T> adapt(java.util.Enumeration<T> enin)
sometimes you have an Enumeration and you want an Iterable

Type Parameters:
T - type
Parameters:
enin - enumeration to adapt
Returns:
an iterable adapter for the enumeration

adapt

public static <T> java.lang.Iterable<T> adapt(java.util.Iterator<T> itin)
sometimes you have an Iterator but you want to use a for

Type Parameters:
T - type
Parameters:
itin - iterator to adapt
Returns:
an iterable adapter for the iterator