org.apache.mina.statemachine
Class StateMachine

java.lang.Object
  extended by org.apache.mina.statemachine.StateMachine

public class StateMachine
extends Object

Represents a complete state machine. Contains a collection of State objects connected by Transitions. Normally you wouldn't create instances of this class directly but rather use the State annotation to define your states and then let StateMachineFactory create a StateMachine for you.

Version:
$Rev: 641052 $, $Date: 2008-03-25 23:22:35 +0100 (mar, 25 mar 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
StateMachine(Collection<State> states, String startStateId)
          Creates a new instance using the specified States and start state.
StateMachine(State[] states, String startStateId)
          Creates a new instance using the specified States and start state.
 
Method Summary
 State getState(String id)
          Returns the State with the specified id.
 Collection<State> getStates()
          Returns an unmodifiable Collection of all States used by this StateMachine.
 void handle(Event event)
          Processes the specified Event through this StateMachine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateMachine

public StateMachine(State[] states,
                    String startStateId)
Creates a new instance using the specified States and start state.

Parameters:
states - the States.
startStateId - the id of the start State.

StateMachine

public StateMachine(Collection<State> states,
                    String startStateId)
Creates a new instance using the specified States and start state.

Parameters:
states - the States.
startStateId - the id of the start State.
Method Detail

getState

public State getState(String id)
               throws NoSuchStateException
Returns the State with the specified id.

Parameters:
id - the id of the State to return.
Returns:
the State
Throws:
NoSuchStateException - if no matching State could be found.

getStates

public Collection<State> getStates()
Returns an unmodifiable Collection of all States used by this StateMachine.

Returns:
the States.

handle

public void handle(Event event)
Processes the specified Event through this StateMachine. Normally you wouldn't call this directly but rather use StateMachineProxyBuilder to create a proxy for an interface of your choice. Any method calls on the proxy will be translated into Event objects and then fed to the StateMachine by the proxy using this method.

Parameters:
event - the Event to be handled.


Copyright © 2004-2008 Apache MINA Project. All Rights Reserved.