com.evelopers.unimod.core.stateworks
Class Guard

java.lang.Object
  extended bycom.evelopers.unimod.core.ModelElement
      extended bycom.evelopers.unimod.core.stateworks.Guard
All Implemented Interfaces:
java.io.Serializable

public class Guard
extends ModelElement

Contains guard condition. Parses given logical expression into Abstract Syntax Tree for futher interpreting.

Guard condition expression must sutisfy the following gramma:


	S  -> S '||' I1
	S  -> I1
	I1 -> I1 '&&' I2
	I1 -> I2
	I2 -> '!' I3
	I2 -> I3
	I3 -> '(' S ')'
	I3 -> I4
	I4 -> I5 rel I5
	I4 -> ident_bool
	I4 -> const_bool
	I5 -> ident_number
	I5 -> const_number
 
Where rel is one of '>', '<', '>=', '<=', '!=', '=='

See Also:
com.evelopers.unimod.parser.ExprParser, Serialized Form

Field Summary
static Guard ELSE
          Else Guard
static java.lang.String ELSE_EXPR
          Expression for else guard
static java.lang.String EXPR_PROPERTY
           
static Guard TRUE
          True Guard
static java.lang.String TRUE_EXPR
          Guard with empty expression will be interpreted as "true".
 
Fields inherited from class com.evelopers.unimod.core.ModelElement
listeners, name, NAME_PROPERTY, stereotype, STEREOTYPE_PROPERTY
 
Constructor Summary
protected Guard(java.lang.String expr)
          Creates gruard condition based on given logical expression.
 
Method Summary
 boolean equals(java.lang.Object o)
          Two guards equal if their expr equal
 antlr.collections.AST getAST()
          Returns Abstract Syntax Tree (AST)
 java.lang.String getExpr()
          Return guard condition logical expression.
 java.util.Set getInputActions()
          Returns set of input actions, that is being used in guard condiiton.
 int hashCode()
          Takes hashcode from expr
 void setAST(antlr.collections.AST ast)
          Sets abstract syntax tree.
 void setExpr(java.lang.String expr)
          Sets guard condition logical expression
 void setInputActions(java.util.Set inputActions)
           
 java.lang.String toString()
          Returns guard condition string representation.
 
Methods inherited from class com.evelopers.unimod.core.ModelElement
accept, addPropertyChangeListener, firePropertyChange, getName, getStereotype, initListeners, removePropertyChangeListener, setName, setStereotype
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EXPR_PROPERTY

public static final java.lang.String EXPR_PROPERTY
See Also:
Constant Field Values

TRUE_EXPR

public static final java.lang.String TRUE_EXPR
Guard with empty expression will be interpreted as "true".

See Also:
Constant Field Values

TRUE

public static final Guard TRUE
True Guard


ELSE_EXPR

public static final java.lang.String ELSE_EXPR
Expression for else guard

See Also:
Constant Field Values

ELSE

public static final Guard ELSE
Else Guard

Constructor Detail

Guard

protected Guard(java.lang.String expr)
Creates gruard condition based on given logical expression. Treats null expression as true.

Parameters:
expr - guard condition logical expression. Null will be converted to true.
Method Detail

getAST

public antlr.collections.AST getAST()
Returns Abstract Syntax Tree (AST)

Returns:
Abstract Syntax Tree

setAST

public void setAST(antlr.collections.AST ast)
Sets abstract syntax tree. This method should be used only by compiler

Parameters:
ast - abstract syntax tree

getExpr

public java.lang.String getExpr()
Return guard condition logical expression.

Returns:
guard condition logical expression

setInputActions

public void setInputActions(java.util.Set inputActions)
Parameters:
inputActions - The inputActions to set.

getInputActions

public java.util.Set getInputActions()
Returns set of input actions, that is being used in guard condiiton. Returns null, if Guard was not yet coimpiled.

Returns:

setExpr

public void setExpr(java.lang.String expr)
Sets guard condition logical expression

Parameters:
expr - new logical expression to set

toString

public java.lang.String toString()
Returns guard condition string representation.

Overrides:
toString in class ModelElement
Returns:
guard condition string representation

equals

public boolean equals(java.lang.Object o)
Two guards equal if their expr equal

Specified by:
equals in class ModelElement
Parameters:
o - guard to compare with this
Returns:
whether guards are equal

hashCode

public int hashCode()
Takes hashcode from expr

Specified by:
hashCode in class ModelElement
Returns:
hash code