Class Conversions


  • public final class Conversions
    extends Object
    Utility class defining the conversion that take place between PropertyStates of different types. All conversions defined in this class are compatible with the conversions specified in JSR-283 $3.6.4. However, some conversion in this class might not be defined in JSR-283.

    Example:

        double three = convert("3.0").toDouble();
     
    • Method Detail

      • convert

        public static Conversions.Converter convert​(Blob value)
        Create a converter for a binary. For the conversion to String the binary in interpreted as UTF-8 encoded string.
        Parameters:
        value - The binary to convert
        Returns:
        A converter for value
        Throws:
        IllegalArgumentException - if the binary is inaccessible
      • convert

        public static Conversions.Converter convert​(long value)
        Create a converter for a long. String.valueOf(long) is used for the conversion to String. The conversions to double and long return the value itself. The conversion to decimal uses new BigDecimal.valueOf(long). The conversion to date interprets the value as number of milliseconds since 1970-01-01T00:00:00.000Z.
        Parameters:
        value - The long to convert
        Returns:
        A converter for value
      • convert

        public static Conversions.Converter convert​(double value)
        Create a converter for a double. String.valueOf(double) is used for the conversion to String. The conversions to double and long return the value itself where in the former case the value is casted to long. The conversion to decimal uses BigDecimal.valueOf(double). The conversion to date interprets toLong() as number of milliseconds since 1970-01-01T00:00:00.000Z.
        Parameters:
        value - The double to convert
        Returns:
        A converter for value
      • convert

        public static Conversions.Converter convert​(String value,
                                                    Type<?> type)
        Create a converter for a date. ISO8601.format(Calendar) is used for the conversion to String. The conversions to double, long and BigDecimal return the number of milliseconds since 1970-01-01T00:00:00.000Z.
        Parameters:
        value - The date to convert
        Returns:
        A converter for value
      • convert

        public static Conversions.Converter convert​(boolean value)
        Create a converter for a boolean. Boolean.toString(boolean) is used for the conversion to String.
        Parameters:
        value - The boolean to convert
        Returns:
        A converter for value
      • convert

        public static Conversions.Converter convert​(BigDecimal value)
        Create a converter for a decimal. BigDecimal.toString() is used for the conversion to String. BigDecimal.longValue() and BigDecimal.doubleValue() is used for the conversions to long and double, respectively. The conversion to date interprets toLong() as number of milliseconds since 1970-01-01T00:00:00.000Z.
        Parameters:
        value - The decimal to convert
        Returns:
        A converter for value