|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.openai.util.fsm.Machine
The controlling Machine class for the Finite State Machine
Constructor Summary | |
Machine()
Constructs a new Machine object with no start state. |
|
Machine(State startState)
Constructs a new Machine object. |
Method Summary | |
void |
addMachineListener(MachineListener listener)
Adds a MachineListener to this Machine that we will deliver events to. |
State |
getCurrentState()
Returns the current state of this machine. |
State |
getStartState()
Returns a handle to the starting state for this machine. |
void |
input(boolean condition)
Convenience method to handle the boolean primitive as an input condition. |
void |
input(byte condition)
Convenience method to handle the byte primitive type as an input condition. |
void |
input(char condition)
Convience method to handle the char primitive type as an input condition. |
void |
input(double condition)
Convience method to handle the double primitive type as an input condition. |
void |
input(float condition)
Convience method to handle the float primitive type as an input condition. |
void |
input(int condition)
Convience method to handle the int primitive type as an input condition. |
void |
input(long condition)
Convience method to handle the long primitive type as an input condition. |
void |
input(java.lang.Object condition)
Takes input and passes it to the current State . |
void |
input(short condition)
Convience method to handle the Short primitive type as an input condition. |
void |
removeMachineListener(MachineListener listener)
Removes a MachineListener from this Machine. |
void |
reset()
Resets this machine so that its current State is the
start state. |
void |
reset(boolean asTransition,
boolean nullifyInput)
Resets this machine so that its current State is the
start state. |
protected void |
setCurrentState(State state)
Forcibly sets the current state of this machine. |
void |
setStartState(State state)
Sets the start state for this machine. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Machine()
public Machine(State startState)
startState
- The State
object to begin on. This must
be non-null
.Method Detail |
public final void addMachineListener(MachineListener listener)
listener
- The MachineListener to add.public final void removeMachineListener(MachineListener listener)
listener
- The MachineListener to remove.public final void setStartState(State state)
state
- The new start state for this machine.public final State getStartState()
protected final void setCurrentState(State state)
state
- The new current state.public final State getCurrentState()
public final void input(java.lang.Object condition) throws UnhandledConditionException
State
. If the
condition is met by one of the Condition
s of the
State
, then the new current State
will be that
returned by the input method of the present State
.
condition
- The input to pass to the current State
.
UnhandledConditionException
- If the current State
returns null
for its input method, then a condition
has arisen that is not handled.public final void input(boolean condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(byte condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(char condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(double condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(float condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(int condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(long condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void input(short condition) throws UnhandledConditionException
condition
- The value to input.
UnhandledConditionException
public final void reset()
State
is the
start state. No state transitions will be fired. This is the same
as calling reset(false, false)
.
public final void reset(boolean asTransition, boolean nullifyInput)
State
is the
start state. If asTransition
is true
then
the output of the current state (if it exists) will be input into
the start state and the start state will be the new current state.
If it is false
then the current state will simply be set
to be the start state.
asTransition
- If true
then the current state
and the start state will act as if there is
a transition between them.nullifyInput
- If true
then null will be fed into
the start state instead of the output of the
current state.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |