org.zkoss.fsm
Class StateCtx<E,C,IN>

java.lang.Object
  extended by org.zkoss.fsm.StateCtx<E,C,IN>
Direct Known Subclasses:
MacroStateCtx

public class StateCtx<E,C,IN>
extends java.lang.Object

A context for a State in a StateMachine, holding returning and transition information.

Since:
6.0.0
Author:
simonpai

Nested Class Summary
static interface StateCtx.TransitionListener<IN,C>
           
 
Field Summary
protected  StateMachine<E,C,IN> _machine
           
protected  java.util.Set<IN> _minorReturners
           
protected  java.util.Map<IN,StateCtx.TransitionListener<IN,C>> _minorTransitionListeners
           
protected  java.util.Map<IN,E> _minorTransitions
           
protected  boolean _returnAll
           
protected  java.util.Set<C> _returners
           
protected  java.util.Map<C,StateCtx.TransitionListener<IN,C>> _transitionListeners
           
protected  java.util.Map<C,E> _transitions
           
 
Constructor Summary
StateCtx()
          Creates a new state context
 
Method Summary
 StateCtx<E,C,IN> addMinorRoute(IN input, E destination)
          Add a transition for a character.
 StateCtx<E,C,IN> addMinorRoute(IN input, E destination, StateCtx.TransitionListener<IN,C> callback)
          Add a transition for a character with callback.
 StateCtx<E,C,IN> addMinorRoutes(E destination, IN... inputs)
          Add multiple transitions for characters.
 StateCtx<E,C,IN> addMinorRoutes(E destination, StateCtx.TransitionListener<IN,C> callback, IN... inputs)
          Add multiple transitions for characters with a callback.
 StateCtx<E,C,IN> addMinorTransition(IN input, E destination)
          Add a transition for a character.
 StateCtx<E,C,IN> addMinorTransition(IN input, E destination, StateCtx.TransitionListener<IN,C> callback)
          Add a transition for a character with a callback
 StateCtx<E,C,IN> addMinorTransitions(E destination, IN... inputs)
          Add multiple transitions for characters
 StateCtx<E,C,IN> addMinorTransitions(E destination, StateCtx.TransitionListener<IN,C> callback, IN... inputs)
          Add multiple transitions for characters with a callback
 StateCtx<E,C,IN> addReturningClasses(C... inputClasses)
          Add an input class for returning to this state
 StateCtx<E,C,IN> addReturningClasses(java.util.Collection<C> collection)
          Add multiple input classes for returning to this state
 StateCtx<E,C,IN> addReturningInputs(java.util.Collection<IN> collection)
          Add input characters for returning to this state
 StateCtx<E,C,IN> addReturningInputs(IN... inputs)
          Add input characters for returning to this state
 StateCtx<E,C,IN> addRoute(C inputClass, E destination)
          Add a transition.
 StateCtx<E,C,IN> addRoute(C inputClass, E destination, StateCtx.TransitionListener<IN,C> callback)
          Add a transition with callback.
 StateCtx<E,C,IN> addRoutes(E destination, C... inputClasses)
          Add multiple transitions.
 StateCtx<E,C,IN> addRoutes(E destination, StateCtx.TransitionListener<IN,C> callback, C... inputClasses)
          Add multiple transitions with a callback.
 StateCtx<E,C,IN> addTransition(C inputClass, E destination)
          Add a transition rule
 StateCtx<E,C,IN> addTransition(C inputClass, E destination, StateCtx.TransitionListener<IN,C> callback)
          Add a transition rule with a callback
 StateCtx<E,C,IN> addTransitions(E destination, C... inputClasses)
          Add multiple transitions
 StateCtx<E,C,IN> addTransitions(E destination, StateCtx.TransitionListener<IN,C> callback, C... inputClasses)
          Add multiple transitions with a callback
 E getDestination(IN input, C inputClass)
          Returns the destination state upon meeting the character or the class.
protected  void init()
          Initialization method called at the constructor
 boolean isLeaving(IN input, C inputClass)
          Returns true if the machine is leaving this state upon meeting the character or the class.
 boolean isReturning(IN input, C inputClass)
          Returns true if this state returns to itself upon meeting the character or the class.
 boolean isReturningAll()
          Returns true if this state returns to itself by default, unless meeting specified characters or classes.
protected  void onLand(IN input, C inputClass, E origin)
          This method is called when the machine enters this state
protected  void onLeave(IN input, C inputClass, E destination)
          This method is called when the machine leaves this state
protected  void onReject(IN input, C inputClass)
          This method is called when the machine rejects the input on this state
protected  void onReturn(IN input, C inputClass)
          This method is called when the machine returns to the same state
protected  void onStop(boolean endOfInput)
          This method is called when the machine stops on this state
protected  StateCtx<E,C,IN> setMaster(StateMachine<E,C,IN> master)
          Sets the owner state machine.
 StateCtx<E,C,IN> setReturningAll(boolean returnAll)
          Set whether returns to this state upon meeting unspecified characters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_machine

protected StateMachine<E,C,IN> _machine

_returnAll

protected boolean _returnAll

_returners

protected final java.util.Set<C> _returners

_minorReturners

protected final java.util.Set<IN> _minorReturners

_transitions

protected final java.util.Map<C,E> _transitions

_transitionListeners

protected final java.util.Map<C,StateCtx.TransitionListener<IN,C>> _transitionListeners

_minorTransitions

protected final java.util.Map<IN,E> _minorTransitions

_minorTransitionListeners

