com.jamonapi.utils
Class CommandIterator

java.lang.Object
  extended by com.jamonapi.utils.CommandIterator

public class CommandIterator
extends java.lang.Object

Used with the Command interface to implement the Gang of 4 Command pattern to execute some logic for every entry of various iterators. This class allows a Command object to be passed to various iterators. This capability is also similar to function pointers in C.


Method Summary
static void iterate(java.util.Collection collection, Command command)
          Iterate through a Collection passing the Command object each element in the collection.
static void iterate(java.util.Enumeration enumer, Command command)
          Iterate through an Enumeration passing the Command object each element in the Collection
static void iterate(java.util.Iterator iterator, Command command)
          Iterate passing each Command each Object that is being iterated
static void iterate(java.util.Map map, Command command)
          Iterate through a Map passing Command object a Map.Entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

iterate

public static void iterate(java.util.Map map,
                           Command command)
                    throws java.lang.Exception
Iterate through a Map passing Command object a Map.Entry.

Command code would look something like:

entry = (Map.Entry) object;
   entry.getKey(), entry.getValue();
 

Throws:
java.lang.Exception

iterate

public static void iterate(java.util.Collection collection,
                           Command command)
                    throws java.lang.Exception
Iterate through a Collection passing the Command object each element in the collection.

Throws:
java.lang.Exception

iterate

public static void iterate(java.util.Enumeration enumer,
                           Command command)
                    throws java.lang.Exception
Iterate through an Enumeration passing the Command object each element in the Collection

Throws:
java.lang.Exception

iterate

public static void iterate(java.util.Iterator iterator,
                           Command command)
                    throws java.lang.Exception
Iterate passing each Command each Object that is being iterated

Throws:
java.lang.Exception