net.sf.smc
Class SmcAction

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

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

Actions are used in both transtions and state Entry and Exit clauses. Actions are implemented as methods in the FSM's context class.

Actions have two properties:

  1. Property: if this flag is true, then the action was a property assignment (var = value). This action is supported only for C# and VB.Net target compilation.
  2. Arguments: the action's arguments copied verbatim from the SMC code. The SMC parser does not attempt to interpret the actions beyond requiring that the arguments are a comma-separated list.


Field Summary
 
Fields inherited from class net.sf.smc.SmcElement
_lineNumber, _name
 
Constructor Summary
SmcAction(java.lang.String name, int lineNumber)
          Creates the named action appearing on the given .sm line.
SmcAction(java.lang.String name, int lineNumber, boolean propertyFlag, java.util.List<java.lang.String> arguments)
          Creates an action with all data members specified.
 
Method Summary
 void accept(SmcVisitor visitor)
          Pass this action to the visitor for processing.
 int compareTo(SmcAction action)
          Returns an integer value <, = or > zero depending on whether this action is <, = or > action.
 java.util.List<java.lang.String> getArguments()
          Returns the action's argument list.
 boolean isProperty()
          Returns true if this action is a .Net property assignment and false if not.
 void setArguments(java.util.List<java.lang.String> args)
          Sets the action's arguments.
 void setProperty(boolean flag)
          If flag is true, then this action is a .Net property assignment.
 java.lang.String toString()
          Returns a textual representation of this action.
 
Methods inherited from class net.sf.smc.SmcElement
getLineNumber, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmcAction

public SmcAction(java.lang.String name,
                 int lineNumber)
Creates the named action appearing on the given .sm line. The action has no arguments and is not a property assignment by default.

Parameters:
name - the action's name should correspond to the FSM context method.
lineNumber - where the action appears in the .sm file.

SmcAction

public SmcAction(java.lang.String name,
                 int lineNumber,
                 boolean propertyFlag,
                 java.util.List<java.lang.String> arguments)
          throws java.lang.IllegalArgumentException
Creates an action with all data members specified.

Parameters:
name - the action's name should correspond to the FSM context method.
lineNumber - where the action appears in the .sm file.
propertyFlag - if true, then this action is a .Net property assignment and arguments must be a non-null list with exactly one item.
args - the action's arguments. May be null.
Throws:
java.lang.IllegalArgumentException - if propertyFlag is true and arguments is either null or does not contain exactly one item.
Method Detail

isProperty

public boolean isProperty()
Returns true if this action is a .Net property assignment and false if not.

Returns:
true if this action is a .Net property assignment and false if not.

getArguments

public java.util.List<java.lang.String> getArguments()
Returns the action's argument list. May return null.

Returns:
the action's argument list. May return null.

setProperty

public void setProperty(boolean flag)
If flag is true, then this action is a .Net property assignment.

Parameters:
flag - if true, then this action is a .Net property assignment.

setArguments

public void setArguments(java.util.List<java.lang.String> args)
                  throws java.lang.IllegalArgumentException
Sets the action's arguments.

Parameters:
args - the action's arguments. May be null.
Throws:
java.lang.IllegalArgumentException - if this is a property action and arguments is either null or does not contain exactly one item.

compareTo

public int compareTo(SmcAction action)
Returns an integer value <, = or > zero depending on whether this action is <, = or > action.

Specified by:
compareTo in interface java.lang.Comparable<SmcAction>
Parameters:
action - comparison action object.
Returns:
an integer value <, = or > zero depending on whether this action is <, = or > action.

toString

public java.lang.String toString()
Returns a textual representation of this action. If this is a .Net property, the format is "<name> = <argument>". Otherwise the format is "<name>(<arg0>[, <argn>])".

Overrides:
toString in class java.lang.Object
Returns:
a textual representation of this action.

accept

public void accept(SmcVisitor visitor)
Pass this action to the visitor for processing. Part of the Visitor pattern.

Specified by:
accept in class SmcElement
Parameters:
visitor - the object implementing the visit(SmcElement) method.