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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final DataTypestatic final DataTypestatic final DataTypestatic final DataTypestatic final DataTypestatic final DataTypestatic final DataTypestatic final DataTypestatic final DataTypestatic final bytestatic final DataTypestatic final DataTypestatic final DataTypestatic final bytestatic final DataTypefinal DataType._type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDataType(DataType._type t, byte id) protectedDataType(DataType._type t, byte id, boolean comparable) -
Method Summary
Modifier and TypeMethodDescriptionstatic DataTypestatic DataTypethis is the inverse ofname()static Stringstatic ObjectPerforms casting: numbers to numbers, numbers to string, string to numbersstatic ObjectPerforms casting of v from sourceType to targetTypestatic intstatic booleancompatible(DataType dt1, DataType dt2) static intreturn the size in bytes of the encoded data type if it can be encoded on fixed size, or -1 if not.bytebooleanhasEnums()Return true if this data type is an enum or a composite type (array) containing an enumbooleanstatic booleanbooleanjavaType()name()Returns type as string.static DataTypestatic DataTypetoString()static DataTypetuple(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)
-