org.apache.commons.chain.impl
Class CatalogBase

java.lang.Object
  extended by org.apache.commons.chain.impl.CatalogBase
All Implemented Interfaces:
Catalog

public class CatalogBase
extends java.lang.Object
implements Catalog

Simple in-memory implementation of Catalog. This class can also be used as the basis for more advanced implementations.

This implementation is thread-safe.

Version:
$Revision: 1.12 $ $Date: 2004/11/30 05:52:23 $
Author:
Craig R. McClanahan, Matthew J. Sgarlata

Field Summary
protected  java.util.Map commands
          The map of named Commands, keyed by name.
 
Fields inherited from interface org.apache.commons.chain.Catalog
CATALOG_KEY
 
Constructor Summary
CatalogBase()
           
 
Method Summary
 void addCommand(java.lang.String name, Command command)
          Add a new name and associated Command or Chain to the set of named commands known to this Catalog, replacing any previous command for that name.
 Command getCommand(java.lang.String name)
          Return the Command or Chain associated with the specified name, if any; otherwise, return null.
 java.util.Iterator getNames()
          Return an Iterator over the set of named commands known to this Catalog.
 java.lang.String toString()
          Converts this Catalog to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

commands

protected java.util.Map commands

The map of named Commands, keyed by name.

Constructor Detail

CatalogBase

public CatalogBase()
Method Detail

addCommand

public void addCommand(java.lang.String name,
                       Command command)
Description copied from interface: Catalog

Add a new name and associated Command or Chain to the set of named commands known to this Catalog, replacing any previous command for that name.

Specified by:
addCommand in interface Catalog
Parameters:
name - Name of the new command
command - Command or Chain to be returned for later lookups on this name

getCommand

public Command getCommand(java.lang.String name)
Description copied from interface: Catalog

Return the Command or Chain associated with the specified name, if any; otherwise, return null.

Specified by:
getCommand in interface Catalog
Parameters:
name - Name for which a Command or Chain should be retrieved

getNames

public java.util.Iterator getNames()
Description copied from interface: Catalog

Return an Iterator over the set of named commands known to this Catalog. If there are no known commands, an empty Iterator is returned.

Specified by:
getNames in interface Catalog

toString

public java.lang.String toString()
Converts this Catalog to a String. Useful for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
a representation of this catalog as a String