|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectextvisitor.AExtVisitor<R,I,P,H>
R - The type of the return valueI - The type of the index valueP - The type of the input parametersH - The type of the host, restricted to being a subclass of IExtVisitorHost<I, ? super H>public abstract class AExtVisitor<R,I,P,H extends IExtVisitorHost<I,? super H>>
Abstract implementation of IExtVisitor that adds an invariant implementation of
storing commands associated with each case in a dictionary indexed by the
case's associated index value.
When a particular case is called, the associated command is retrieved and
executed. The return value is the return value from the command.
If no associated command is found, then a default command is executed.
In general, command-based implementations of IExtVisitor will be concrete subclasses of this class.
Usage:
public class MyExtVisitor extends AExtVisitor<MyReturn, MyIndex, MyReturn, MyExtVisitorHost> {...}
| Field Summary | |
|---|---|
private java.util.Map<I,IExtVisitorCmd<R,I,P,H>> |
cmds
The dictionary used to store the commands |
private IExtVisitorCmd<R,I,P,H> |
defaultCmd
The default command to use if no command is associated with a case index value. |
private static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
AExtVisitor(IExtVisitorCmd<R,I,P,H> defaultCmd)
Constructor that takes a default command to use. |
|
AExtVisitor(R noOpResult)
A convenience constructor that takes a value that the default command will return. |
|
| Method Summary | ||
|---|---|---|
|
caseAt(I idx,
T host,
P... params)
Concrete implementation of the parameterized case method that takes the index value, retrieves an associated IExtVisitor command and executes the command with the given host and input parameters. |
|
IExtVisitorCmd<R,I,P,H> |
getCmd(I idx)
Retrieve the command associated with given index value. |
|
IExtVisitorCmd<R,I,P,H> |
getDefaultCmd()
Retrieve the current default command |
|
void |
setCmd(I idx,
IExtVisitorCmd<R,I,P,H> cmd)
Associates the given index value with the given command |
|
void |
setDefaultCmd(IExtVisitorCmd<R,I,P,H> defaultCmd)
Set the default command to a new value. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private java.util.Map<I,IExtVisitorCmd<R,I,P,H extends IExtVisitorHost<I,? super H>>> cmds
private IExtVisitorCmd<R,I,P,H extends IExtVisitorHost<I,? super H>> defaultCmd
| Constructor Detail |
|---|
public AExtVisitor(IExtVisitorCmd<R,I,P,H> defaultCmd)
defaultCmd - The default command to use.public AExtVisitor(R noOpResult)
noOpResult - The value for the default command to return.| Method Detail |
|---|
public void setCmd(I idx,
IExtVisitorCmd<R,I,P,H> cmd)
idx - The index value to use associate with the command.cmd - The command associated with the index valuepublic IExtVisitorCmd<R,I,P,H> getCmd(I idx)
idx - An index value
public IExtVisitorCmd<R,I,P,H> getDefaultCmd()
public void setDefaultCmd(IExtVisitorCmd<R,I,P,H> defaultCmd)
defaultCmd - The new default command
public <T extends IExtVisitorHost<I,? super H>> R caseAt(I idx,
T host,
P... params)
caseAt in interface IExtVisitor<R,I,P,H extends IExtVisitorHost<I,? super H>>T - The type of the host the is expected to call this method. T is restricted to be a subclass of IExtVisitorHost<I, ? super H>idx - The index value for the casehost - The visitor's host.params - Vararg input parameters for the case
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||