org.apache.mina.statemachine
Class State

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

public class State
extends Object

Represents a state in a StateMachine. 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.

States inherits Transitions from their parent. A State can override any of the parents Transitions. When an Event is processed the Transitions of the current State will be searched for a Transition which can handle the event. If none is found the State's parent will be searched and so on.

Version:
$Rev: 586108 $, $Date: 2007-10-18 22:05:07 +0200 (jeu, 18 oct 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
State(String id)
          Creates a new State with the specified id.
State(String id, State parent)
          Creates a new State with the specified id and parent.
 
Method Summary
 State addTransition(Transition transition)
          Adds an outgoing Transition to this State with weight 0.
 State addTransition(Transition transition, int weight)
          Adds an outgoing Transition to this State with the specified weight.
 boolean equals(Object o)
           
 String getId()
          Returns the id of this State.
 State getParent()
          Returns the parent State.
 List<Transition> getTransitions()
          Returns an unmodifiable List of Transitions going out from this State.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

State

public State(String id)
Creates a new State with the specified id.

Parameters:
id - the unique id of this State.

State

public State(String id,
             State parent)
Creates a new State with the specified id and parent.

Parameters:
id - the unique id of this State.
parent - the parent State.
Method Detail

getId

public String getId()
Returns the id of this State.

Returns:
the id.

getParent

public State getParent()
Returns the parent State.

Returns:
the parent or null if this State has no parent.

getTransitions

public List<Transition> getTransitions()
Returns an unmodifiable List of Transitions going out from this State.

Returns:
the Transitions.

addTransition

public State addTransition(Transition transition)
Adds an outgoing Transition to this State with weight 0.

Parameters:
transition - the Transition to add.
Returns:
this State.
See Also:
addTransition(Transition, int)

addTransition

public State addTransition(Transition transition,
                           int weight)
Adds an outgoing Transition to this State with the specified weight. The higher the weight the less important a Transition is. If two Transitions match the same Event the Transition with the lower weight will be executed.

Parameters:
transition - the Transition to add.
Returns:
this State.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


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