public final class SafeDoubleParser extends Object
Prevents brute force attacks using the famous Java bug.
| Modifier and Type | Field and Description | 
|---|---|
| protected static BigDecimal | LOWERLower allowed value | 
| protected static BigDecimal | MIDDLEThe middle of the bad interval - used for rounding bad values | 
| protected static BigDecimal | TWOConstant 2 | 
| protected static BigDecimal | UPPERUpper allowed value | 
| Constructor and Description | 
|---|
| SafeDoubleParser() | 
| Modifier and Type | Method and Description | 
|---|---|
| protected static double | decimalValue(BigDecimal bigDecimal)Safe way of getting the double value Prevents BigDecimal from calling Double.parseDouble() | 
| protected static double | decimalValue(Number number)Safe way of getting the double value prevents BigDecimal from calling Double.parseDouble() | 
| protected static Double | decimalValueOf(String s)Safe parsing of a String into a Double | 
| static double | doubleValue(BigDecimal bigDecimal)Safe way of getting the double value Prevents BigDecimal from calling Double.parseDouble() | 
| static double | doubleValue(Number number)Safe way of getting the double value prevents BigDecimal from calling Double.parseDouble() | 
| protected static boolean | isSuspicious(String s)Heuristic test if we should look closer at the value | 
| static Double | parseDouble(String s)Safe way of parsing a Double value from a String | 
| static Double | valueOf(String s)Safe way of parsing a Double value from a String | 
protected static final BigDecimal TWO
protected static final BigDecimal LOWER
protected static final BigDecimal UPPER
protected static final BigDecimal MIDDLE
public static Double valueOf(String s)
s - The input Stringpublic static Double parseDouble(String s)
s - The input Stringpublic static double doubleValue(Number number)
number - public static double doubleValue(BigDecimal bigDecimal)
bigDecimal - protected static final boolean isSuspicious(String s)
s - The non-null input Stringtrue if the value is suspicious, false otherwiseprotected static final Double decimalValueOf(String s)
s - The input String, can be nullprotected static final double decimalValue(Number number)
number - protected static final double decimalValue(BigDecimal bigDecimal)
bigDecimal - Copyright © 2001-2015 JRuby. All Rights Reserved.