Package org.apache.mina.statemachine
Class StateControl
- java.lang.Object
-
- org.apache.mina.statemachine.StateControl
-
public class StateControl extends java.lang.ObjectAllows for programmatic control of a state machines execution.The
*Now()family of methods move to a newStateimmediately and let the newStatehandle the currentEvent. The*Next()family on the other hand let the newStatehandle the nextEventwhich is generated which make these method the programmatic equivalent of using theTransitionannotation.Using the
breakAndCall*()andbreakAndReturn*methods one can create sub state machines which behave very much like sub routines. When calling a state the current state (or the specifiedreturnTostate) 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.
-
-
Constructor Summary
Constructors Constructor Description StateControl()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbreakAndCallNext(java.lang.String state)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the nextEvent.static voidbreakAndCallNext(java.lang.String state, java.lang.String returnTo)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the nextEvent.static voidbreakAndCallNow(java.lang.String state)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the currentEvent.static voidbreakAndCallNow(java.lang.String state, java.lang.String returnTo)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the currentEvent.static voidbreakAndContinue()Breaks the execution of the currentTransitionand tries to find anotherTransitionwith higher weight or aTransitionof a parentStatewhich can handle the currentEvent.static voidbreakAndGotoNext(java.lang.String state)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the nextEvent.static voidbreakAndGotoNow(java.lang.String state)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the currentEvent.static voidbreakAndReturnNext()Breaks the execution of the currentTransitionand lets the last recordedStatehandle the nextEvent.static voidbreakAndReturnNow()Breaks the execution of the currentTransitionand lets the last recordedStatehandle the currentEvent.
-
-
-
Method Detail
-
breakAndContinue
public static void breakAndContinue()
Breaks the execution of the currentTransitionand tries to find anotherTransitionwith higher weight or aTransitionof a parentStatewhich can handle the currentEvent.
-
breakAndGotoNow
public static void breakAndGotoNow(java.lang.String state)
Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the currentEvent.- Parameters:
state- the id of theStateto go to.
-
breakAndGotoNext
public static void breakAndGotoNext(java.lang.String state)
Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the nextEvent. Using this method is the programmatic equivalent of using theTransitionannotation.- Parameters:
state- the id of theStateto go to.
-
breakAndCallNow
public static void breakAndCallNow(java.lang.String state)
Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the currentEvent. Before moving to the new state the current state will be recorded. The next call tobreakAndReturnNow()orbreakAndReturnNext()will return to the current state.- Parameters:
state- the id of theStateto call.
-
breakAndCallNext
public static void breakAndCallNext(java.lang.String state)
Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the nextEvent. Before moving to the new state the current state will be recorded. The next call tobreakAndReturnNow()orbreakAndReturnNext()will return to the current state.- Parameters:
state- the id of theStateto call.
-
breakAndCallNow
public static void breakAndCallNow(java.lang.String state, java.lang.String returnTo)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the currentEvent. Before moving to the new state the current state will be recorded. The next call tobreakAndReturnNow()orbreakAndReturnNext()will return to the specifiedreturnTostate.
-
breakAndCallNext
public static void breakAndCallNext(java.lang.String state, java.lang.String returnTo)Breaks the execution of the currentTransitionand lets theStatewith the specified id handle the nextEvent. Before moving to the new state the current state will be recorded. The next call tobreakAndReturnNow()orbreakAndReturnNext()will return to the specifiedreturnTostate.
-
breakAndReturnNow
public static void breakAndReturnNow()
Breaks the execution of the currentTransitionand lets the last recordedStatehandle the currentEvent.
-
breakAndReturnNext
public static void breakAndReturnNext()
Breaks the execution of the currentTransitionand lets the last recordedStatehandle the nextEvent.
-
-