org.apache.mina.statemachine
Class StateControl

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

public class StateControl
extends Object

Allows for programmatic control of a state machines execution.

The *Now() family of methods move to a new State immediately and let the new State handle the current Event. The *Next() family on the other hand let the new State handle the next Event which is generated which make these method the programmatic equivalent of using the Transition annotation.

Using the breakAndCall*() and breakAndReturn* methods one can create sub state machines which behave very much like sub routines. When calling a state the current state (or the specified returnTo state) will be pushed on a stack. When returning from a state the last pushed state will be popped from the stack and used as the new state.

Version:
$Rev: 592122 $, $Date: 2007-11-05 20:10:32 +0100 (lun, 05 nov 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
StateControl()
           
 
Method Summary
static void breakAndCallNext(String state)
          Breaks the execution of the current Transition and lets the State with the specified id handle the next Event.
static void breakAndCallNext(String state, String returnTo)
          Breaks the execution of the current Transition and lets the State with the specified id handle the next Event.
static void breakAndCallNow(String state)
          Breaks the execution of the current Transition and lets the State with the specified id handle the current Event.
static void breakAndCallNow(String state, String returnTo)
          Breaks the execution of the current Transition and lets the State with the specified id handle the current Event.
static void breakAndContinue()
          Breaks the execution of the current Transition and tries to find another Transition with higher weight or a Transition of a parent State which can handle the current Event.
static void breakAndGotoNext(String state)
          Breaks the execution of the current Transition and lets the State with the specified id handle the next Event.
static void breakAndGotoNow(String state)
          Breaks the execution of the current Transition and lets the State with the specified id handle the current Event.
static void breakAndReturnNext()
          Breaks the execution of the current Transition and lets the last recorded State handle the next Event.
static void breakAndReturnNow()
          Breaks the execution of the current Transition and lets the last recorded State handle the current Event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateControl

public StateControl()
Method Detail

breakAndContinue

public static void breakAndContinue()
Breaks the execution of the current Transition and tries to find another Transition with higher weight or a Transition of a parent State which can handle the current Event.


breakAndGotoNow

public static void breakAndGotoNow(String state)
Breaks the execution of the current Transition and lets the State with the specified id handle the current Event.

Parameters:
state - the id of the State to go to.

breakAndGotoNext

public static void breakAndGotoNext(String state)
Breaks the execution of the current Transition and lets the State with the specified id handle the next Event. Using this method is the programmatic equivalent of using the Transition annotation.

Parameters:
state - the id of the State to go to.

breakAndCallNow

public static void breakAndCallNow(String state)
Breaks the execution of the current Transition and lets the State with the specified id handle the current Event. Before moving to the new state the current state will be recorded. The next call to breakAndReturnNow() or breakAndReturnNext() will return to the current state.

Parameters:
state - the id of the State to call.

breakAndCallNext

public static void breakAndCallNext(String state)
Breaks the execution of the current Transition and lets the State with the specified id handle the next Event. Before moving to the new state the current state will be recorded. The next call to breakAndReturnNow() or breakAndReturnNext() will return to the current state.

Parameters:
state - the id of the State to call.

breakAndCallNow

public static void breakAndCallNow(String state,
                                   String returnTo)
Breaks the execution of the current Transition and lets the State with the specified id handle the current Event. Before moving to the new state the current state will be recorded. The next call to breakAndReturnNow() or breakAndReturnNext() will return to the specified returnTo state.

Parameters:
state - the id of the State to call.
returnTo - the id of the State to return to.

breakAndCallNext

public static void breakAndCallNext(String state,
                                    String returnTo)
Breaks the execution of the current Transition and lets the State with the specified id handle the next Event. Before moving to the new state the current state will be recorded. The next call to breakAndReturnNow() or breakAndReturnNext() will return to the specified returnTo state.

Parameters:
state - the id of the State to call.
returnTo - the id of the State to return to.

breakAndReturnNow

public static void breakAndReturnNow()
Breaks the execution of the current Transition and lets the last recorded State handle the current Event.


breakAndReturnNext

public static void breakAndReturnNext()
Breaks the execution of the current Transition and lets the last recorded State handle the next Event.



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