public class Switch extends CfgNode
This node represents conditional block. It's Case
children contain possible values
of the condition expression. Also this block may be of event type, when it's condition
is true
, but it can be executed only when the specified event
Event
happens.
Note thar every Case
child of this node MUST have NodeValue
values
of the same data type that this object's Node
condition has.
When executed, only one output node will be active.
childNode, parentNode
Constructor and Description |
---|
Switch(Event event)
Constructs an object with the specified event.
|
Switch(ru.ispras.fortress.expression.Node condition)
Constructs an object with the specified condition.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(CfgModelNode node)
Adds the specified child node.
|
CfgModelNode |
deepCopy()
Returns a copy of this node.
|
java.util.Collection<CfgModelNode> |
getChildren()
Return child nodes.
|
ru.ispras.fortress.expression.Node |
getCondition()
Returns
Node condition. |
java.util.Set<ru.ispras.fortress.expression.NodeVariable> |
getDefines()
Returns a set of defined variables.
|
java.lang.String |
getDescription(ru.ispras.fortress.expression.printer.ExprTreePrinter printer)
Returns a string description in the format of the specified printer.
|
Event |
getEvent()
Returns event.
|
CfgModelNode |
getOnlyChild()
Returns the only child node.
|
CfgModelNode |
getOnlyParent()
Returns the only parent node.
|
CfgNodeType |
getType()
Returns node type.
|
java.util.Set<ru.ispras.fortress.expression.NodeVariable> |
getUses()
Returns a set of used variables.
|
boolean |
hasChildren()
Checks rather node has child nodes.
|
boolean |
hasOnlyChild()
Checks rather node has exactly one child node.
|
boolean |
hasOnlyParent()
Checks rather node has exactly one parent node.
|
void |
removeChild(CfgModelNode node)
Removes child node.
|
void |
setCondition(ru.ispras.fortress.expression.Node expr)
Sets new
Node condition. |
addParent, equals, getId, getParents, hashCode, hasParents, removeParent
addMetaInfo, addMetaInfo, addMetaInfo, addMetaInfo, getMetaInfo, getMetaInfo, getMetaInfo, hasMetaInfo, hasMetaInfo, removeMetaInfo
public Switch(ru.ispras.fortress.expression.Node condition)
condition
- switch conditionjava.lang.IllegalArgumentException
- when argument is null
.public Switch(Event event)
The condition is set to NodeValue.newBoolean(true)
.
event
- eventjava.lang.IllegalArgumentException
- when argument is null
.public ru.ispras.fortress.expression.Node getCondition()
Node
condition.public void setCondition(ru.ispras.fortress.expression.Node expr)
Node
condition.expr
- expressionjava.lang.IllegalArgumentException
- when argument is either null
or not of the same DataType
data type
that its children Case
nodes have.public Event getEvent()
public CfgModelNode deepCopy()
CfgModelNode
The copy does not keep the same links to parent or child nodes as this has.
public java.lang.String getDescription(ru.ispras.fortress.expression.printer.ExprTreePrinter printer)
getDescription
in interface CfgModelNode
getDescription
in class CfgNode
printer
- printer that provides an output string formatjava.lang.IllegalArgumentException
- when argument is null
.public CfgNodeType getType()
CfgModelNode
By default, node has CfgNodeType.UNKNOWN
type.
public boolean hasOnlyParent()
CfgModelNode
true
if node has exactly one parent at the moment, false
otherwise.public boolean hasChildren()
CfgModelNode
hasChildren
in interface CfgModelNode
hasChildren
in class CfgNode
true
if node has at least one child, false
otherwise.public boolean hasOnlyChild()
CfgModelNode
true
if node has exactly one child at the moment, false
otherwise.public CfgModelNode getOnlyParent()
CfgModelNode
public CfgModelNode getOnlyChild()
CfgModelNode
public void addChild(CfgModelNode node)
addChild
in interface CfgModelNode
addChild
in class CfgNode
node
- child nodejava.lang.IllegalArgumentException
- in the following situations: (1) argument is either
null
or not of Case
type;
(2) when at least one NodeValue
value of Case
child
argument has DataType
which is not equal to the data type of condition.public void removeChild(CfgModelNode node)
removeChild
in interface CfgModelNode
removeChild
in class CfgNode
node
- child nodejava.lang.IllegalArgumentException
- when argument is either null
or is not of Case
type.public java.util.Collection<CfgModelNode> getChildren()
CfgModelNode
getChildren
in interface CfgModelNode
getChildren
in class CfgNode
public java.util.Set<ru.ispras.fortress.expression.NodeVariable> getUses()
UseDef
public java.util.Set<ru.ispras.fortress.expression.NodeVariable> getDefines()
UseDef