public abstract class ATokVisitor extends java.lang.Object implements ITokVisitor
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,ITokVisitorCmd> |
cmds
The dictionary mapping token id's (names) to associated commands.
|
private ITokVisitorCmd |
defaultCmd
The default command to use if there are no command associated with the given host id.
|
Constructor and Description |
---|
ATokVisitor()
Constructor that sets the default cmd to one that throws and IllegalArgumentException" for any unknown tokens.
|
ATokVisitor(ITokVisitorCmd defaultCmd)
Constructor that sets the default cmd to the given command.
|
Modifier and Type | Method and Description |
---|---|
void |
addCmd(java.lang.String id,
ITokVisitorCmd cmd)
Add a new cmd or replace an existing cmd associated with the given host id.
|
java.lang.Object |
caseAt(java.lang.String id,
Token host,
java.lang.Object... params)
Delegates to the ITokVisitorCmd associated with the given host id (name),
or if nothing is associated with the id, use the default cmd.
|
private ITokVisitorCmd defaultCmd
private java.util.Map<java.lang.String,ITokVisitorCmd> cmds
public ATokVisitor()
public ATokVisitor(ITokVisitorCmd defaultCmd)
defaultCmd
- the default cmd to use.public java.lang.Object caseAt(java.lang.String id, Token host, java.lang.Object... params)
caseAt
in interface ITokVisitor
id
- the name of the host Tokenhost
- the host token itself.params
- vararg list of input parameters that the processing might need.public void addCmd(java.lang.String id, ITokVisitorCmd cmd)
id
- the id of the host to associate with this visitor.cmd
- The command to associate with the given key value.