public abstract class Transition
extends java.lang.Object
This is an inner class of StateMachine.State
and is meant to
be used as follows:
Transition t = new <eventtype> (<parameters>, <output state>) { public boolean guard () { ... return True if transitions enabled ... } // optional public void action () { ... transition action ... } // optional }
The Transition
class has many derived classes corresponding to the various types of events that can be handled by a state machine.
<eventtype>
represents one of these classes and <parameters> the corresponding parameters.
<output state>
is the specification of the output state of the transition.
It is a string containing the name of the output state, which is, in general, the name of the
field of the state machine that holds the state (see class StateMachine.State).
In order to make it easier to spot the output state in the declaration, the name can be prefixed by
any combination of the following characters: -, =, > and space. This makes it possible to
specify a transition to state s2
with strings such as "-> s2", "==> s2", ">> s2"
, etc.
StateMachine
Modifier and Type | Method and Description |
---|---|
void |
action()
Method called when this transition is fired.
|
java.util.EventObject |
getEvent()
Returns the event that has just been received.
|
State |
getInputState() |
State |
getOutputState() |
boolean |
guard()
Method called when an event matching this transition
is received to decide whether it can be fired.
|
boolean |
manageEventID(int id) |
boolean |
matches(java.util.EventObject eventObject)
Tests if an event can trigger that transition.
|
java.lang.String |
oldToString() |
boolean |
pickingRequired() |
void |
setTriggeringEvent(java.util.EventObject triggeringEvent) |
public State getOutputState()
public State getInputState()
public boolean matches(java.util.EventObject eventObject)
eventObject
- The event to testeventObject
can trigger this transition.public java.lang.String oldToString()
public boolean guard()
Transition t = new Press (BUTTON1) { public boolean guard() { ... return true or false ... } }
public void action()
Transition t = new Press (BUTTON1) { public void action() { ... do something ... } }
public java.util.EventObject getEvent()
public void setTriggeringEvent(java.util.EventObject triggeringEvent)
triggeringEvent
- The event that has just triggered this transition.public boolean pickingRequired()
public boolean manageEventID(int id)