Class AdeptDataConversion
java.lang.Object
de.aristaflow.adept2.model.datamanagement.AdeptDataConversion
Provides a method to convert values of one ADEPT2 data type to another where
possible.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Serializableconvert(Serializable value, ProcessConstants.AdeptDataType targetDataType) Converts the given value to the specified target data type and returns it.
-
Method Details
-
convert
public static Serializable convert(Serializable value, ProcessConstants.AdeptDataType targetDataType) throws ConversionException Converts the given value to the specified target data type and returns it.Conversions between data types. BOOLEAN INTEGER
(accepts allNumbersFLOAT
(accepts allNumbersSTRING DATE URI USERDEFINED BOOLEAN -> as is false -> 0L
true -> 1Lfalse -> 0d
true -> 1dfalse -> "false"
true -> "true"- - - INTEGER -> 0 -> false; true otherwise as is
(cast toLongif necessary)cast to Doublesigned decimal representation taken as milliseconds since 1970-01-01, 00:00:00 GMT - - FLOAT -> 0 -> false; true otherwise
(accepts allNumbers)discards fractional digits while casting to Long
(accepts allNumbers)as is
(accepts allNumbers; will be cast toDouble)computerized scientific notation taken as milliseconds since 1970-01-01, 00:00:00 GMT; discards fractional digits - - STRING -> "true" (ignoring case) -> true, false otherwise ( Boolean.parseBoolean(String))parsed as signed decimal representation ( Long.parseLong(String))parsed as computerized scientific notation ( Double.parseDouble(String))as is parsed as ISO 8601 parsed as URI ( URI.create(String))encoded as UTF-8 DATE -> - milliseconds since 1970-01-01, 00:00:00 GMT as Longmilliseconds since 1970-01-01, 00:00:00 GMT as Doubleformatted as ISO 8601 as is - - URI -> - - - as string - as is - USERDEFINED -> - - - decoded as UTF-8 - - as is (cloned) - Parameters:
value- the value to be converted; this should typically be a direct equivalent to an ADEPT2 data type. The caller is responsible for closing.targetDataType- the target data type to which the value should be converted- Returns:
- the converted value. The caller is responsible for closing if appropriate.
- Throws:
ConversionException- if the conversion is not possible
-