Package org.glassfish.pfl.basic.fsm
Class Runner
- java.lang.Object
-
- org.glassfish.pfl.basic.fsm.Runner
-
public class Runner extends java.lang.Object
This is the main class that represents an instance of a state machine using a state engine. It may be used as a base class, in which case the guards and actions have access to the derived class.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doIt(Input in)
Perform the transition for the given input in the current state.boolean
done()
Return true if the stack is empty, which means that the runner is finished.FSM
peek()
Return the top fsm on the stack.FSM
pop()
void
push(FSM fsm)
Push a new fsm onto the stack.
-
-
-
Field Detail
-
debug
private boolean debug
-
current
private FSM current
-
-
Method Detail
-
peek
public FSM peek()
Return the top fsm on the stack.
-
push
public void push(FSM fsm)
Push a new fsm onto the stack.
-
pop
public FSM pop()
-
done
public boolean done()
Return true if the stack is empty, which means that the runner is finished.
-
doIt
public void doIt(Input in)
Perform the transition for the given input in the current state. This proceeds as follows:Let S be the current state of the FSM. If there are guarded actions for S with input in, evaluate their guards successively until all have been evaluted, or one returns a non-DISABLED Result.
- If a DEFERED result is returned, retry the input
- If a ENABLED result is returned, the action for the guarded action is the current action
- Otherwise there is no enabled action. If S has a default action and next state, use them; otherwise use the state engine default action (the next state is always the current state).
- If the next state is not the current state, execute the current state postAction method.
- Execute the action.
- If the next state is not the current state, execute the next state preAction method.
- Set the current state to the next state.
-
-