Class Conversions
java.lang.Object
org.apache.jackrabbit.oak.plugins.value.Conversions
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();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA converter converts a value to its representation as a specific target type. -
Method Summary
Modifier and TypeMethodDescriptionstatic Conversions.Converterconvert(boolean value) Create a converter for a boolean.static Conversions.Converterconvert(double value) Create a converter for a double.static Conversions.Converterconvert(long value) Create a converter for a long.static Conversions.ConverterCreate a converter for a string.static Conversions.ConverterCreate a converter for a date.static Conversions.Converterconvert(BigDecimal value) Create a converter for a decimal.static Conversions.ConverterCreate a converter for a binary.
-
Method Details
-
convert
Create a converter for a string.- Parameters:
value- The string to convert- Returns:
- A converter for
value - Throws:
NumberFormatException
-
convert
Create a converter for a binary. For the conversion toStringthe 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
Create a converter for a long.String.valueOf(long)is used for the conversion toString. The conversions todoubleandlongreturn thevalueitself. The conversion to decimal usesnew BigDecimal.valueOf(long). The conversion to date interprets the value as number of milliseconds since1970-01-01T00:00:00.000Z.- Parameters:
value- The long to convert- Returns:
- A converter for
value
-
convert
Create a converter for a double.String.valueOf(double)is used for the conversion toString. The conversions todoubleandlongreturn thevalueitself where in the former case the value is casted tolong. The conversion to decimal usesBigDecimal.valueOf(double). The conversion to date interpretstoLong()as number of milliseconds since1970-01-01T00:00:00.000Z.- Parameters:
value- The double to convert- Returns:
- A converter for
value
-
convert
Create a converter for a date.ISO8601.format(Calendar)is used for the conversion toString. The conversions todouble,longandBigDecimalreturn the number of milliseconds since1970-01-01T00:00:00.000Z.- Parameters:
value- The date to convert- Returns:
- A converter for
value
-
convert
Create a converter for a boolean.Boolean.toString(boolean)is used for the conversion toString.- Parameters:
value- The boolean to convert- Returns:
- A converter for
value
-
convert
Create a converter for a decimal.BigDecimal.toString()is used for the conversion toString.BigDecimal.longValue()andBigDecimal.doubleValue()is used for the conversions tolonganddouble, respectively. The conversion to date interpretstoLong()as number of milliseconds since1970-01-01T00:00:00.000Z.- Parameters:
value- The decimal to convert- Returns:
- A converter for
value
-