public class DataUtilities
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
checkDataType(java.lang.Object v,
Type type)
Return true if a value is compatible with a type.
|
static java.lang.Object |
copyValue(Type fromType,
java.lang.Object fromValue,
Type toType)
Copy a value from one type to another.
|
static Data<?> |
createData(ServiceDefinition.Data dataDef)
Create a Data for a Service.
|
static Data<?> |
createData(Type type)
Create a Data for a type.
|
static java.lang.String |
formatTimeStamp(java.time.Duration duration)
Format a time stamp value.
|
static java.lang.Object |
getFieldValue(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure.
|
static java.util.List<java.lang.Object> |
getFieldValueAsArray(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a short.
|
static boolean |
getFieldValueAsBoolean(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a boolean.
|
static char |
getFieldValueAsChar(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a char.
|
static double |
getFieldValueAsDouble(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a double.
|
static float |
getFieldValueAsFloat(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a float.
|
static int |
getFieldValueAsInt(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as an int.
|
static long |
getFieldValueAsLong(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a long.
|
static short |
getFieldValueAsShort(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName)
Return the value of a field for a Structure as a short.
|
static EnumType.State |
getState(EnumType enumType,
java.lang.String stateName)
Return the state for a state name.
|
static int |
getStateValue(EnumType enumType,
java.lang.String stateName)
Return the state value for a state name.
|
static Type |
getTerminalType(Type type)
Return the terminal type corresponding to a type.
|
static java.util.List<java.lang.Object> |
getValue(Type type,
org.json.JSONArray jsonArray)
Return a value from a JSONArray
|
static java.lang.Object |
getValue(Type type,
org.json.JSONObject json)
Return a value from a JSONObject
|
static java.lang.Object |
getValueFromString(Type type,
java.lang.String value)
Return the value corresponding with a String.
|
static boolean |
setFieldValue(StructType struct,
java.util.List<java.lang.Object> value,
java.lang.String fieldName,
java.lang.Object fieldValue)
Set the value of a field for a Structure.
|
static org.json.JSONElement |
toJSON(Data<?> data,
boolean enumStateAsString)
Convert the content of a data as a JSON element.
|
static org.json.JSONObject |
toJSON(ServiceInstance<?,?> service,
boolean enumStateAsString)
Convert the content of a service as a JSON object.
|
public static final java.lang.String formatTimeStamp(java.time.Duration duration)
duration
- the time stamp as a durationpublic static Type getTerminalType(Type type)
type
- the typepublic static boolean checkDataType(java.lang.Object v, Type type)
v
- the valuetype
- the typepublic static java.lang.Object getFieldValue(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static float getFieldValueAsFloat(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static double getFieldValueAsDouble(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static int getFieldValueAsInt(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static short getFieldValueAsShort(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static long getFieldValueAsLong(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static boolean getFieldValueAsBoolean(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static char getFieldValueAsChar(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static java.util.List<java.lang.Object> getFieldValueAsArray(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName)
struct
- the structurevalue
- the value for the structurefieldName
- the field namepublic static boolean setFieldValue(StructType struct, java.util.List<java.lang.Object> value, java.lang.String fieldName, java.lang.Object fieldValue)
struct
- the structurefieldName
- the field namevalue
- the value for the structurefieldValue
- the value for the fieldpublic static java.lang.Object getValueFromString(Type type, java.lang.String value)
SimpleType
.type
- the typevalue
- the value as a Stringpublic static EnumType.State getState(EnumType enumType, java.lang.String stateName)
enumType
- the Enumeration typestateName
- the state namepublic static int getStateValue(EnumType enumType, java.lang.String stateName)
enumType
- the Enumeration typestateName
- the state namepublic static Data<?> createData(ServiceDefinition.Data dataDef)
dataDef
- the Data definitionpublic static Data<?> createData(Type type)
type
- the typepublic static java.util.List<java.lang.Object> getValue(Type type, org.json.JSONArray jsonArray)
type
- the data typejsonArray
- the JSONArraypublic static java.lang.Object getValue(Type type, org.json.JSONObject json)
type
- the data typejson
- the JSONObjectpublic static org.json.JSONElement toJSON(Data<?> data, boolean enumStateAsString) throws org.json.JSONException
SimpleType
, the
method will return null.data
- the dataenumStateAsString
- true if the enumeration states should be converted as Stringsorg.json.JSONException
public static org.json.JSONObject toJSON(ServiceInstance<?,?> service, boolean enumStateAsString) throws org.json.JSONException
service
- the serviceenumStateAsString
- true if the enumeration states should be converted as Stringsorg.json.JSONException
public static java.lang.Object copyValue(Type fromType, java.lang.Object fromValue, Type toType)
fromType
- the type from which to copy the valuefromValue
- to value to copytoType
- the type to which to copy the valueCopyright ©2017-2023 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence