com.jamonapi.utils
Class CommandIterator

java.lang.Object
  |
  +--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 enum, 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.
static void iterate(java.sql.ResultSet resultSet, Command command)
          Iterate through a ResultSet passing in a Command object.
static void main(java.lang.String[] argv)
          Test code for this class
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

iterate

public static void iterate(java.sql.ResultSet resultSet,
                           Command command)
                    throws java.lang.Exception
Iterate through a ResultSet passing in a Command object. The command object will be passed an Object[] representing 1 row of the result set

java.lang.Exception

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();

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.

java.lang.Exception

iterate

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

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

java.lang.Exception

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Test code for this class

java.lang.Exception