java.lang.Object
provided.tokenFW.ATokVisitor
- All Implemented Interfaces:
ITokVisitor
A visitor to an Token that implements ITokVisitor using a dictionary of commands.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String,ITokVisitorCmd>
The dictionary mapping token id's (names) to associated commands.private ITokVisitorCmd
The default command to use if there are no command associated with the given host id. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor 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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCmd(String id, ITokVisitorCmd cmd)
Add a new cmd or replace an existing cmd associated with the given host id.Delegates to the ITokVisitorCmd associated with the given host id (name), or if nothing is associated with the id, use the default cmd.
-
Field Details
-
defaultCmd
The default command to use if there are no command associated with the given host id. -
cmds
The dictionary mapping token id's (names) to associated commands. Implemented using a hast table.
-
-
Constructor Details
-
ATokVisitor
public ATokVisitor()Constructor that sets the default cmd to one that throws and IllegalArgumentException" for any unknown tokens. -
ATokVisitor
Constructor that sets the default cmd to the given command.- Parameters:
defaultCmd
- the default cmd to use.
-
-
Method Details
-
caseAt
Delegates to the ITokVisitorCmd associated with the given host id (name), or if nothing is associated with the id, use the default cmd.- Specified by:
caseAt
in interfaceITokVisitor
- Parameters:
id
- the name of the host Tokenhost
- the host token itself.params
- vararg list of input parameters that the processing might need.- Returns:
- the result of the delegation to the associated cmd.
-
addCmd
Add a new cmd or replace an existing cmd associated with the given host id.- Parameters:
id
- the id of the host to associate with this visitor.cmd
- The command to associate with the given key value.
-