sm
Class StateMachine.State.Transition

java.lang.Object
  extended bysm.StateMachine.State.Transition
Direct Known Subclasses:
StateMachine.State.Event, StateMachine.State.EventOnPosition, StateMachine.State.KeyTransition, StateMachine.State.TimeOut
Enclosing class:
StateMachine.State

public class StateMachine.State.Transition
extends java.lang.Object

A transition of a state machine.

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 handeled by a state machine. <eventtype> represents one of these classes and <parameters> the corresponding parameters. The complete list of events is given below, refer to the corresponding classes for further details.

<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.

The complete list of event types is:

Author:
Caroline Appert
See Also:
StateMachine

Constructor Summary
StateMachine.State.Transition(java.lang.String e)
          Constructs a transition with any modifier that loops on the current state.
StateMachine.State.Transition(java.lang.String e, int m)
          Constructs a transition with a modifier that loops on the current state.
StateMachine.State.Transition(java.lang.String e, int m, java.lang.String a)
          Constructs a transition with a modifier.
StateMachine.State.Transition(java.lang.String e, java.lang.String a)
          Constructs a transition with any modifier.
 
Method Summary
 void action()
          Method called when this transition is fired.
 int getModifier()
          Returns the modifier of the event that fires this transition.
 StateMachine.State getOutputStateName()
           
 SMVirtualEvent getVirtualEvent()
           
 boolean guard()
          Method called when an event matching this transition is received to decide whether it can be fired.
 java.lang.String hashKey()
          Returns the hashkey of this transition.
 java.lang.String oldToString()
           
 void setVirtualEvent(SMVirtualEvent virtualEvent)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StateMachine.State.Transition

public StateMachine.State.Transition(java.lang.String e,
                                     java.lang.String a)
Constructs a transition with any modifier.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click", "KeyPress", "KeyType", "KeyRelease", "Timeout" or "Gesture"*
a - The name of the output state

StateMachine.State.Transition

public StateMachine.State.Transition(java.lang.String e,
                                     int m,
                                     java.lang.String a)
Constructs a transition with a modifier.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click", "KeyPress", "KeyType", "KeyRelease", "Timeout" or "Gesture"*
m - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT
a - The name of the output state

StateMachine.State.Transition

public StateMachine.State.Transition(java.lang.String e)
Constructs a transition with any modifier that loops on the current state.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click", "KeyPress", "KeyType", "KeyRelease", "Timeout" or "Gesture"*

StateMachine.State.Transition

public StateMachine.State.Transition(java.lang.String e,
                                     int m)
Constructs a transition with a modifier that loops on the current state.

Parameters:
e - The string describing the events for which this transition must be triggered: "Down", "Motion", "Move", "Up", "Click", "KeyPress", "KeyType", "KeyRelease", "Timeout" or "Gesture"*
m - The modifier: NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT
Method Detail

getModifier

public int getModifier()
Returns the modifier of the event that fires this transition.

Returns:
Returns the modifier of the event that fires this transition (NOMODIFIER, CONTROL, ALT, SHIFT, ALT_CONTROL, CONTROL_SHIFT, ALT_SHIFT or ALT_CONTROL_SHIFT).

getOutputStateName

public StateMachine.State getOutputStateName()
Returns:
Returns the output state of this transition.

hashKey

public java.lang.String hashKey()
Returns the hashkey of this transition. Used for recording the transition in the state's hashtable.

Returns:
Returns the hashkey of this transition.

oldToString

public java.lang.String oldToString()

toString

public java.lang.String toString()

guard

public boolean guard()
Method called when an event matching this transition is received to decide whether it can be fired. This method always returns true. It can be redefined in subclasses, e.g.:
 	Transition t = new Press (BUTTON1) {
 		public boolean guard() { ... return true or false ... }
 	}
 

Returns:
True if this transition must be fired.

action

public void action()
Method called when this transition is fired. This method does nothing. It can be redefined in subclasses, e.g.:
 	Transition t = new Press (BUTTON1) {
 		public void action() { ... do something ... }
 	}
 


getVirtualEvent

public SMVirtualEvent getVirtualEvent()

setVirtualEvent

public void setVirtualEvent(SMVirtualEvent virtualEvent)