public class Case extends CfgNode
This object can be either of default kind (and does not contain values)
or of non-default kind (and does contain values). If it is non-default,
this object stores values of the parent Switch
node's expression. So
these values MUST be of the same data type. If this object stores more than
one value, it means, that parent Switch
node can be equal to one of them.
childNode, parentNode
Constructor and Description |
---|
Case(boolean defaultNode)
Default constructor.
|
Case(java.util.Collection<ru.ispras.fortress.expression.NodeValue> values)
Constructs node with the specified possible values.
|
Case(java.util.Collection<ru.ispras.fortress.expression.NodeValue> values,
boolean defaultNode)
Constructs node with the specified values and default flag.
|
Case(ru.ispras.fortress.expression.NodeValue value)
Constructs node with the specified possible value.
|
Modifier and Type | Method and Description |
---|---|
void |
addParent(CfgModelNode node)
Adds parent node.
|
void |
addValue(ru.ispras.fortress.expression.NodeValue value)
Adds the specified value.
|
CfgModelNode |
deepCopy()
Returns a copy of this node.
|
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 node string description in the format of the specified printer.
|
CfgModelNode |
getOnlyChild()
Returns the only child node.
|
CfgModelNode |
getOnlyParent()
Returns the only parent node.
|
java.util.Collection<CfgModelNode> |
getParents()
Returns parent nodes.
|
CfgNodeType |
getType()
Returns node type.
|
java.util.Set<ru.ispras.fortress.expression.NodeVariable> |
getUses()
Returns a set of used variables.
|
java.util.Collection<ru.ispras.fortress.expression.NodeValue> |
getValues()
Returns node values.
|
boolean |
hasOnlyChild()
Checks rather node has exactly one child node.
|
boolean |
hasOnlyParent()
Checks rather node has exactly one parent node.
|
boolean |
hasParents()
Checks rather node has parent nodes.
|
boolean |
isDefault()
Checks rather case node is default.
|
void |
removeParent(CfgModelNode node)
Removes parent node.
|
addChild, equals, getChildren, getId, hasChildren, hashCode, removeChild
addMetaInfo, addMetaInfo, addMetaInfo, addMetaInfo, getMetaInfo, getMetaInfo, getMetaInfo, hasMetaInfo, hasMetaInfo, removeMetaInfo
public Case(boolean defaultNode)
Construct object with the specified default flag.
defaultNode
- default node typepublic Case(ru.ispras.fortress.expression.NodeValue value)
value
- valuejava.lang.IllegalArgumentException
- in the following situations:
(1) when argument is null
;
(2) when argument's data type differs from
Switch
parent node's condition data type (if parent node exists).public Case(java.util.Collection<ru.ispras.fortress.expression.NodeValue> values)
values
- valuesjava.lang.IllegalArgumentException
- in the following situations:
(1) when argument is null
;
(2) when at least one element of the argument has
DataType
data type that differs from one of the parent Switch
node's
condition;
(3) when elements of the argument do not have
the same DataType
data type.public Case(java.util.Collection<ru.ispras.fortress.expression.NodeValue> values, boolean defaultNode)
If values collection is non-empty,
than the default flag must be set to false
.
Otherwise the default flag must be set to true
.
values
- valuesdefaultNode
- default flagjava.lang.IllegalArgumentException
- in the following situations:
(1) when values argument is null
;
(2) when the contract noted above is not satisfied;
(3) when values does not have the same DataType
data type;
(4) when values data type is not equal to parent
Switch
node's condition data type.public boolean isDefault()
true
if node is default, false
otherwisepublic void addValue(ru.ispras.fortress.expression.NodeValue value)
The argument's data type MUST be equal to either Switch
parent node's
condition data type (if parent node exists)
or to all existing values data types (if exist).
value
- valuejava.lang.IllegalArgumentException
- in the following situations:
(1) when argument is null
;
(2) when argument has data type that differs from either
parent node's condition data type or from existing values data types.java.lang.IllegalStateException
- when the object is default.public java.util.Collection<ru.ispras.fortress.expression.NodeValue> getValues()
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)
CfgModelNode
getDescription
in interface CfgModelNode
getDescription
in class CfgNode
printer
- printerpublic CfgNodeType getType()
CfgModelNode
By default, node has CfgNodeType.UNKNOWN
type.
public void addParent(CfgModelNode node)
addParent
in interface CfgModelNode
addParent
in class CfgNode
node
- parent nodejava.lang.IllegalArgumentException
- in the following situations:
(1) when argument is null
;
(2) when the specified node
is not of Switch
type.java.lang.IllegalStateException
- when this object already
has non-null parent node.public void removeParent(CfgModelNode node)
removeParent
in interface CfgModelNode
removeParent
in class CfgNode
node
- parent nodejava.lang.IllegalArgumentException
- in the following situations:
(1) when argument is null
;
(2) when there is no such parent node in this object.public boolean hasParents()
CfgModelNode
hasParents
in interface CfgModelNode
hasParents
in class CfgNode
true
if node has at least one parent, false
otherwise.public boolean hasOnlyParent()
CfgModelNode
true
if node has exactly one parent at the moment, false
otherwise.public boolean hasOnlyChild()
CfgModelNode
true
if node has exactly one child at the moment, false
otherwise.public CfgModelNode getOnlyParent()
CfgModelNode
public java.util.Collection<CfgModelNode> getParents()
CfgModelNode
getParents
in interface CfgModelNode
getParents
in class CfgNode
public CfgModelNode getOnlyChild()
CfgModelNode
public java.util.Set<ru.ispras.fortress.expression.NodeVariable> getUses()
UseDef
public java.util.Set<ru.ispras.fortress.expression.NodeVariable> getDefines()
UseDef