Package ru.ispras.fortress.data
Class DataType
- java.lang.Object
-
- ru.ispras.fortress.data.DataType
-
public final class DataType extends java.lang.Object
TheDataType
class stores information about data types used by the solver engine. It maintains a single instance for each data type (uniqueness is based on the data type identifier and the data size).
-
-
Field Summary
Fields Modifier and Type Field Description static DataType
BOOLEAN
Predefined logic boolean data type.static DataType
INTEGER
Predefined logic integer data type.static int
LOGIC_TYPE_SIZE
TheLOGIC_TYPE_SIZE
constant specifies the size of logic data types.static DataType
REAL
Predefined logic real data type.static DataType
STRING
Predefined logic string data type.static DataType
UNKNOWN
Predefined unknown data type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataType
bitVector(int size)
Returns a data type describing a bit vector of the specified size.boolean
equals(java.lang.Object obj)
java.lang.Object
getAttribute(DataTypeId.Attribute attr)
java.lang.Object[]
getParameters()
int
getSize()
Returns the size of binary data in bits.DataTypeId
getTypeId()
Returns a data type identifier.int
getTypeRadix()
Returns a radix to be used for conversion data of this type to a string or vice versa.java.lang.Class<?>
getValueClass()
Returns the class that is used to store data (internal representation).int
hashCode()
boolean
isTypeId(DataTypeId typeId)
Checks whether the specified data type identifier is used.static DataType
map(DataType keyType, DataType valueType)
Returns a data type describing a map that uses key and values of the specified data type.static DataType
newDataType(DataTypeId typeId, int size)
Returns a data type for the specified data type identifier and data size.static DataType
newDataType(DataTypeId typeId, java.lang.Object... parameters)
Returns an instance of a data type object based on its attributes.java.lang.String
toString()
static DataType
typeOf(java.lang.String text)
Creates an instance of a data type from the its textual representation.Data
valueOf(java.lang.String value, int radix)
Creates an instance of a data object of a corresponding data type.Data
valueUninitialized()
Creates an uninitialized data object (the value is set to null).
-
-
-
Field Detail
-
LOGIC_TYPE_SIZE
public static final int LOGIC_TYPE_SIZE
TheLOGIC_TYPE_SIZE
constant specifies the size of logic data types. Such types are not related with machine-dependent types and can have any size. For this reason, we specify it as zero to distinguish from types that describe real data.- See Also:
- Constant Field Values
-
INTEGER
public static final DataType INTEGER
Predefined logic integer data type.
-
REAL
public static final DataType REAL
Predefined logic real data type.
-
STRING
public static final DataType STRING
Predefined logic string data type.
-
BOOLEAN
public static final DataType BOOLEAN
Predefined logic boolean data type.
-
UNKNOWN
public static final DataType UNKNOWN
Predefined unknown data type.
-
-
Method Detail
-
bitVector
public static DataType bitVector(int size)
Returns a data type describing a bit vector of the specified size. For bit vectors of the same size, the same instances are returned.- Parameters:
size
- Bit vector size in bits.- Returns:
- Bit vector data type.
-
map
public static DataType map(DataType keyType, DataType valueType)
Returns a data type describing a map that uses key and values of the specified data type. For maps with matching key and value data types, the same instances are returned.- Parameters:
keyType
- Key type.valueType
- Value type.- Returns:
- Map data type.
-
newDataType
public static DataType newDataType(DataTypeId typeId, int size)
Returns a data type for the specified data type identifier and data size. For the same identifier and data size, the same instances are returned.- Parameters:
typeId
- Data type identifier.size
- Data size in bits.- Returns:
- Data type object.
-
newDataType
public static DataType newDataType(DataTypeId typeId, java.lang.Object... parameters)
Returns an instance of a data type object based on its attributes. For objects of the same type (type identifier and sizes are equal), the same instance is returned.- Parameters:
typeId
- Type identifier.parameters
- List of type parameters.- Returns:
- Data type object.
-
getTypeId
public DataTypeId getTypeId()
Returns a data type identifier.- Returns:
- Data type identifier.
-
isTypeId
public boolean isTypeId(DataTypeId typeId)
Checks whether the specified data type identifier is used.- Returns:
true
is the specified data type identifier is used orfalse
otherwise.
-
getSize
public int getSize()
Returns the size of binary data in bits. ReturnsLOGIC_TYPE_SIZE
for logic data types.- Returns:
- Data size in bits.
-
getParameters
public java.lang.Object[] getParameters()
-
getAttribute
public java.lang.Object getAttribute(DataTypeId.Attribute attr)
-
getTypeRadix
public int getTypeRadix()
Returns a radix to be used for conversion data of this type to a string or vice versa.- Returns:
- A radix value.
-
getValueClass
public java.lang.Class<?> getValueClass()
Returns the class that is used to store data (internal representation).- Returns:
- The class that is used to store data.
-
valueOf
public Data valueOf(java.lang.String value, int radix)
Creates an instance of a data object of a corresponding data type.- Parameters:
value
- The text representation of a value.radix
- The radix to be used for parsing.- Returns:
- A new data object.
-
typeOf
public static DataType typeOf(java.lang.String text)
Creates an instance of a data type from the its textual representation. If such type has already been registered the existing instance will be returned.- Parameters:
text
- Textual representation of the data type.- Returns:
- Data type.
-
valueUninitialized
public Data valueUninitialized()
Creates an uninitialized data object (the value is set to null).- Returns:
- A new data object.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.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
-
-