|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.tomgibara.pronto.state.impl.StateEngineImpl<S,L,P>
public class StateEngineImpl<S,L,P>
| Constructor Summary | |
|---|---|
StateEngineImpl(StateGraph<S,L> graph,
StateActivator<S,L,P> activator)
|
|
| 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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StateEngineImpl(StateGraph<S,L> graph,
StateActivator<S,L,P> activator)
| Method Detail |
|---|
public void setPolicy(StateEnginePolicy policy)
StateEngineDefaultStatePolicy to be
used.
setPolicy in interface StateEngine<S,L,P>policy - the engine's policy, may be nullpublic StateEnginePolicy getPolicy()
StateEngine
getPolicy in interface StateEngine<S,L,P>public StateGraph<S,L> getGraph()
StateEngine
getGraph in interface StateEngine<S,L,P>public java.util.Set<S> getPossibleStates()
StateEnginesetState. 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.
getPossibleStates in interface StateEngine<S,L,P>public S getState()
StateEngine
getState in interface StateEngine<S,L,P>
public void setState(S state)
throws ProntoStateException
StateEngine
setState in interface StateEngine<S,L,P>state - the state into which the engine should be put
ProntoStateException - if the state change is impossible, vetoed or failed
public void transition(S state,
L label,
P parameter)
throws ProntoStateException
StateEnginegetState() 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.
transition in interface StateEngine<S,L,P>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
public void pathTransition(S state,
L label,
PathType type,
StateTransitionParameters<S,L,P> parameters)
throws ProntoStateException,
java.lang.IllegalArgumentException
StateEnginegetState() 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.
pathTransition in interface StateEngine<S,L,P>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 labelpublic boolean addStateListener(StateListener<S,L> listener)
StateEngine
addStateListener in interface StateEngine<S,L,P>listener - the state listener to be added
public boolean removeStateListener(StateListener<S,L> listener)
StateEngine
removeStateListener in interface StateEngine<S,L,P>listener - the listener to be removed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||