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".
-
StateMachineStd()
-
-
addCommand(String, boolean)
- Adds the command.
-
addState(String, String)
- Adds the state.
-
addTransition(String, String, String)
- Adds the transition.
-
commandExists(String)
- Determines whether the command exists, ie was added.
-
enumerateStateCommands(String)
- Returns all the StateCommands for the part, configured to reflect
the current state.
-
getInitialState()
- Returns the initial state.
-
getNewState(String, String)
- Returns the new state implied by the arguments or null for
undefined.
-
isTransitionAllowed(String, String)
- Determines whether the transition implied by the arguments is
allowed according to the state transition table.
-
setInitialState(String)
- Sets the initial state.
StateMachineStd
public StateMachineStd()
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.
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.
setInitialState
public void setInitialState(String stateName)
- Sets the initial state.
- Parameters:
- stateName - the initial state name.
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.
getInitialState
public String getInitialState()
- Returns the initial state.
- Returns:
- the initial state.
commandExists
public boolean commandExists(String command)
- Determines whether the command exists, ie was added.
- Returns:
- true if exists, false if not.
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.
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.
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