Class Conversions.Converter
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.value.Conversions.Converter
-
- Enclosing class:
- Conversions
public abstract static class Conversions.Converter extends Object
A converter converts a value to its representation as a specific target type. Not all target types might be supported for a given value in which case implementations throw an exception. The default implementations of the various conversion methods all operate on the string representation of the underlying value (i.e. callConverter.toString().
-
-
Constructor Summary
Constructors Constructor Description Converter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.apache.jackrabbit.oak.api.BlobtoBinary()Convert to binary.booleantoBoolean()Convert to boolean.CalendartoCalendar()Convert to date.StringtoDate()Convert to date.BigDecimaltoDecimal()Convert to decimal.doubletoDouble()Convert to double.longtoLong()Convert to long.abstract StringtoString()Convert to string
-
-
-
Method Detail
-
toString
public abstract String toString()
Convert to string
-
toBinary
public org.apache.jackrabbit.oak.api.Blob toBinary()
Convert to binary. This default implementation returns an new instance ofStringBasedBlob.- Returns:
- binary representation of the converted value
-
toLong
public long toLong()
Convert to long. This default implementation is based onLong.parseLong(String).- Returns:
- long representation of the converted value
- Throws:
NumberFormatException
-
toDouble
public double toDouble()
Convert to double. This default implementation is based onDouble.parseDouble(String).- Returns:
- double representation of the converted value
- Throws:
NumberFormatException
-
toCalendar
public Calendar toCalendar()
Convert to date. This default implementation is based onISO8601.parse(String).- Returns:
- date representation of the converted value
- Throws:
IllegalArgumentException- if the string cannot be parsed into a date
-
toDate
public String toDate()
Convert to date. This default implementation delegates totoCalendar()and returns theISO8601.format(Calendar)value of the calendar.- Returns:
- date representation of the converted value
- Throws:
IllegalArgumentException- if the string cannot be parsed into a date
-
toBoolean
public boolean toBoolean()
Convert to boolean. This default implementation is based onBoolean.parseBoolean(String).- Returns:
- boolean representation of the converted value
-
toDecimal
public BigDecimal toDecimal()
Convert to decimal. This default implementation is based onnew BigDecimal(String).- Returns:
- decimal representation of the converted value
- Throws:
NumberFormatException
-
-