Package org.yamcs.yarch
Class DataType
java.lang.Object
org.yamcs.yarch.DataType
- Direct Known Subclasses:
ArrayDataType
,ProtobufDataType
,TupleDataType
Types supported by yarch. Currently TUPLE and LIST do now work well. ENUM is just like String, except that when it's
stored on disk a two bytes integer value from a map is stored instead of the String. (maximum allowed version is 2^16
(which is anyway too big considering that the map is stored as serialised yaml file)
PROTOBUF is a Google Protocol Buffer message
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final byte
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final DataType
static final byte
static final DataType
static final DataType
static final DataType
static final byte
static final DataType
final DataType._type
-
Constructor Summary
ModifierConstructorDescriptionprotected
DataType
(DataType._type t, byte id) protected
DataType
(DataType._type t, byte id, boolean comparable) -
Method Summary
Modifier and TypeMethodDescriptionstatic DataType
static DataType
this is the inverse ofname()
static String
static Object
Performs casting: numbers to numbers, numbers to string, string to numbersstatic Object
Performs casting of v from sourceType to targetTypestatic int
static boolean
compatible
(DataType dt1, DataType dt2) static int
return the size in bytes of the encoded data type if it can be encoded on fixed size, or -1 if not.byte
boolean
hasEnums()
Return true if this data type is an enum or a composite type (array) containing an enumboolean
static boolean
boolean
javaType()
name()
Returns type as string.static DataType
static DataType
toString()
static DataType
tuple
(TupleDefinition td) static DataType
-
Field Details
-
val
-
BYTE
-
SHORT
-
INT
-
LONG
-
DOUBLE
-
STRING
-
BINARY
-
BOOLEAN
-
TIMESTAMP
-
ENUM
-
PARAMETER_VALUE
-
PROTOBUF_ID
public static final byte PROTOBUF_ID- See Also:
-
TUPLE_ID
public static final byte TUPLE_ID- See Also:
-
ARRAY_ID
public static final byte ARRAY_ID- See Also:
-
HRES_TIMESTAMP
-
UUID
-
-
Constructor Details
-
DataType
-
DataType
-
-
Method Details
-
tuple
-
array
-
protobuf
-
protobuf
-
byName
this is the inverse ofname()
- Parameters:
name
-- Returns:
- the DataType corresponding to the name
- Throws:
IllegalArgumentException
- thrown in case the name is invalid
-
getSerializedSize
return the size in bytes of the encoded data type if it can be encoded on fixed size, or -1 if not.- Parameters:
dt
-- Returns:
-
capitalized
-
javaType
-
primitiveJavaType
-
isPrimitiveJavaType
public boolean isPrimitiveJavaType() -
toString
-
name
Returns type as string.- Returns:
- for basic types returns the enum name for PROTOBUF returns PROTOBUF(className)
-
typeOf
-
compare
-
castAs
public static Object castAs(DataType sourceType, DataType targetType, Object v) throws IllegalArgumentException Performs casting of v from sourceType to targetType- Parameters:
sourceType
-targetType
-v
-- Returns:
- the casted object (can be v if no casting is performed)
- Throws:
IllegalArgumentException
-
castAs
Performs casting: numbers to numbers, numbers to string, string to numbers- Parameters:
targetType
-v
-- Returns:
- the casted object (can be to v if no casting is performed)
- Throws:
IllegalArgumentException
-
isNumber
-
compatible
-
getTypeId
public byte getTypeId() -
hasEnums
public boolean hasEnums()Return true if this data type is an enum or a composite type (array) containing an enum -
isComparable
public boolean isComparable()- Returns:
- true if two values of this type are comparable (i.e. if they support a natural ordering)
-