Class Data


  • public final class Data
    extends java.lang.Object
    The Data class is a storage of data being processed. This data will be used as an input or an output parameter of a constraint solver.
    • Constructor Summary

      Constructors 
      Constructor Description
      Data​(DataType type, java.lang.Object value)
      Constructs a data object of the specified type and initializes its value with the specified value object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      static boolean equalTypes​(Data... args)
      Checks whether all Data objects in the specified array have equal types.
      static boolean equalValues​(Data... args)
      Checks whether all Data objects in the specified array have equal values.
      BitVector getBitVector()
      Returns a BitVector value stored in the data object.
      boolean getBoolean()
      Returns a boolean value stored in the data object.
      java.math.BigInteger getInteger()
      Returns a BigInteger value stored in the data object.
      DataMap getMap()
      Returns a DataMap value stored in the data object.
      double getReal()
      Returns a Double value stored in the data object.
      java.lang.String getString()
      Returns a String value stored in the data object.
      DataType getType()
      Returns information about the type of the stored value.
      java.lang.Object getUserData()
      Returns the value of the used-defined property.
      java.lang.Object getValue()
      Returns an object that holds the data.
      <T> T getValue​(java.lang.Class<T> clazz)
      Returns an object of given type that holds the data.
      int hashCode()  
      boolean hasValue()
      Checks whether a value assigned to the the data object.
      boolean isType​(DataType type)
      Checks whether the stored value has the specified type (comparison is based on DataType).
      boolean isType​(DataTypeId typeId)
      Checks whether the stored value has the specified type (comparison is based on DataTypeId).
      static Data newBitVector​(boolean value)
      Creates a data object of the BIT_VECTOR type from a boolean value.
      static Data newBitVector​(int value, int size)
      Creates a data object of the BIT_VECTOR type from an integer value.
      static Data newBitVector​(long value, int size)
      Creates a data object of the BIT_VECTOR type from a long integer value.
      static Data newBitVector​(java.lang.String bitVectorStr, int radix, int size)
      Creates a data object of the BIT_VECTOR type from a string.
      static Data newBitVector​(java.math.BigInteger value, int size)
      Creates a data object of the BIT_VECTOR type from a BigInteger object.
      static Data newBitVector​(BitVector value)
      Creates a data object of the BIT_VECTOR type from a BitVector object.
      static Data newBoolean​(boolean value)
      Creates a data object of the BOOLEAN type from a boolean value.
      static Data newInteger​(int value)
      Creates a data object of the INTEGER type from an integer value.
      static Data newInteger​(long value)
      Creates a data object of the INTEGER type from a long value.
      static Data newInteger​(java.lang.String text, int radix)
      Creates a data object of the INTEGER type from a string.
      static Data newInteger​(java.math.BigInteger value)
      Creates a data object of the INTEGER type from a BigInteger value.
      static Data newMap​(DataMap map)
      Creates a data object of the MAP type from the specified DataMap object.
      static Data newReal​(double value)
      Creates a data object of the REAL type from an double value.
      static Data newString​(java.lang.String value)
      Creates a data object of the STRING type from a String value.
      static Data newUnknown​(java.lang.Object value)
      Creates a data object from an object value of an unknown type (UNKNOWN will be used as target type).
      void setUserData​(java.lang.Object obj)
      Assigns value to the user-defined property.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Data

        public Data​(DataType type,
                    java.lang.Object value)
        Constructs a data object of the specified type and initializes its value with the specified value object.
        Parameters:
        type - The type of the data.
        value - An object of related type that stores the data.
        Throws:
        java.lang.IllegalArgumentException - if the type parameter is null.
    • Method Detail

      • newInteger

        public static Data newInteger​(java.math.BigInteger value)
        Creates a data object of the INTEGER type from a BigInteger value.
        Parameters:
        value - A BitInteger value.
        Returns:
        New data object.
        Throws:
        java.lang.IllegalArgumentException - if the parameter equals null.
      • newInteger

        public static Data newInteger​(long value)
        Creates a data object of the INTEGER type from a long value.
        Parameters:
        value - A long value.
        Returns:
        New data object.
      • newInteger

        public static Data newInteger​(int value)
        Creates a data object of the INTEGER type from an integer value.
        Parameters:
        value - An integer value.
        Returns:
        New data object.
      • newInteger

        public static Data newInteger​(java.lang.String text,
                                      int radix)
        Creates a data object of the INTEGER type from a string.
        Parameters:
        text - String to be parsed.
        radix - Radix to be used for parsing.
        Returns:
        New data object.
        Throws:
        java.lang.IllegalArgumentException - if the text parameter equals null.
        java.lang.NumberFormatException - if failed to parse the string.
      • newReal

        public static Data newReal​(double value)
        Creates a data object of the REAL type from an double value.
        Parameters:
        value - A double value.
        Returns:
        An new data object.
      • newString

        public static Data newString​(java.lang.String value)
        Creates a data object of the STRING type from a String value.
        Parameters:
        value - A String value.
        Returns:
        An new data object.
        Throws:
        java.lang.IllegalArgumentException - if the parameter equals null.
      • newBoolean

        public static Data newBoolean​(boolean value)
        Creates a data object of the BOOLEAN type from a boolean value.
        Parameters:
        value - A boolean value.
        Returns:
        A new data object.
      • newUnknown

        public static Data newUnknown​(java.lang.Object value)
        Creates a data object from an object value of an unknown type (UNKNOWN will be used as target type). Method for wrapping uninterpreted data that should not be passed to the solver.
        Parameters:
        value - A value of an unknown type.
        Returns:
        New data object.
      • newBitVector

        public static Data newBitVector​(java.math.BigInteger value,
                                        int size)
        Creates a data object of the BIT_VECTOR type from a BigInteger object.
        Parameters:
        value - A BigInteger object that stores binary data for a bit vector.
        size - The bit vector size (in bits).
        Returns:
        A new data object.
        Throws:
        java.lang.IllegalArgumentException - if the value parameter equals null.
      • newBitVector

        public static Data newBitVector​(BitVector value)
        Creates a data object of the BIT_VECTOR type from a BitVector object.
        Parameters:
        value - A BitVector object.
        Returns:
        A new data object.
        Throws:
        java.lang.IllegalArgumentException - if the value parameter equals null.
      • newBitVector

        public static Data newBitVector​(java.lang.String bitVectorStr,
                                        int radix,
                                        int size)
        Creates a data object of the BIT_VECTOR type from a string.
        Parameters:
        bitVectorStr - Textual representation of the bit vector.
        radix - Radix to be used for parsing.
        size - Size of the resulting bit vector in bits.
        Returns:
        A new data object.
        Throws:
        java.lang.IllegalArgumentException - if the s parameter equals null.
      • newBitVector

        public static Data newBitVector​(int value,
                                        int size)
        Creates a data object of the BIT_VECTOR type from an integer value.
        Parameters:
        value - Integer value to be converted.
        size - The bit vector size (in bits).
        Returns:
        A new data object.
      • newBitVector

        public static Data newBitVector​(long value,
                                        int size)
        Creates a data object of the BIT_VECTOR type from a long integer value.
        Parameters:
        value - Long integer value to be converted.
        size - The bit vector size (in bits).
        Returns:
        A new data object.
      • newBitVector

        public static Data newBitVector​(boolean value)
        Creates a data object of the BIT_VECTOR type from a boolean value.
        Parameters:
        value - Boolean value to be converted.
        Returns:
        A new data object.
      • newMap

        public static Data newMap​(DataMap map)
        Creates a data object of the MAP type from the specified DataMap object.
        Parameters:
        map - A DataMap object.
        Returns:
        A new data object.
        Throws:
        java.lang.IllegalArgumentException - if the map parameter equals null.
      • getType

        public DataType getType()
        Returns information about the type of the stored value.
        Returns:
        A DataType object.
      • hasValue

        public boolean hasValue()
        Checks whether a value assigned to the the data object.
        Returns:
        true if a value is assigned or false otherwise.
      • getValue

        public java.lang.Object getValue()
        Returns an object that holds the data.
        Returns:
        A type-dependent object that stores the data.
      • getValue

        public <T> T getValue​(java.lang.Class<T> clazz)
        Returns an object of given type that holds the data.
        Type Parameters:
        T - Type of the value object.
        Parameters:
        clazz - Class object that describes the type of the value object.
        Returns:
        A type-dependent object that stores the data.
      • getUserData

        public java.lang.Object getUserData()
        Returns the value of the used-defined property.
        Returns:
        User-defined object.
      • setUserData

        public void setUserData​(java.lang.Object obj)
        Assigns value to the user-defined property.
        Parameters:
        obj - User-defined 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
      • isType

        public boolean isType​(DataTypeId typeId)
        Checks whether the stored value has the specified type (comparison is based on DataTypeId).
        Parameters:
        typeId - DataTypeId object the data type is to be compared to.
        Returns:
        true if the type matches the type specified by the typeId argument or false otherwise.
      • isType

        public boolean isType​(DataType type)
        Checks whether the stored value has the specified type (comparison is based on DataType).
        Parameters:
        type - DataType object the data type is to be compared to.
        Returns:
        true if the type matches the type specified by the type argument or false otherwise.
      • getInteger

        public java.math.BigInteger getInteger()
        Returns a BigInteger value stored in the data object. Applicable to data objects of type DataTypeId.LOGIC_INTEGER.
        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 a BitVector value stored in the data object. Applicable to data objects of type DataTypeId.BIT_VECTOR.
        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 a boolean value stored in the data object. Applicable to data objects of type DataTypeId.LOGIC_BOOLEAN.
        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 a Double value stored in the data object. Applicable to data objects of type DataTypeId.LOGIC_REAL.
        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 a String value stored in the data object. Applicable to data objects of type DataTypeId.LOGIC_STRING.
        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 a DataMap value stored in the data object. Applicable to data objects of type DataTypeId.MAP.
        Returns:
        Stored value represented by a DataMap.
        Throws:
        java.lang.IllegalStateException - if the stored data is not convertible to DataMap.
      • equalValues

        public static boolean equalValues​(Data... args)
        Checks whether all Data objects in the specified array have equal values.
        Parameters:
        args - Array of Data objects to be checked.
        Returns:
        true if all objects have equal values or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments equals null.
      • equalTypes

        public static boolean equalTypes​(Data... args)
        Checks whether all Data objects in the specified array have equal types.
        Parameters:
        args - Array of Data objects to be checked.
        Returns:
        true if all objects have equal types or false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments equals null.