Package org.yamcs.yarch
Class DataType
- java.lang.Object
-
- org.yamcs.yarch.DataType
-
- Direct Known Subclasses:
ListDataType,ProtobufDataType,TupleDataType
public class DataType extends Object
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 Modifier and Type Class Description static classDataType._type
-
Field Summary
Fields Modifier and Type Field Description static DataTypeBINARYstatic DataTypeBOOLEANstatic DataTypeBYTEstatic DataTypeDOUBLEstatic DataTypeENUMstatic DataTypeINTstatic byteLIST_IDstatic DataTypeLONGstatic DataTypePARAMETER_VALUEstatic bytePROTOBUF_IDstatic DataTypeSHORTstatic DataTypeSTRINGstatic DataTypeTIMESTAMPstatic byteTUPLE_IDDataType._typeval
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataType(DataType._type t, byte id)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataTypebyName(String name)this is the inverse ofname()static Stringcapitalized(String s)static ObjectcastAs(DataType targetType, Object v)Performs casting: numbers to numbers numbers to string string to numbersstatic ObjectcastAs(DataType sourceType, DataType targetType, Object v)Performs casting of v from type1 to type2static intcompare(Object v1, Object v2)static booleancompatible(DataType dt1, DataType dt2)bytegetTypeId()static booleanisNumber(DataType dt)StringjavaType()static DataTypelist(TupleDefinition td)Stringname()Returns type as string.StringprimitiveJavaType()static DataTypeprotobuf(String className)StringtoString()static DataTypetuple(TupleDefinition td)static DataTypetypeOf(Object v)
-
-
-
Field Detail
-
val
public final DataType._type val
-
BYTE
public static final DataType BYTE
-
SHORT
public static final DataType SHORT
-
INT
public static final DataType INT
-
LONG
public static final DataType LONG
-
DOUBLE
public static final DataType DOUBLE
-
STRING
public static final DataType STRING
-
BINARY
public static final DataType BINARY
-
BOOLEAN
public static final DataType BOOLEAN
-
TIMESTAMP
public static final DataType TIMESTAMP
-
ENUM
public static final DataType ENUM
-
PARAMETER_VALUE
public static final DataType PARAMETER_VALUE
-
PROTOBUF_ID
public static final byte PROTOBUF_ID
- See Also:
- Constant Field Values
-
TUPLE_ID
public static final byte TUPLE_ID
- See Also:
- Constant Field Values
-
LIST_ID
public static final byte LIST_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DataType
protected DataType(DataType._type t, byte id)
-
-
Method Detail
-
tuple
public static DataType tuple(TupleDefinition td)
-
list
public static DataType list(TupleDefinition td)
-
byName
public static DataType byName(String name) throws IllegalArgumentException
this is the inverse ofname()- Parameters:
name-- Returns:
- the DataType corresponding to the name
- Throws:
IllegalArgumentException- thrown in case the name is invalid
-
javaType
public String javaType()
-
primitiveJavaType
public String primitiveJavaType()
-
name
public String name()
Returns type as string.- Returns:
- for basic types returns the enum name for PROTOBUF returns PROTOBUF(className)
-
castAs
public static Object castAs(DataType sourceType, DataType targetType, Object v) throws IllegalArgumentException
Performs casting of v from type1 to type2- Parameters:
sourceType-targetType-v-- Returns:
- the casted object (can be v if no casting is performed)
- Throws:
IllegalArgumentException
-
castAs
public static Object castAs(DataType targetType, Object v) throws IllegalArgumentException
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
public static boolean isNumber(DataType dt)
-
getTypeId
public byte getTypeId()
-
-