SMC
6_0_1

net.sf.smc.model
Class SmcTransition

java.lang.Object
  extended by net.sf.smc.model.SmcElement
      extended by net.sf.smc.model.SmcTransition
All Implemented Interfaces:
java.lang.Comparable<SmcTransition>

public final class SmcTransition
extends SmcElement
implements java.lang.Comparable<SmcTransition>

SMC breaks transitions into two components: this class and guard. This is done because a transition may appear multiple times in a state with different conditional guards. The only requirement is that the transition use the same name and parameters. Two transitions with the name name but different parameters is considered to be different transitions.

See Also:
SmcState, SmcGuard

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.smc.model.SmcElement
SmcElement.TransType
 
Field Summary
 
Fields inherited from class net.sf.smc.model.SmcElement
_lineNumber, _name, NIL_STATE
 
Constructor Summary
SmcTransition(java.lang.String name, java.util.List<SmcParameter> parameters, int lineNumber, SmcState state)
          Creates a transitions instance with the given name, parameters, line number and owning state.
 
Method Summary
 void accept(SmcVisitor visitor)
          Calls the visitor's visit method for this finite state machine element.
 void addGuard(SmcGuard guard)
          Adds a guard to the list.
 int compareTo(SmcTransition trans)
          Returns an interger value <, equal to or > than zero if this transition is <, = or > than trans.
 int compareTo(java.lang.String name, java.util.List<SmcParameter> parameters)
          Returns an interger value <, equal to or > than zero if this transition's name and parameters are <, = or > than name and parameters.
 boolean equals(java.lang.Object obj)
          Returns true if obj is a non-null transition instance with the same name and parameters; false otherwise.
 java.util.List<SmcGuard> getGuards()
          Returns the guard list.
 java.util.List<SmcParameter> getParameters()
          Returns the transition parameters.
 SmcState getState()
          Returns the transitions owning state.
 boolean hasCtxtReference()
          Returns true if this transition references the ctxt local variable and false otherwise.
 boolean hasNonNilEndState()
          Returns true if this transition has a guard with a non-nil end state and false otherwise.
 java.lang.String toString()
          Returns the transition text representation.
 
Methods inherited from class net.sf.smc.model.SmcElement
getLineNumber, getName, merge
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmcTransition

public SmcTransition(java.lang.String name,
                     java.util.List<SmcParameter> parameters,
                     int lineNumber,
                     SmcState state)
Creates a transitions instance with the given name, parameters, line number and owning state.

Parameters:
name - transition name.
parameters - transition parameters.
lineNumber - where this transition appears in the .sm file.
state - transition appears in this state.
Method Detail

accept

public void accept(SmcVisitor visitor)
Calls the visitor's visit method for this finite state machine element.

Specified by:
accept in class SmcElement
Parameters:
visitor - The visitor instance.
See Also:
SmcVisitor

compareTo

public int compareTo(SmcTransition trans)
              throws java.lang.ClassCastException
Returns an interger value <, equal to or > than zero if this transition is <, = or > than trans. This compararison is based on the transition name first and, if equal, then on the parameters.

Specified by:
compareTo in interface java.lang.Comparable<SmcTransition>
Parameters:
trans - the compared transition instance.
Returns:
an interger value <, equal to or > than zero if this transition is <, = or > than trans.
Throws:
java.lang.ClassCastException

getState

public SmcState getState()
Returns the transitions owning state.

Returns:
the transitions owning state.

getParameters

public java.util.List<SmcParameter> getParameters()
Returns the transition parameters.

Returns:
the transition parameters.

getGuards

public java.util.List<SmcGuard> getGuards()
Returns the guard list.

Returns:
the guard list.

hasCtxtReference

public boolean hasCtxtReference()
Returns true if this transition references the ctxt local variable and false otherwise.

Returns:
true if this transition references the ctxt local variable and false otherwise.

hasNonNilEndState

public boolean hasNonNilEndState()
Returns true if this transition has a guard with a non-nil end state and false otherwise.

Returns:
true if this transition has a guard with a non-nil end state and false otherwise.

addGuard

public void addGuard(SmcGuard guard)
Adds a guard to the list.

Parameters:
guard - add this guard.

equals

public boolean equals(java.lang.Object obj)
Returns true if obj is a non-null transition instance with the same name and parameters; false otherwise.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the compared object.
Returns:
true if obj is a non-null transition instance with the same name and parameters; false otherwise.

compareTo

public int compareTo(java.lang.String name,
                     java.util.List<SmcParameter> parameters)
Returns an interger value <, equal to or > than zero if this transition's name and parameters are <, = or > than name and parameters.

Parameters:
name - transition name.
parameters - transition parameters.
Returns:
an interger value <, equal to or > than zero if this transition's name and parameters are <, = or > than name and parameters.

toString

public java.lang.String toString()
Returns the transition text representation.

Overrides:
toString in class java.lang.Object
Returns:
the transition text representation.

SMC
6_0_1

Copyright © 2009. Charles W. Rapp. All Rights Reserved. Use is subject to license terms.