Package org.glassfish.pfl.basic.fsm
Class State
- java.lang.Object
-
- org.glassfish.pfl.basic.fsm.NameBase
-
- org.glassfish.pfl.basic.fsm.State
-
public class State extends NameBase
Base class for all states in a StateEngine. This must be used as the base class for all states in transitions added to a StateEngine.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
State.Kind
Kind of state.
-
Field Summary
Fields Modifier and Type Field Description private Action
defaultAction
private State
defaultNextState
private java.util.Map<Input,java.util.Set<Transition>>
inputMap
private java.util.Map<Input,java.util.Set<Transition>>
inputMapImage
private java.util.Map<Input,java.util.Set<Transition>>
inputMapRangeImage
private State.Kind
kind
-
Constructor Summary
Constructors Constructor Description State(java.lang.String name)
State(java.lang.String name, State.Kind kind)
State(java.util.Set<State> states, java.lang.String name)
State(java.util.Set<State> states, java.lang.String name, State.Kind kind)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addTransition(Input in, Transition ga)
Action
getDefaultAction()
Get the default transition action that is used if the default next state is used.State
getDefaultNextState()
Return the default next state for this state.java.util.Map<Input,java.util.Set<Transition>>
getInputMap()
State.Kind
getKind()
Return the Kind of this state.(package private) java.util.Set<Transition>
getTransitions(Input in)
void
postAction(FSM fsm)
Method that defines action that occurs whenever this state is exited, that is, when the state is changed from this state to a new state.FSM
preAction(FSM fsm)
Method that defines action that occurs whenever this state is entered from a different state.State
returnAction(FSM fsm, FSM nestedFSM)
If this state has Kind REFERENCE, and its preAction pushes a nested FSM onto the stack, the returnAction method is called after the nested FSM reaches a final state.(package private) void
setDefaultAction(Action defaultAction)
(package private) void
setDefaultNextState(State defaultNextState)
-
-
-
Field Detail
-
kind
private State.Kind kind
-
defaultAction
private Action defaultAction
-
defaultNextState
private State defaultNextState
-
inputMap
private java.util.Map<Input,java.util.Set<Transition>> inputMap
-
inputMapRangeImage
private java.util.Map<Input,java.util.Set<Transition>> inputMapRangeImage
-
inputMapImage
private java.util.Map<Input,java.util.Set<Transition>> inputMapImage
-
-
Constructor Detail
-
State
public State(java.lang.String name)
-
State
public State(java.lang.String name, State.Kind kind)
-
State
public State(java.util.Set<State> states, java.lang.String name)
-
State
public State(java.util.Set<State> states, java.lang.String name, State.Kind kind)
-
-
Method Detail
-
getKind
public State.Kind getKind()
Return the Kind of this state.
-
preAction
public FSM preAction(FSM fsm)
Method that defines action that occurs whenever this state is entered from a different state. preAction is not called on a self-transition. If preAction returns a non-null result, the result becomes the current FSM.Any exceptions except ThreadDeath thrown by this method are ignored. This method can be overridden in a state implementation if needed.
-
returnAction
public State returnAction(FSM fsm, FSM nestedFSM)
If this state has Kind REFERENCE, and its preAction pushes a nested FSM onto the stack, the returnAction method is called after the nested FSM reaches a final state. The nested FSM is passed into nestedFSM, and fsm is the new top of stack, which is the FSM that was active when the preAction was called. The result is the new state that will be assumed after this REFERENCE's state postAction method is called.If the returnAction method sets the state to a new state, the postAction method is called as usuTransition.
Any exceptions except ThreadDeath thrown by this method are ignored. This method can be overridden in a state implementation if needed.
-
postAction
public void postAction(FSM fsm)
Method that defines action that occurs whenever this state is exited, that is, when the state is changed from this state to a new state.Any exceptions except ThreadDeath thrown by this method are ignored. This method can be overridden in a state implementation if needed.
-
getDefaultNextState
public State getDefaultNextState()
Return the default next state for this state. This is the next state if the input is not found in the action map.
-
getDefaultAction
public Action getDefaultAction()
Get the default transition action that is used if the default next state is used.
-
getInputMap
public java.util.Map<Input,java.util.Set<Transition>> getInputMap()
-
setDefaultNextState
void setDefaultNextState(State defaultNextState)
-
setDefaultAction
void setDefaultAction(Action defaultAction)
-
addTransition
void addTransition(Input in, Transition ga)
-
getTransitions
java.util.Set<Transition> getTransitions(Input in)
-
-