Top Description Inners Fields Constructors Methods
org.glassfish.pfl.basic.fsm

public Class State

extends NameBase
Class Inheritance
Imports
java.util.Collections, .HashMap, .HashSet, .Map, .Set

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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
State.Kind

Kind of state.

Field Summary

Modifier and TypeField and Description
private Action
private State
private Map<Input, Set<Transition>>
private Map<Input, Set<Transition>>
private Map<Input, Set<Transition>>
private State.Kind

Constructor Summary

AccessConstructor and Description
public
State(String name)

public
State(String name, State.Kind kind)

public
State(Set<State> states, String name)

public
State(Set<State> states, String name, State.Kind kind)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public Action
getDefaultAction()

Get the default transition action that is used if the default next state is used.

public State
getDefaultNextState()

Return the default next state for this state.

public Map<Input, Set<Transition>>
public State.Kind
getKind()

Return the Kind of this state.

pack-priv Set<Transition>
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.

public FSM
preAction(FSM fsm)

Method that defines action that occurs whenever this state is entered from a different state.

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.

pack-priv void
setDefaultAction(Action defaultAction)

pack-priv void
setDefaultNextState(State defaultNextState)

Inherited from org.glassfish.pfl.basic.fsm.NameBase:
getNametoString

Field Detail

defaultActionback to summary
private Action defaultAction
defaultNextStateback to summary
private State defaultNextState
inputMapback to summary
private Map<Input, Set<Transition>> inputMap
inputMapImageback to summary
private Map<Input, Set<Transition>> inputMapImage
inputMapRangeImageback to summary
private Map<Input, Set<Transition>> inputMapRangeImage
kindback to summary
private State.Kind kind

Constructor Detail

Stateback to summary
public State(String name)
Stateback to summary
public State(String name, State.Kind kind)
Stateback to summary
public State(Set<State> states, String name)
Stateback to summary
public State(Set<State> states, String name, State.Kind kind)

Method Detail

addTransitionback to summary
pack-priv void addTransition(Input in, Transition ga)
getDefaultActionback to summary
public Action getDefaultAction()

Get the default transition action that is used if the default next state is used.

getDefaultNextStateback to summary
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.

getInputMapback to summary
public Map<Input, Set<Transition>> getInputMap()
getKindback to summary
public State.Kind getKind()

Return the Kind of this state.

getTransitionsback to summary
pack-priv Set<Transition> getTransitions(Input in)
postActionback to summary
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.

preActionback to summary
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.

returnActionback to summary
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.

setDefaultActionback to summary
pack-priv void setDefaultAction(Action defaultAction)
setDefaultNextStateback to summary
pack-priv void setDefaultNextState(State defaultNextState)
org.glassfish.pfl.basic.fsm back to summary

public final Enum State.Kind

extends Enum<State.Kind>
Class Inheritance

Kind of state. A StateEngine must have at least one INITIAL state. An FSM may only be created in an INITIAL state. It may have 0 or more FINAL states. A FINAL state may only be the target of a state transition. If a state engine is used as a submachine, it must have at least one final state.

A REFERENCE state is handled specially. It is used to call into another state engine much as a normal subroutine call. A REFERENCE state (like a FINAL state) may not have any transitions that leave it. The returnAction method on a REFERENCE state is responsible for setting the state directly.

Field Summary

Modifier and TypeField and Description
public static final State.Kind
public static final State.Kind
public static final State.Kind
public static final State.Kind

Constructor Summary

AccessConstructor and Description
private
Kind()

Method Summary

Modifier and TypeMethod and Description
public static State.Kind
public static State.Kind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FINALback to summary
public static final State.Kind FINAL
INITIALback to summary
public static final State.Kind INITIAL
NORMALback to summary
public static final State.Kind NORMAL
REFERENCEback to summary
public static final State.Kind REFERENCE

Constructor Detail

Kindback to summary
private Kind()

Method Detail

valueOfback to summary
public static State.Kind valueOf(String name)
valuesback to summary
public static State.Kind[] values()