public final class NodeVariable extends Node
NodeVariable
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 allow Variable
objects to be used in an expression tree. The variable is unknown or has a value.Constructor and 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 a
Variable object. |
Modifier and Type | Method and 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() |
getDataTypeId, getKind, getUserData, isType, isType, setUserData
public NodeVariable(java.lang.String name, Value<Data> data)
name
- Variable name.data
- Dynamic value.java.lang.IllegalArgumentException
- if any of the arguments is null
.public NodeVariable(java.lang.String name, DataType type)
null
.name
- Variable name.type
- Variable type.java.lang.IllegalArgumentException
- if any of the arguments is null
.public NodeVariable(java.lang.String name, Data value)
name
- Variable name.value
- Variable value.java.lang.IllegalArgumentException
- if any of the arguments is null
.public static NodeVariable newInteger(java.lang.String name)
name
- Variable name.java.lang.IllegalArgumentException
- if the argument is null
.public static NodeVariable newReal(java.lang.String name)
name
- Variable name.java.lang.IllegalArgumentException
- if the argument is null
.public static NodeVariable newString(java.lang.String name)
name
- Variable name.java.lang.IllegalArgumentException
- if the argument is null
.public static NodeVariable newBoolean(java.lang.String name)
name
- Variable name.java.lang.IllegalArgumentException
- if the argument is null
.public static NodeVariable newUnknown(java.lang.String name)
name
- Variable name.java.lang.IllegalArgumentException
- if the argument is null
.public static NodeVariable newBitVector(java.lang.String name, int size)
name
- Variable name.size
- Bit vector size in bits.java.lang.IllegalArgumentException
- if the name
argument is null
or
if the size
argument is <= 0
.public static NodeVariable newMap(java.lang.String name, DataType keyType, DataType valueType)
name
- Variable name.keyType
- Key type.valueType
- Value type.java.lang.IllegalArgumentException
- if any of the arguments is null
.public Node deepCopy()
Node
public Variable getVariable()
public java.lang.String getName()
public Data getData()
public void setData(Data data)
data
- Data value to be assigned to the variable.java.lang.IllegalArgumentException
- if the argument is null
.public java.lang.Object getValue()
DataTypeId
enumeration for details on
internal representation of data objectspublic DataType getDataType()
Node
getDataType
in class Node
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object