Package ru.ispras.fortress.expression
Class NodeValue
- java.lang.Object
-
- ru.ispras.fortress.expression.Node
-
- ru.ispras.fortress.expression.NodeValue
-
public final class NodeValue extends Node
TheNodeValue
class represents a node that stores a constant value. The class serves as an adapter to allow Data to be used in an expression.
-
-
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)
BitVector
getBitVector()
Returns storedBitVector
value and throws an exception if the stored value has a different type.boolean
getBoolean()
Returns stored boolean value and throws an exception if the stored value has a different type.Data
getData()
Returns the data object that encapsulates the value.DataType
getDataType()
Returns an object that describes the type of the value referred by the node.java.math.BigInteger
getInteger()
Returns storedBigInteger
value and throws an exception if the stored value has a different type.DataMap
getMap()
Returns stored DataMap value and throws an exception if the stored value has a different type.double
getReal()
Returns stored Double value and throws an exception if the stored value has a different type.java.lang.String
getString()
Returns stored String value and throws an exception if the stored value has a different type.java.lang.Object
getValue()
Returns an object that stores a data value.int
hashCode()
static NodeValue
newBitVector(boolean value)
Creates a new value node based on a bit vector constructed from the specified boolean value.static NodeValue
newBitVector(int value, int size)
Creates a new value node based on a bit vector of the specified size constructed from the specified integer value.static NodeValue
newBitVector(long value, int size)
Creates a new value node based on a bit vector of the specified size constructed from the specified long value.static NodeValue
newBitVector(java.lang.String text, int radix, int size)
Creates a new value node based on a bit vector of the specified size constructed from a textual representation.static NodeValue
newBitVector(java.math.BigInteger value, int size)
Creates a new value node based on a bit vector of the specified size constructed from the specifiedBigInteger
value.static NodeValue
newBitVector(BitVector value)
Creates a new value node based on a bit vector.static NodeValue
newBoolean(boolean value)
Creates a new value node based on a boolean value.static NodeValue
newInteger(int value)
Creates a new value node based on an integer value.static NodeValue
newInteger(java.lang.String text, int radix)
Creates a new value node based on a textual representation of an integer value.static NodeValue
newInteger(java.math.BigInteger value)
Creates a new value node based on aBigInteger
value.static NodeValue
newMap(DataMap value)
Creates a new value node of the MAP type from the specifiedDataMap
object.static NodeValue
newReal(double value)
Creates a new value node based on a double value.static NodeValue
newString(java.lang.String value)
Creates a new value node based on a String value.static NodeValue
newUnknown(java.lang.Object value)
Creates a new value node based on a value of an unknown type.void
setData(Data data)
Changes the data value associated with the node.java.lang.String
toString()
-
Methods inherited from class ru.ispras.fortress.expression.Node
deepestCopy, getDataTypeId, getKind, getUserData, isType, isType, isType, isType, setUserData
-
-
-
-
Constructor Detail
-
NodeValue
public NodeValue(Data data)
Creates a value syntax element based on a data object.- Parameters:
data
- A data object.- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
-
Method Detail
-
newInteger
public static NodeValue newInteger(int value)
Creates a new value node based on an integer value.- Parameters:
value
- Integer value.- Returns:
- New value node.
-
newInteger
public static NodeValue newInteger(java.math.BigInteger value)
Creates a new value node based on aBigInteger
value.- Parameters:
value
-BigInteger
value.- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if the parameter equalsnull
.
-
newInteger
public static NodeValue newInteger(java.lang.String text, int radix)
Creates a new value node based on a textual representation of an integer value.- Parameters:
text
- String to be parsed.radix
- Radix to be used to parsing.- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if thetext
parameter equalsnull
.java.lang.NumberFormatException
- if failed to parse the string.
-
newReal
public static NodeValue newReal(double value)
Creates a new value node based on a double value.- Parameters:
value
- Double value.- Returns:
- New value node.
-
newString
public static NodeValue newString(java.lang.String value)
Creates a new value node based on a String value.- Parameters:
value
- String value.- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if the parameter equalsnull
.
-
newBoolean
public static NodeValue newBoolean(boolean value)
Creates a new value node based on a boolean value.- Parameters:
value
- Boolean value.- Returns:
- New value node.
-
newUnknown
public static NodeValue newUnknown(java.lang.Object value)
Creates a new value node based on a value of an unknown type.- Parameters:
value
- Value of an unknown type.- Returns:
- New value node.
-
newBitVector
public static NodeValue newBitVector(BitVector value)
Creates a new value node based on a bit vector.- Parameters:
value
-BitVector
value.- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if thevalue
parameter equalsnull
.
-
newBitVector
public static NodeValue newBitVector(java.lang.String text, int radix, int size)
Creates a new value node based on a bit vector of the specified size constructed from a textual representation.- Parameters:
text
- Textual representation of the bit vector.radix
- Radix to be used for text parsing.size
- Size of the resulting bit vector in bits.- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if thes
argument isnull
; if thesize
argument is zero or negative.
-
newBitVector
public static NodeValue newBitVector(int value, int size)
Creates a new value node based on a bit vector of the specified size constructed from the specified integer value.- Parameters:
value
- An integer value that represents binary data of the bit vector.size
- The bit vector size (in bits).- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if thesize
argument is zero or negative.
-
newBitVector
public static NodeValue newBitVector(long value, int size)
Creates a new value node based on a bit vector of the specified size constructed from the specified long value.- Parameters:
value
- An long value that represents binary data of the bit vector.size
- The bit vector size (in bits).- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if thesize
argument is zero or negative.
-
newBitVector
public static NodeValue newBitVector(java.math.BigInteger value, int size)
Creates a new value node based on a bit vector of the specified size constructed from the specifiedBigInteger
value.- Parameters:
value
- ABigInteger
object that stores binary data for a bit vector.size
- The bit vector size (in bits).- Returns:
- New value node.
- Throws:
java.lang.IllegalArgumentException
- if thevalue
argument equalsnull
.
-
newBitVector
public static NodeValue newBitVector(boolean value)
Creates a new value node based on a bit vector constructed from the specified boolean value.- Parameters:
value
- Boolean value to be converted to a bit vector.- Returns:
- New value node.
-
newMap
public static NodeValue newMap(DataMap value)
Creates a new value node of the MAP type from the specifiedDataMap
object.- Parameters:
value
- ADataMap
object.- Returns:
- A New value node.
- Throws:
java.lang.IllegalArgumentException
- if themap
parameter equalsnull
.
-
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.
-
getData
public Data getData()
Returns the data object that encapsulates the value.- Returns:
- A data object.
-
setData
public void setData(Data data)
Changes the data value associated with the node.- Parameters:
data
- New data value to be associated with the node.- Throws:
java.lang.IllegalArgumentException
- if the argument isnull
.
-
getValue
public java.lang.Object getValue()
Returns an object that stores a data value. The exact type of the object returned by the method depends on the data type.- Returns:
- An object that store the value of the constant.
-
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
-
getInteger
public java.math.BigInteger getInteger()
Returns storedBigInteger
value and throws an exception if the stored value has a different type.- Returns:
- Stored value represented by a
BigInteger
. - Throws:
java.lang.IllegalStateException
- if the stored data is not convertible toBigInteger
.
-
getBitVector
public BitVector getBitVector()
Returns storedBitVector
value and throws an exception if the stored value has a different type.
-
getBoolean
public boolean getBoolean()
Returns stored boolean value and throws an exception if the stored value has a different type.- Returns:
- Stored value represented by a boolean.
- Throws:
java.lang.IllegalStateException
- if the stored data is not convertible toBoolean
.
-
getReal
public double getReal()
Returns stored Double value and throws an exception if the stored value has a different type.- Returns:
- Stored value represented by a Double.
- Throws:
java.lang.IllegalStateException
- if the stored data is not convertible toDouble
.
-
getString
public java.lang.String getString()
Returns stored String value and throws an exception if the stored value has a different type.- Returns:
- Stored value represented by a String.
- Throws:
java.lang.IllegalStateException
- if the stored data is not convertible toString
.
-
-