public class CatalogBase extends 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.
Modifier and Type | Field and Description |
---|---|
protected Map |
commands
The map of named
Command s, keyed by name. |
CATALOG_KEY
Constructor and Description |
---|
CatalogBase()
Create an empty catalog.
|
CatalogBase(Map commands)
Create a catalog whose commands are those specified in the given
Map . |
Modifier and Type | Method and Description |
---|---|
void |
addCommand(String name,
Command command)
|
Command |
getCommand(String name)
Return the
Command associated with the
specified name, if any; otherwise, return null . |
Iterator |
getNames()
Return an
Iterator over the set of named commands
known to this Catalog . |
String |
toString()
Converts this Catalog to a String.
|
public CatalogBase()
public CatalogBase(Map commands)
Create a catalog whose commands are those specified in the given Map
.
All Map keys should be String
and all values should be Command
.
commands
- Map of Commands.public void addCommand(String name, Command command)
Add a new name and associated Command
to the set of named commands known to this Catalog
,
replacing any previous command for that name.
addCommand
in interface Catalog
name
- Name of the new commandcommand
- Command
to be returned
for later lookups on this namepublic Command getCommand(String name)
Return the Command
associated with the
specified name, if any; otherwise, return null
.
getCommand
in interface Catalog
name
- Name for which a Command
should be retrievedpublic Iterator getNames()
Return an Iterator
over the set of named commands
known to this Catalog
. If there are no known commands,
an empty Iterator is returned.
Copyright © 2003–2021 The Apache Software Foundation. All rights reserved.