Package org.zkoss.fsm
Class StateCtx<E,C,IN>
java.lang.Object
org.zkoss.fsm.StateCtx<E,C,IN>
- Direct Known Subclasses:
MacroStateCtx
A context for a State in a StateMachine, holding returning and transition
information.
- Since:
- 6.0.0
- Author:
- simonpai
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StateMachine<E,C, IN> protected final Map<IN,StateCtx.TransitionListener<IN, C>> protected booleanprotected final Map<C,StateCtx.TransitionListener<IN, C>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMinorRoute(IN input, E destination) Add a transition for a character.addMinorRoute(IN input, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition for a character with callback.addMinorRoutes(E destination, IN... inputs) Add multiple transitions for characters.addMinorRoutes(E destination, StateCtx.TransitionListener<IN, C> callback, IN... inputs) Add multiple transitions for characters with a callback.addMinorTransition(IN input, E destination) Add a transition for a character.addMinorTransition(IN input, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition for a character with a callbackaddMinorTransitions(E destination, IN... inputs) Add multiple transitions for charactersaddMinorTransitions(E destination, StateCtx.TransitionListener<IN, C> callback, IN... inputs) Add multiple transitions for characters with a callbackaddReturningClasses(C... inputClasses) Add an input class for returning to this stateaddReturningClasses(Collection<C> collection) Add multiple input classes for returning to this stateaddReturningInputs(IN... inputs) Add input characters for returning to this stateaddReturningInputs(Collection<IN> collection) Add input characters for returning to this stateAdd a transition.Add a transition with callback.Add multiple transitions.Add multiple transitions with a callback.addTransition(C inputClass, E destination) Add a transition ruleaddTransition(C inputClass, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition rule with a callbackaddTransitions(E destination, C... inputClasses) Add multiple transitionsaddTransitions(E destination, StateCtx.TransitionListener<IN, C> callback, C... inputClasses) Add multiple transitions with a callbackgetDestination(IN input, C inputClass) Returns the destination state upon meeting the character or the class.protected voidinit()Initialization method called at the constructorbooleanReturns true if the machine is leaving this state upon meeting the character or the class.booleanisReturning(IN input, C inputClass) Returns true if this state returns to itself upon meeting the character or the class.booleanReturns true if this state returns to itself by default, unless meeting specified characters or classes.protected voidThis method is called when the machine enters this stateprotected voidThis method is called when the machine leaves this stateprotected voidThis method is called when the machine rejects the input on this stateprotected voidThis method is called when the machine returns to the same stateprotected voidonStop(boolean endOfInput) This method is called when the machine stops on this statesetMaster(StateMachine<E, C, IN> master) Sets the owner state machine.setReturningAll(boolean returnAll) Set whether returns to this state upon meeting unspecified characters
-
Field Details
-
_machine
-
_returnAll
protected boolean _returnAll -
_returners
-
_minorReturners
-
_transitions
-
_transitionListeners
-
_minorTransitions
-
_minorTransitionListeners
-
-
Constructor Details
-
StateCtx
public StateCtx()Creates a new state context
-
-
Method Details
-
setMaster
Sets the owner state machine. -
init
protected void init()Initialization method called at the constructor -
addReturningClasses
Add an input class for returning to this state- Returns:
- this state
-
addReturningClasses
Add multiple input classes for returning to this state- Returns:
- this state
-
addReturningInputs
Add input characters for returning to this state- Returns:
- this state
-
addReturningInputs
Add input characters for returning to this state- Returns:
- this state
-
setReturningAll
Set whether returns to this state upon meeting unspecified characters- Returns:
- this state
-
addTransition
Add a transition rule- Returns:
- this state
-
addTransition
public StateCtx<E,C, addTransitionIN> (C inputClass, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition rule with a callback- Returns:
- this state
-
addTransitions
Add multiple transitions- Returns:
- this state
-
addTransitions
public StateCtx<E,C, addTransitionsIN> (E destination, StateCtx.TransitionListener<IN, C> callback, C... inputClasses) Add multiple transitions with a callback- Returns:
- this state
-
addRoute
Add a transition. Same asaddTransition(Object, Object), and only differs in return value.- Returns:
- destination state.
-
addRoute
public StateCtx<E,C, addRouteIN> (C inputClass, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition with callback. Same asaddTransition(Object, Object, TransitionListener), and only differs in return value.- Returns:
- destination state.
-
addRoutes
Add multiple transitions. Same asaddTransitions(Object, Object...), and only differs in return value.- Returns:
- destination state.
-
addRoutes
public StateCtx<E,C, addRoutesIN> (E destination, StateCtx.TransitionListener<IN, C> callback, C... inputClasses) Add multiple transitions with a callback. Same asaddTransitions(Object, TransitionListener, Object...), and only differs in return value.- Returns:
- destination state.
-
addMinorTransition
Add a transition for a character.- Returns:
- this state
-
addMinorTransition
public StateCtx<E,C, addMinorTransitionIN> (IN input, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition for a character with a callback- Returns:
- this state
-
addMinorTransitions
Add multiple transitions for characters- Returns:
- this state
-
addMinorTransitions
public StateCtx<E,C, addMinorTransitionsIN> (E destination, StateCtx.TransitionListener<IN, C> callback, IN... inputs) Add multiple transitions for characters with a callback- Returns:
- this state
-
addMinorRoute
Add a transition for a character. Same asaddMinorRoute(Object, Object), and only differs in return value.- Returns:
- destination state
-
addMinorRoute
public StateCtx<E,C, addMinorRouteIN> (IN input, E destination, StateCtx.TransitionListener<IN, C> callback) Add a transition for a character with callback. Same asaddMinorTransition(Object, Object, TransitionListener), and only differs in return value.- Returns:
- destination state
-
addMinorRoutes
Add multiple transitions for characters. Same asaddMinorTransitions(Object, Object...), and only differs in return value.- Returns:
- destination state
-
addMinorRoutes
public StateCtx<E,C, addMinorRoutesIN> (E destination, StateCtx.TransitionListener<IN, C> callback, IN... inputs) Add multiple transitions for characters with a callback. Same asaddMinorTransitions(Object, TransitionListener, Object...), and only differs in return value.- Returns:
- destination state
-
isReturningAll
public boolean isReturningAll()Returns true if this state returns to itself by default, unless meeting specified characters or classes. -
isReturning
Returns true if this state returns to itself upon meeting the character or the class. -
isLeaving
Returns true if the machine is leaving this state upon meeting the character or the class. -
getDestination
Returns the destination state upon meeting the character or the class. -
onLand
This method is called when the machine enters this state -
onReturn
This method is called when the machine returns to the same state -
onReject
This method is called when the machine rejects the input on this state -
onLeave
This method is called when the machine leaves this state -
onStop
protected void onStop(boolean endOfInput) This method is called when the machine stops on this state
-