net.sourceforge.aqueduct
Class StateMachine<S extends State<I>,I extends InputSource>

java.lang.Object
  extended by net.sourceforge.aqueduct.StateMachine<S,I>
Type Parameters:
I - The type of InputSource object used by States in this state machine to find the next transition name.

public class StateMachine<S extends State<I>,I extends InputSource>
extends java.lang.Object

Maintains the current state and InputSource used by a particular execution of a StateMachineDescription.

Author:
keith

Constructor Summary
StateMachine(StateMachineDescription<S,I> stateMachineDescription, I inputSource)
           
 
Method Summary
 void addStateEventListener(S state, StateEventListener<I> listener)
          Registers a StateEventListener to receive transition event notifications for the indicated State.
 S getCurrentState()
           
 void goToNextState()
          Performs a single state transition and fires the requisite StateEventListener event handler methods.
 void goToStateById(java.lang.String id)
          Transitions this StateMachine to the state named by the id parameter.
 void removeStateEventListener(S state, StateEventListener<I> listener)
          Unregisters a StateEventListener that is receiving transition event notifications for the provided State.
 void runUntilStopState()
          Calls goToNextState() until currentState.isStopState() returns true or until the stopRunningUntilStopState() method is called.
 void stopRunningUntilStopState()
          Sets a flag to break the loop in runUntilStopState().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateMachine

public StateMachine(StateMachineDescription<S,I> stateMachineDescription,
                    I inputSource)
Method Detail

getCurrentState

public S getCurrentState()

goToNextState

public void goToNextState()
Performs a single state transition and fires the requisite StateEventListener event handler methods.


goToStateById

public void goToStateById(java.lang.String id)
Transitions this StateMachine to the state named by the id parameter. Does not fire StateEventListener event handler methods. If the isGoToStateByIdAllowed() method returns false, this method throws an IllegalStateException.

Parameters:
id -

runUntilStopState

public void runUntilStopState()
Calls goToNextState() until currentState.isStopState() returns true or until the stopRunningUntilStopState() method is called.


stopRunningUntilStopState

public void stopRunningUntilStopState()
Sets a flag to break the loop in runUntilStopState().


addStateEventListener

public void addStateEventListener(S state,
                                  StateEventListener<I> listener)
Registers a StateEventListener to receive transition event notifications for the indicated State.

Parameters:
state -
listener -

removeStateEventListener

public void removeStateEventListener(S state,
                                     StateEventListener<I> listener)
Unregisters a StateEventListener that is receiving transition event notifications for the provided State.

Parameters:
state -
listener -


Copyright © 2008. All Rights Reserved.