nestedstate
Class NodeState
java.lang.Object
|
+--nestedstate.State
|
+--nestedstate.NodeState
- public class NodeState
- extends State
|
Constructor Summary |
NodeState(java.lang.String s)
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
NodeState
public NodeState(java.lang.String s)
addTransition
public void addTransition(LeafState to,
FSMEvent trigger,
FSMAction action)
- Adds a transition with this state as source and parameter to as a
target. Since this is a node state what really happens is that all the
child nodes get a transaction to the target state with the action.
- Parameters:
trigger - The event that triggers the transitionto - The target state.action - The associated action- Overrides:
- addTransition in class State
addTransition
public void addTransition(NodeState to,
FSMEvent trigger,
FSMAction action)
- Adds a transition with this state as source and parameter to as a
target. Since this is a node state what really happens is that all the
child nodes get a transaction to the target state with the action.
- Parameters:
trigger - The event that triggers the transitionto - The target state.action - The associated action- Overrides:
- addTransition in class State
addState
public void addState(State s)
- A nodestate must know what states it has.
setState
public void setState(State s)
- Sets the state s as the current state. If s is a NodeState, is the
default LeafState is found recursively first. Then that LeafState is
set as the current state for it's parent and that parent is set as the
current state for the parent's parent, etc. All the way up to the
root.
getState
public State getState()
- Returns:
- the current state.
getLowestDefaultLeaf
public static LeafState getLowestDefaultLeaf(LeafState l)
- Find out what the lowest default leaf is. Each NodeState has a default
state. If this default state is a NodeState, it is asked recursively
for its lowest default leaf state.
- Returns:
- The lowest default leaf.
getLowestDefaultLeaf
public static LeafState getLowestDefaultLeaf(NodeState n)
- Find out what the lowest default leaf is. Each NodeState has a default
state. If this default state is a NodeState, it is asked recursively
for its lowest default leaf state.
- Returns:
- The lowest default leaf.
setDefaultState
public void setDefaultState(State s)
getDefaultState
public State getDefaultState()
dispatch
public void dispatch(FSMEvent trigger,
java.lang.Object data,
FSMContext fsmc)
- Dispatch an event. Since this is a node state, this means dispatch it
to the current state of the embedded machine. This state knows how to
handle the event.
- Parameters:
trigger - The event that needs to be dispatched. The correct
transition is located and than executed.data - Some additional data that may be needed by the actionfsmc - The context in which the action is executed. This may be
useful for retrieving global variables.- Overrides:
- dispatch in class State
getEvents
public java.util.Vector getEvents()
- Method to find out which events can be dispatched by this state.
- Returns:
- A vector with the events
- Overrides:
- getEvents in class State
toString
public java.lang.String toString()
- Returns:
- a string describing the current state in the form
name->childname->child's childname-> ...
- Overrides:
- toString in class State