Package ru.ispras.fortress.expression
Class NodeVariable
- java.lang.Object
-
- ru.ispras.fortress.expression.Node
-
- ru.ispras.fortress.expression.NodeVariable
-
public final class NodeVariable extends Node
TheNodeVariable
class represents a node that refers to a variable which is specified as an attribute of a constraint. The class serves as an adapter to allowVariable
objects to be used in an expression tree. The variable is unknown or has a value.
-
-
Constructor Summary
Constructors Constructor Description NodeVariable(java.lang.String name, Data value)
Constructs a node for a variable that holds the specified value.NodeVariable(java.lang.String name, DataType type)
Constructs a node for an uninitialized variable of the specified type.NodeVariable(java.lang.String name, Value<Data> data)
Constructs a node variable from its name and associated dynamic data.NodeVariable(Variable variable)
Creates a node based on aVariable
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Node
deepCopy()
Creates a deep copy of the current objects.boolean
equals(java.lang.Object obj)
Data
getData()
Returns the data object that encapsulates the variable value.DataType
getDataType()
Returns an object that describes the type of the value referred by the node.java.lang.String
getName()
Returns the name of the variable.java.lang.Object
getValue()
Returns an object that stores a data value if any value was assigned to the variable (it is a known variable) or null if it is an unknown variable.Variable
getVariable()
Returns the variable associated with the node.int
hashCode()
static NodeVariable
newBitVector(java.lang.String name, int size)
Creates a new bit vector variable.static NodeVariable
newBoolean(java.lang.String name)
Creates a new boolean variable.static NodeVariable
newInteger(java.lang.String name)
Creates a new integer variable.static NodeVariable
newMap(java.lang.String name, DataType keyType, DataType valueType)
Creates a map-based variable.static NodeVariable
newReal(java.lang.String name)
Creates a new real variable.static NodeVariable
newString(java.lang.String name)
Creates a new string variable.static NodeVariable
newUnknown(java.lang.String name)
Creates a new variable of unknown type.void
setData(Data data)
Assigns new data value to the variable.java.lang.String
toString()
-
Methods inherited from class ru.ispras.fortress.expression.Node
deepestCopy, getDataTypeId, getKind, getUserData, isType, isType, isType, isType, setUserData
-
-
-
-
Constructor Detail
-
NodeVariable
public NodeVariable(java.lang.String name, Value<Data> data)
Constructs a node variable from its name and associated dynamic data. Used for creating context-dependent variables.- Parameters:
name
- Variable name.data
- Dynamic value.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
.
-
NodeVariable
public NodeVariable(java.lang.String name, DataType type)
Constructs a node for an uninitialized variable of the specified type. The constructed variable does not hold any data and its value is set tonull
.- Parameters:
name
- Variable name.type
- Variable type.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
.
-
NodeVariable
public NodeVariable(java.lang.String name, Data value)
Constructs a node for a variable that holds the specified value.- Parameters:
name
- Variable name.value
- Variable value.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
.
-
-
Method Detail
-
newInteger
public static NodeVariable newInteger(java.lang.String name)
Creates a new integer variable.- Parameters:
name
- Variable name.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
newReal
public static NodeVariable newReal(java.lang.String name)
Creates a new real variable.- Parameters:
name
- Variable name.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
newString
public static NodeVariable newString(java.lang.String name)
Creates a new string variable.- Parameters:
name
- Variable name.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
newBoolean
public static NodeVariable newBoolean(java.lang.String name)
Creates a new boolean variable.- Parameters:
name
- Variable name.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
newUnknown
public static NodeVariable newUnknown(java.lang.String name)
Creates a new variable of unknown type.- Parameters:
name
- Variable name.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
newBitVector
public static NodeVariable newBitVector(java.lang.String name, int size)
Creates a new bit vector variable.- Parameters:
name
- Variable name.size
- Bit vector size in bits.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if thename
argument isnull
or if thesize
argument is<= 0
.
-
newMap
public static NodeVariable newMap(java.lang.String name, DataType keyType, DataType valueType)
Creates a map-based variable.- Parameters:
name
- Variable name.keyType
- Key type.valueType
- Value type.- Returns:
- New variable node.
- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
.
-
deepCopy
public Node deepCopy()
Description copied from class:Node
Creates a deep copy of the current objects. All aggregated objects that are not readonly must be cloned. This excludes user data as its type is unknown.
-
getVariable
public Variable getVariable()
Returns the variable associated with the node.- Returns:
- Variable associated with the node.
-
getName
public java.lang.String getName()
Returns the name of the variable.- Returns:
- The variable name.
-
getData
public Data getData()
Returns the data object that encapsulates the variable value.- Returns:
- A data object.
-
setData
public void setData(Data data)
Assigns new data value to the variable.- Parameters:
data
- Data value to be assigned to the variable.- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
getValue
public java.lang.Object getValue()
Returns an object that stores a data value if any value was assigned to the variable (it is a known variable) or null if it is an unknown variable. The exact type of the object returned by the method depends on the implementation. Please see theDataTypeId
enumeration for details on internal representation of data objects- Returns:
- Object that stores the variable value if it is assigned or null otherwise
-
getDataType
public DataType getDataType()
Description copied from class:Node
Returns an object that describes the type of the value referred by the node.- Specified by:
getDataType
in classNode
- Returns:
- A data type object.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-