Class AdeptDataConversion
- java.lang.Object
-
- de.aristaflow.adept2.model.datamanagement.AdeptDataConversion
-
public final class AdeptDataConversion extends Object
Provides a method to convert values of one ADEPT2 data type to another where possible.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Serializable
convert(Serializable value, ProcessConstants.AdeptDataType targetDataType)
Converts the given value to the specified target data type and returns it.
-
-
-
Method Detail
-
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 allNumbers
FLOAT
(accepts allNumbers
STRING DATE URI USERDEFINED BOOLEAN -> as is false -> 0L
true -> 1Lfalse -> 0d
true -> 1dfalse -> "false"
true -> "true"- - - INTEGER -> 0 -> false; true otherwise as is
(cast toLong
if necessary)cast to Double
signed 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 Long
milliseconds since 1970-01-01, 00:00:00 GMT as Double
formatted 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
-
-