public abstract class State
extends java.lang.Object
This is an inner class of StateMachine
and is meant to be used as follows:
StateMachine sm = new StateMachine ("sm") { ... public State myState = new State() { ... declare transitions ... } ... }The string name of the state, which is used to specify output states in transitions, will be the name of the field (
"myState"
in this example).
For this to work, the field must be declared public.StateMachine
Constructor and Description |
---|
State()
Builds a new state.
|
State(java.lang.String n)
Builds a new state with a given name.
|
Modifier and Type | Method and Description |
---|---|
void |
addTransition(Transition t)
Adds a transition to this state.
|
void |
enter()
The method called when the parent state machine enters this state.
|
StateMachine |
getMachine() |
java.lang.String |
getName() |
java.util.LinkedList<Transition> |
getTransitions() |
void |
leave()
The method called when the parent state machine leaves this state.
|
java.lang.String |
oldToString() |
void |
removeTransition(Transition t)
Removes a transition from this state.
|
public State()
public State(java.lang.String n)
n
- The string name of the state, which is used to specify destination state in transitions.public java.lang.String getName()
public StateMachine getMachine()
public java.lang.String oldToString()
toString
default method.public java.util.LinkedList<Transition> getTransitions()
public void enter()
State s = new State () { public void enter () { ... do something ...} ... }
public void leave()
State s = new State () { public void leave () { ... do something ...} ... }
public final void addTransition(Transition t)
t
- the transition to add.public final void removeTransition(Transition t)
t
- the transition to remove.