Class AdeptDataConversion


  • public final class AdeptDataConversion
    extends Object
    Provides a method to convert values of one ADEPT2 data type to another where possible.
    • 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 all Numbers
        FLOAT
        (accepts all Numbers
        STRING DATE URI USERDEFINED
        BOOLEAN -> as is false -> 0L
        true -> 1L
        false -> 0d
        true -> 1d
        false -> "false"
        true -> "true"
        - - -
        INTEGER -> 0 -> false; true otherwise as is
        (cast to Long 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 all Numbers)
        discards fractional digits while casting to Long
        (accepts all Numbers)
        as is
        (accepts all Numbers; will be cast to Double)
        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