org.apache.mina.statemachine

## Class StateControl

- java.lang.Object
- - 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.

  Author:
    Apache MINA Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StateControl()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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-2012 Apache MINA Project. All Rights Reserved.