com.bristle.javalib.util
Class IterUtil

java.lang.Object
  extended by com.bristle.javalib.util.IterUtil

public class IterUtil
extends Object

This class contains utility routines for creating and manipulating Java Iterators.

Usage:
   - The typical scenario for using this class is:
       Map map = IterUtil.toIterator(Enumeration enumeration);

   - See the source code of the inner Tester class for more examples.
  
Assumptions:
Effects:
       - None.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
Revision History:
   $Log$


Nested Class Summary
static class IterUtil.Tester
          Each class contains a Tester inner class with a main() for easier unit testing.
 
Constructor Summary
IterUtil()
           
 
Method Summary
static String enumerationToString(Enumeration enumeration)
          Return a String version of the Enumeration.
static String iteratorToString(Iterator iter)
          Return a String version of the Iterator.
static Enumeration toEnumeration(Iterator iter)
          Create an Enumeration from the specified Iterator, or null if the Iterator is null.
static Iterator toIterator(Enumeration enumeration)
          Create an Iterator from the specified Enumeration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterUtil

public IterUtil()
Method Detail

iteratorToString

public static String iteratorToString(Iterator iter)
Return a String version of the Iterator. Note: This leaves the Iterator with hasNext() == false.

Parameters:
iter - Iterator to convert to a String.
Returns:
String version of the Iterator.

enumerationToString

public static String enumerationToString(Enumeration enumeration)
Return a String version of the Enumeration. Note: This leaves the Enumeration with hasMoreElements() == false.

Parameters:
enumeration - Enumeration to convert to a String.
Returns:
String version of the Enumeration.

toIterator

public static Iterator toIterator(Enumeration enumeration)
Create an Iterator from the specified Enumeration. Note: This leaves the Enumeration with hasMoreElements() == false.

Parameters:
enumeration - Enumeration of Objects to put in the Iterator.
Returns:
The new Iterator.

toEnumeration

public static Enumeration toEnumeration(Iterator iter)
Create an Enumeration from the specified Iterator, or null if the Iterator is null. Note: This leaves the Iterator with hasNext() == false.

Parameters:
iter - Iterator to copy to a new List.
Returns:
The new Enumeration