Package org.apache.commons.chain.impl
Class CatalogBase
java.lang.Object
org.apache.commons.chain.impl.CatalogBase
- All Implemented Interfaces:
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
FieldsFields inherited from interface org.apache.commons.chain.Catalog
CATALOG_KEY
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty catalog.CatalogBase
(Map commands) Create a catalog whose commands are those specified in the givenMap
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommand
(String name, Command command) getCommand
(String name) Return theCommand
associated with the specified name, if any; otherwise, returnnull
.getNames()
Return anIterator
over the set of named commands known to thisCatalog
.toString()
Converts this Catalog to a String.
-
Field Details
-
commands
The map of named
Command
s, keyed by name.
-
-
Constructor Details
-
CatalogBase
public CatalogBase()Create an empty catalog. -
CatalogBase
Create a catalog whose commands are those specified in the given
Map
. All Map keys should beString
and all values should beCommand
.- Parameters:
commands
- Map of Commands.- Since:
- Chain 1.1
-
-
Method Details
-
addCommand
Add a new name and associated
Command
to the set of named commands known to thisCatalog
, replacing any previous command for that name.- Specified by:
addCommand
in interfaceCatalog
- Parameters:
name
- Name of the new commandcommand
-Command
to be returned for later lookups on this name
-
getCommand
Return the
Command
associated with the specified name, if any; otherwise, returnnull
.- Specified by:
getCommand
in interfaceCatalog
- Parameters:
name
- Name for which aCommand
should be retrieved- Returns:
- The Command associated with the specified name.
-
getNames
Return an
Iterator
over the set of named commands known to thisCatalog
. If there are no known commands, an empty Iterator is returned. -
toString
Converts this Catalog to a String. Useful for debugging purposes.
-