protected final java.util.Map<IN,StateCtx.TransitionListener<IN,C>> _minorTransitionListeners
Constructor Detail

StateCtx

public StateCtx()
Creates a new state context

Method Detail

setMaster

protected StateCtx<E,C,IN> setMaster(StateMachine<E,C,IN> master)
Sets the owner state machine.


init

protected void init()
Initialization method called at the constructor


addReturningClasses

public StateCtx<E,C,IN> addReturningClasses(C... inputClasses)
Add an input class for returning to this state

Returns:
this state

addReturningClasses

public StateCtx<E,C,IN> addReturningClasses(java.util.Collection<C> collection)
Add multiple input classes for returning to this state

Returns:
this state

addReturningInputs

public StateCtx<E,C,IN> addReturningInputs(IN... inputs)
Add input characters for returning to this state

Returns:
this state

addReturningInputs

public StateCtx<E,C,IN> addReturningInputs(java.util.Collection<IN> collection)
Add input characters for returning to this state

Returns:
this state

setReturningAll

public StateCtx<E,C,IN> setReturningAll(boolean returnAll)
Set whether returns to this state upon meeting unspecified characters

Returns:
this state

addTransition

public StateCtx<E,C,IN> addTransition(C inputClass,
                                      E destination)
Add a transition rule

Returns:
this state

addTransition

public StateCtx<E,C,IN> addTransition(C inputClass,
                                      E destination,
                                      StateCtx.TransitionListener<IN,C> callback)
Add a transition rule with a callback

Returns:
this state

addTransitions

public StateCtx<E,C,IN> addTransitions(E destination,
                                       C... inputClasses)
Add multiple transitions

Returns:
this state

addTransitions

public StateCtx<E,C,IN> addTransitions(E destination,
                                       StateCtx.TransitionListener<IN,C> callback,
                                       C... inputClasses)
Add multiple transitions with a callback

Returns:
this state

addRoute

public StateCtx<E,C,IN> addRoute(C inputClass,
                                 E destination)
Add a transition. Same as addTransition(Object, Object), and only differs in return value.

Returns:
destination state.

addRoute

public StateCtx<E,C,IN> addRoute(C inputClass,
                                 E destination,
                                 StateCtx.TransitionListener<IN,C> callback)
Add a transition with callback. Same as addTransition(Object, Object, TransitionListener), and only differs in return value.

Returns:
destination state.

addRoutes

public StateCtx<E,C,IN> addRoutes(E destination,
                                  C... inputClasses)
Add multiple transitions. Same as addTransitions(Object, Object...), and only differs in return value.

Returns:
destination state.

addRoutes

public StateCtx<E,C,IN> addRoutes(E destination,
                                  StateCtx.TransitionListener<IN,C> callback,
                                  C... inputClasses)
Add multiple transitions with a callback. Same as addTransitions(Object, TransitionListener, Object...), and only differs in return value.

Returns:
destination state.

addMinorTransition

public StateCtx<E,C,IN> addMinorTransition(IN input,
                                           E destination)
Add a transition for a character.

Returns:
this state

addMinorTransition

public StateCtx<E,C,IN> addMinorTransition(IN input,
                                           E destination,
                                           StateCtx.TransitionListener<IN,C> callback)
Add a transition for a character with a callback

Returns:
this state

addMinorTransitions

public StateCtx<E,C,IN> addMinorTransitions(E destination,
                                            IN... inputs)
Add multiple transitions for characters

Returns:
this state

addMinorTransitions

public StateCtx<E,C,IN> addMinorTransitions(E destination,
                                            StateCtx.TransitionListener<IN,C> callback,
                                            IN... inputs)
Add multiple transitions for characters with a callback

Returns:
this state

addMinorRoute

public StateCtx<E,C,IN> addMinorRoute(IN input,
                                      E destination)
Add a transition for a character. Same as addMinorRoute(Object, Object), and only differs in return value.

Returns:
destination state

addMinorRoute

public StateCtx<E,C,IN> addMinorRoute(IN input,
                                      E destination,
                                      StateCtx.TransitionListener<IN,C> callback)
Add a transition for a character with callback. Same as addMinorTransition(Object, Object, TransitionListener), and only differs in return value.

Returns:
destination state

addMinorRoutes

public StateCtx<E,C,IN> addMinorRoutes(E destination,
                                       IN... inputs)
Add multiple transitions for characters. Same as addMinorTransitions(Object, Object...), and only differs in return value.

Returns:
destination state

addMinorRoutes

public StateCtx<E,C,IN> addMinorRoutes(E destination,
                                       StateCtx.TransitionListener<IN,C> callback,
                                       IN... inputs)
Add multiple transitions for characters with a callback. Same as addMinorTransitions(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

public boolean isReturning(IN input,
                           C inputClass)
Returns true if this state returns to itself upon meeting the character or the class.


isLeaving

public boolean isLeaving(IN input,
                         C inputClass)
Returns true if the machine is leaving this state upon meeting the character or the class.


getDestination

public E getDestination(IN input,
                        C inputClass)
Returns the destination state upon meeting the character or the class.


onLand

protected void onLand(IN input,
                      C inputClass,
                      E origin)
This method is called when the machine enters this state


onReturn

protected void onReturn(IN input,
                        C inputClass)
This method is called when the machine returns to the same state


onReject

protected void onReject(IN input,
                        C inputClass)
This method is called when the machine rejects the input on this state


onLeave

protected void onLeave(IN input,
                       C inputClass,
                       E destination)
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



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo