org.jboss.util.state
Class StateMachine

java.lang.Object
  extended byorg.jboss.util.state.StateMachine
All Implemented Interfaces:
java.lang.Cloneable

public class StateMachine
extends java.lang.Object
implements java.lang.Cloneable

The representation of a finite state machine.


Constructor Summary
StateMachine(java.util.Set states, State (src)  startState)
          Create a state machine given its states and start state.
StateMachine(java.util.Set states, State (src)  startState, java.lang.String description)
          Create a state machine given its states and start state.
 
Method Summary
 java.lang.Object clone()
          Make a copy of the StateMachine maintaining the current state.
 State (src) getCurrentState()
          Get the current state of the state machine.
 java.lang.String getDescription()
          Get the state machine description.
 State (src) getStartState()
          Get the start state of the state machine.
 java.util.Set getStates()
          Get the states of the state machine.
 State (src) nextState(java.lang.String actionName)
          Transition to the next state given the name of a valid transition.
 State (src) reset()
          Reset the state machine back to the start state
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StateMachine

public StateMachine(java.util.Set states,
                    State (src)  startState)
Create a state machine given its states and start state.

Parameters:
states - - Set for the state machine
startState - - the starting state

StateMachine

public StateMachine(java.util.Set states,
                    State (src)  startState,
                    java.lang.String description)
Create a state machine given its states and start state.

Parameters:
states - - Set for the state machine
startState - - the starting state
description - - an optional description of the state machine
Method Detail

clone

public java.lang.Object clone()
Make a copy of the StateMachine maintaining the current state.

Returns:
a copy of the StateMachine.

getDescription

public java.lang.String getDescription()
Get the state machine description.

Returns:
an possibly null description.

getCurrentState

public State (src)  getCurrentState()
Get the current state of the state machine.

Returns:
the current state.

getStartState

public State (src)  getStartState()
Get the start state of the state machine.

Returns:
the start state.

getStates

public java.util.Set getStates()
Get the states of the state machine.

Returns:
the machine states.

nextState

public State (src)  nextState(java.lang.String actionName)
                throws IllegalTransitionException (src) 
Transition to the next state given the name of a valid transition.

Parameters:
actionName - - the name of transition that is valid for the current state.
Returns:
Throws:
IllegalTransitionException (src)

reset

public State (src)  reset()
Reset the state machine back to the start state

Returns:
the start state

toString

public java.lang.String toString()