Package org.apache.commons.chain.impl
Class CatalogBase
- java.lang.Object
-
- 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: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
- Author:
- Craig R. McClanahan, Matthew J. Sgarlata
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.MapcommandsThe map of namedCommands, keyed by name.-
Fields inherited from interface org.apache.commons.chain.Catalog
CATALOG_KEY
-
-
Constructor Summary
Constructors Constructor Description CatalogBase()Create an empty catalog.CatalogBase(java.util.Map commands)Create a catalog whose commands are those specified in the givenMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(java.lang.String name, Command command)CommandgetCommand(java.lang.String name)Return theCommandassociated with the specified name, if any; otherwise, returnnull.java.util.IteratorgetNames()Return anIteratorover the set of named commands known to thisCatalog.java.lang.StringtoString()Converts this Catalog to a String.
-
-
-
Field Detail
-
commands
protected java.util.Map commands
The map of named
Commands, keyed by name.
-
-
Constructor Detail
-
CatalogBase
public CatalogBase()
Create an empty catalog.
-
CatalogBase
public CatalogBase(java.util.Map commands)
Create a catalog whose commands are those specified in the given
Map. All Map keys should beStringand all values should beCommand.- Parameters:
commands- Map of Commands.- Since:
- Chain 1.1
-
-
Method Detail
-
addCommand
public void addCommand(java.lang.String name, Command command)Add a new name and associated
Commandto the set of named commands known to thisCatalog, replacing any previous command for that name.- Specified by:
addCommandin interfaceCatalog- Parameters:
name- Name of the new commandcommand-Commandto be returned for later lookups on this name
-
getCommand
public Command getCommand(java.lang.String name)
Return the
Commandassociated with the specified name, if any; otherwise, returnnull.- Specified by:
getCommandin interfaceCatalog- Parameters:
name- Name for which aCommandshould be retrieved- Returns:
- The Command associated with the specified name.
-
getNames
public java.util.Iterator getNames()
Return an
Iteratorover the set of named commands known to thisCatalog. If there are no known commands, an empty Iterator is returned.
-
toString
public java.lang.String toString()
Converts this Catalog to a String. Useful for debugging purposes.- Overrides:
toStringin classjava.lang.Object- Returns:
- a representation of this catalog as a String
-
-