|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
S - the type of states in the engine's state graphL - the type of labels on the engine's state graphP - the type of transition parameterisation of the state activatorpublic interface StateEngine<S,L,P>
State Engines manage transitions across a pre-defined graph of allowed states
and state transitions. Work that is to be done as part of a transition is
performed by a StateActivator assigned to the engine. When an
engine is first created (or after the failure of a transition due to a
unchecked exception being thrown by the engine's associated activator), the
engine is in an indeterminate state and the setState method must be called
before any transmissions may be made. Instances of this class are entirely
safe for concurrent access.
| Method Summary | |
|---|---|
boolean |
addStateListener(StateListener<S,L> listener)
Adds a state listener to this engine. |
StateGraph<S,L> |
getGraph()
The graph of an engine constrains the states which it may enter and the transitions it may make. |
StateEnginePolicy |
getPolicy()
The policy under which the engine is operating. |
java.util.Set<S> |
getPossibleStates()
Returns a set of the states which are currently permitted in a call to setState. |
S |
getState()
The state that this engine is currently in. |
void |
pathTransition(S state,
L label,
PathType type,
StateTransitionParameters<S,L,P> parameters)
This method is called to instruct the engine to make a sequence of state transitions. |
boolean |
removeStateListener(StateListener<S,L> listener)
Removes a previously added state listener from this engine. |
void |
setPolicy(StateEnginePolicy policy)
Sets the policy under which the state engine will operate. |
void |
setState(S state)
Puts the engine into a specified state. |
void |
transition(S state,
L label,
P parameter)
This method is called to instruct the engine to make one (or possibly more) state transitions. |
| Method Detail |
|---|
void setPolicy(StateEnginePolicy policy)
DefaultStatePolicy to be
used.
policy - the engine's policy, may be nullStateEnginePolicy getPolicy()
StateGraph<S,L> getGraph()
java.util.Set<S> getPossibleStates()
setState. Initially, this will be every state in the
engine's state graph. After a state has been set, only the current state
will be returned unless a transition failure has occured due to an
unchecked exception in which case the possible states are the initial and
final states of the transition which failed.
S getState()
void setState(S state)
throws ProntoStateException
state - the state into which the engine should be put
ProntoStateException - if the state change is impossible, vetoed or failed
void transition(S state,
L label,
P parameter)
throws ProntoStateException,
java.lang.IllegalArgumentException
getState() will return null.
Depending on the engine's current policy, exceptions raised by listeners
in response to the transitioning may be thrown from this method. Such
exceptions will not cause the engine to enter an indeterminate state.
state - the state to transition to, may be nulllabel - a constraint on the transition, may be nullparameter - passed through to the activator on transition, may be null if
the activator permits it
ProntoStateException - if the transition fails for any reason including: the engine
being in an indetermintate state, the activator vetoing the
transition, the activator failing with a unchecked exception,
the lack of a matching transition, the presence of more than
one matching transition
java.lang.IllegalArgumentException - if the method is called with null state and null label
void pathTransition(S state,
L label,
PathType type,
StateTransitionParameters<S,L,P> parameters)
throws ProntoStateException,
java.lang.IllegalArgumentException
getState() will return null.
Depending on the engine's current policy, exceptions raised by listeners
in response to the transitioning may be thrown from this method. Such
exceptions will not cause the engine to enter an indeterminate state.
state - the state to transition to, may be nulllabel - a constraint on each transition, may be nulltype - a constraint on the sequence of transitionsparameters - may supply a parameter for each transition, may be null in
which case a null parameter will be supplied for every
transition
ProntoStateException - if the transition fails for any reason including: the engine
being in an indetermintate state, the activator vetoing the
transition, the activator failing with a unchecked exception,
the lack of a matching sequence of transition, the presence
of more than one matching sequence of transitions.
java.lang.IllegalArgumentException - if the method is called with null state and null labelboolean addStateListener(StateListener<S,L> listener)
listener - the state listener to be added
boolean removeStateListener(StateListener<S,L> listener)
listener - the listener to be removed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||