Class Conversions
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.value.Conversions
-
public final class Conversions extends java.lang.ObjectUtility class defining the conversion that take place betweenPropertyStates 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 Classes Modifier and Type Class Description static classConversions.ConverterA converter converts a value to its representation as a specific target type.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.Converterconvert(java.lang.String value)Create a converter for a string.static Conversions.Converterconvert(java.lang.String value, Type<?> type)Create a converter for a date.static Conversions.Converterconvert(java.math.BigDecimal value)Create a converter for a decimal.static Conversions.Converterconvert(Blob value)Create a converter for a binary.
-
-
-
Method Detail
-
convert
public static Conversions.Converter convert(java.lang.String value)
Create a converter for a string.- Parameters:
value- The string to convert- Returns:
- A converter for
value - Throws:
java.lang.NumberFormatException
-
convert
public static Conversions.Converter convert(Blob value)
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:
java.lang.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 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
public static Conversions.Converter convert(double value)
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
public static Conversions.Converter convert(java.lang.String value, Type<?> type)
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
public static Conversions.Converter convert(boolean value)
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
public static Conversions.Converter convert(java.math.BigDecimal value)
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
-
-