All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface java.util.Iterator

public interface Iterator
An Iterator is designed to perform an action on every element of a collection. By using classes that implement this interface, client classes don't have to code loops, they only have to provide the action that is to be performed on each element. The actual iterating (initializing and incrementing the loop counter and checking if the loop terminates) is performed by classes that implement this interface. These iterator classes have to know about the structure of the collection that must be iterated over. The client classes provide the action to be done by overriding the action() method of an iterator class that can handle the specific collection that must be iterated over.

Version:
$Revision: 1.3 $

Method Index

 o action(Object)
The method that is invoked by doAll on every element of the collection, one by one.
 o doAll(Object)
This is the entry point of the iterator that can be called by a client class.
 o postAction()
The code that is executed by doAll() after the iteration has ended.
 o preAction()
The code that is executed by doAll() before the actual iteration.

Methods

 o doAll
 public abstract void doAll(Object store)
This is the entry point of the iterator that can be called by a client class. The client passes the collection to this method, and the iterator invokes action() on every element of the collection. Before the iteration starts, preAction() is executed, and afterwards postAction() is executed.

Parameters:
store - The collection of objects to iterate over.
See Also:
action, preAction, postAction
 o preAction
 public abstract void preAction()
The code that is executed by doAll() before the actual iteration. It can be used (overridden) to set up internal variables of the iterator that might be used by action() to construct a result during the iteration or keep track of the status of the iteration.

See Also:
doAll
 o action
 public abstract void action(Object item)
The method that is invoked by doAll on every element of the collection, one by one. It must be overridden by an iterator class to provide a useful action.

Parameters:
item - an object of the collection.
See Also:
doAll
 o postAction
 public abstract void postAction()
The code that is executed by doAll() after the iteration has ended. It can be used (overridden) to clean up things used during the iteration if necessary or possibly finalize the construction of a result or final status of the iteration.

See Also:
doAll

All Packages  Class Hierarchy  This Package  Previous  Next  Index