Top Description Fields Constructors Methods
org.glassfish.pfl.basic.fsm

public Class Runner

extends Object
Class Inheritance

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.
Author
Ken Cavanaugh

Field Summary

Modifier and TypeField and Description
private FSM
private boolean

Constructor Summary

AccessConstructor and Description
public
Runner(FSM fsm)

Create a new Runner with fsm on top of the stack.

public
Runner(FSM fsm, boolean debug)

Method Summary

Modifier and TypeMethod and Description
public void
doIt(Input in)

Perform the transition for the given input in the current state.

public boolean
done()

Return true if the stack is empty, which means that the runner is finished.

public FSM
peek()

Return the top fsm on the stack.

public FSM
pop()

public void
push(FSM fsm)

Push a new fsm onto the stack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private FSM current
debugback to summary
private boolean debug

Constructor Detail

Runnerback to summary
public Runner(FSM fsm)

Create a new Runner with fsm on top of the stack.

Runnerback to summary
public Runner(FSM fsm, boolean debug)

Method Detail

doItback to summary
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.

  1. If a DEFERED result is returned, retry the input
  2. If a ENABLED result is returned, the action for the guarded action is the current action
  3. 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).
After the action is available, the transition proceeds as follows:
  1. If the next state is not the current state, execute the current state postAction method.
  2. Execute the action.
  3. If the next state is not the current state, execute the next state preAction method.
  4. Set the current state to the next state.
doneback to summary
public boolean done()

Return true if the stack is empty, which means that the runner is finished.

peekback to summary
public FSM peek()

Return the top fsm on the stack.

popback to summary
public FSM pop()
pushback to summary
public void push(FSM fsm)

Push a new fsm onto the stack.