Class DecimalField
- java.lang.Object
-
- org.apache.jackrabbit.core.query.lucene.DecimalField
-
public class DecimalField extends Object
TheDecimalField
class is a utility to convertjava.math.BigDecimal
values toString
values that are lexicographically sortable according to the decimal value.The string format uses the characters '0' to '9' and consists of:
{ value signum +2 } { exponent signum +2 } { exponent length -1 } { exponent value } { value (-1 if inverted) }
Only the signum is encoded if the value is zero. The exponent is not encoded if zero. Negative values are "inverted" character by character ('0' -> 9, '1' -> '8', and so on). The same applies to the exponent.Examples: 0 => "2" 2 => "322" (signum 1; exponent 0; value 2) 120 => "330212" (signum 1; exponent signum 1, length 1, value 2; value 12). -1 => "179" (signum -1, rest inverted; exponent 0; value 1 (-1, inverted).
Values between BigDecimal(BigInteger.ONE, Integer.MIN_VALUE) and BigDecimal(BigInteger.ONE, Integer.MAX_VALUE) are supported.
-
-
Constructor Summary
Constructors Constructor Description DecimalField()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
decimalToString(BigDecimal value)
Convert a BigDecimal to a String.static BigDecimal
stringToDecimal(String value)
Convert a String to a BigDecimal.
-
-
-
Method Detail
-
decimalToString
public static String decimalToString(BigDecimal value)
Convert a BigDecimal to a String.- Parameters:
value
- the BigDecimal- Returns:
- the String
-
stringToDecimal
public static BigDecimal stringToDecimal(String value)
Convert a String to a BigDecimal.- Parameters:
value
- the String- Returns:
- the BigDecimal
-
-