All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class uhr.core.role.StateMachineStd

java.lang.Object
   |
   +----uhr.core.role.StateMachineStd

public class StateMachineStd
extends Object
implements StateMachine
This provides a simple configurable state machine. It's designed to work with the StateCommandableAide on a flyweight basis. It contains no part specific state, only the definition of a state machine. Perhaps a better name is "StateMachineDef".


Constructor Index

 o StateMachineStd()

Method Index

 o addCommand(String, boolean)
Adds the command.
 o addState(String, String)
Adds the state.
 o addTransition(String, String, String)
Adds the transition.
 o commandExists(String)
Determines whether the command exists, ie was added.
 o enumerateStateCommands(String)
Returns all the StateCommands for the part, configured to reflect the current state.
 o getInitialState()
Returns the initial state.
 o getNewState(String, String)
Returns the new state implied by the arguments or null for undefined.
 o isTransitionAllowed(String, String)
Determines whether the transition implied by the arguments is allowed according to the state transition table.
 o setInitialState(String)
Sets the initial state.

Constructors

 o StateMachineStd
 public StateMachineStd()

Methods

 o addCommand
 public void addCommand(String name,
                        boolean isPropogated)
Adds the command. Call this method for each command in the visual display order desired.

Parameters:
name - the command name, such as "Start" or "Close". It must be unique within the aide.
isPropogated - true for automatically propogated to childeren if their state allows it, false if not.
 o addState
 public void addState(String state,
                      String defaultCommand)
Adds the state. The first one added is the initial state unless setInitialState(...) is called.

Parameters:
state - the state name, unique within the aide. Examples are "Created" or "Paused".
defaultCommand - the default command for the state. If null then this is a final state.
 o setInitialState
 public void setInitialState(String stateName)
Sets the initial state.

Parameters:
stateName - the initial state name.
 o addTransition
 public void addTransition(String state,
                           String command,
                           String newState)
Adds the transition. Note that a state can have multiple commands. Each state/command combination can have only one newState.

Parameters:
state - the current state of the transition.
command - the command received in the current state.
newState - the newState after the command is performed.
 o getInitialState
 public String getInitialState()
Returns the initial state.

Returns:
the initial state.
 o commandExists
 public boolean commandExists(String command)
Determines whether the command exists, ie was added.

Returns:
true if exists, false if not.
 o isTransitionAllowed
 public boolean isTransitionAllowed(String currentState,
                                    String command)
Determines whether the transition implied by the arguments is allowed according to the state transition table.

Parameters:
currentState - the current state in question.
command - the command in question.
 o getNewState
 public String getNewState(String currentState,
                           String command)
Returns the new state implied by the arguments or null for undefined.

Parameters:
currentState - the current state in question.
command - the command in question.
 o enumerateStateCommands
 public Enumeration enumerateStateCommands(String currentState)
Returns all the StateCommands for the part, configured to reflect the current state.

Returns:
the StateCommands.

All Packages  Class Hierarchy  This Package  Previous  Next  Index