|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprovided.music.APhraseVisitor
public abstract class APhraseVisitor
Command-based implementation of IPhraseVisitor that uses IPhraseVisitorCmds stored in a hash table.
Field Summary | |
---|---|
private java.util.Map<java.lang.String,IPhraseVisitorCmd> |
cmds
The dictionary of commands, implemented using a hash table. |
private IPhraseVisitorCmd |
defaultCmd
The default command to use when caseAt is called with an ID that is not in the hashtable as a key. |
Constructor Summary | |
---|---|
APhraseVisitor()
Constructor that installs a default cmd that throws an IllegalArgumentException on any unknown host. |
|
APhraseVisitor(IPhraseVisitorCmd defaultCmd)
Constructor that sets the default cmd to the supplied cmd. |
Method Summary | |
---|---|
void |
addCmd(java.lang.String id,
IPhraseVisitorCmd cmd)
Add the given command to the dictionary, associated with the given id value. |
java.lang.Object |
caseAt(java.lang.String id,
IPhrase host,
java.lang.Object... params)
Runs the command associated with the given id, passing along the given host and vararg parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private IPhraseVisitorCmd defaultCmd
private java.util.Map<java.lang.String,IPhraseVisitorCmd> cmds
Constructor Detail |
---|
public APhraseVisitor()
public APhraseVisitor(IPhraseVisitorCmd defaultCmd)
defaultCmd
- the default cmd to use.Method Detail |
---|
public java.lang.Object caseAt(java.lang.String id, IPhrase host, java.lang.Object... params)
caseAt
in interface IPhraseVisitor
id
- The ID value that identifies the hosthost
- The host IPhrase objectparams
- vararg list of parameters that might be used. Can be called with no input params.
public void addCmd(java.lang.String id, IPhraseVisitorCmd cmd)
id
- The id of the host that will use this commandcmd
- The command that will be run when the host calls for it.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |