Class NodeValue


  • public final class NodeValue
    extends Node
    The NodeValue class represents a node that stores a constant value. The class serves as an adapter to allow Data to be used in an expression.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class ru.ispras.fortress.expression.Node

        Node.Kind
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeValue​(Data data)
      Creates a value syntax element based on a data 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)  
      BitVector getBitVector()
      Returns stored BitVector 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 stored BigInteger 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 specified BigInteger 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 a BigInteger value.
      static NodeValue newMap​(DataMap value)
      Creates a new value node of the MAP type from the specified DataMap 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 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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 is null.
    • 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 a BigInteger value.
        Parameters:
        value - BigInteger value.
        Returns:
        New value node.
        Throws:
        java.lang.IllegalArgumentException - if the parameter equals null.
      • 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 the text parameter equals null.
        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 equals null.
      • 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 the value parameter equals null.
      • 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 the s argument is null; if the size 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 the size 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 the size 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 specified BigInteger value.
        Parameters:
        value - A BigInteger 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 the value argument equals null.
      • 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 specified DataMap object.
        Parameters:
        value - A DataMap object.
        Returns:
        A New value node.
        Throws:
        java.lang.IllegalArgumentException - if the map parameter equals null.
      • 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.
        Specified by:
        deepCopy in class Node
        Returns:
        Full copy of the current node object.
      • 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 is null.
      • 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 class Node
        Returns:
        A data type object.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getInteger

        public java.math.BigInteger getInteger()
        Returns stored BigInteger 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 to BigInteger.
      • getBitVector

        public BitVector getBitVector()
        Returns stored BitVector value and throws an exception if the stored value has a different type.
        Returns:
        Stored value represented by a BitVector.
        Throws:
        java.lang.IllegalStateException - if the stored data is not convertible to BitVector.
      • 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 to Boolean.
      • 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 to Double.
      • 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 to String.
      • getMap

        public DataMap getMap()
        Returns stored DataMap value and throws an exception if the stored value has a different type.
        Returns:
        Stored value represented by a DataMap.
        Throws:
        java.lang.IllegalStateException - if the stored data is not convertible to DataMap.