/** Iterate passing each Command each Object that is being iterated **/ public static void iterate(Iterator iterator, Command command)throws Exception { while (iterator.hasNext()) { command.execute(iterator.next()); } }
*/ /** Iterate through a Map passing Command object a Map.Entry. * Command code would look something like: * entry = (Map.Entry) object; * entry.getKey(), entry.getValue(); **/ public static void iterate(Map map, Command command)throws Exception { iterate(map.entrySet().iterator() , command); } /** Iterate through a Collection passing the Command object each element in the collection. **/ public static void iterate(Collection collection, Command command)throws Exception { iterate(collection.iterator() , command); } /** Iterate through an Enumeration passing the Command object each element in the Collection **/ public static void iterate(Enumeration enumer, Command command)throws Exception { iterate(new EnumIterator(enumer) , command); } /** Iterate passing each Command each Object that is being iterated **/ public static void iterate(Iterator iterator, Command command)throws Exception { while (iterator.hasNext()) { command.execute(iterator.next()); } } /** Test code for this class **/