public final class SafeFloatParser 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 | 
|---|
| SafeFloatParser() | 
| 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 float | floatValue(BigDecimal bigDecimal)Safe way of getting the float value Prevents BigDecimal from calling Float.parseFloat() | 
| static float | floatValue(Number number)Safe way of getting the float value prevents BigDecimal from calling Float.parseFloat() | 
| protected static boolean | isSuspicious(String s)Heuristic test if we should look closer at the value | 
| static Float | parseFloat(String s)Safe way of parsing a Float value from a String | 
| static Float | valueOf(String s)Safe way of parsing a Float 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 Float valueOf(String s)
s - The input Stringpublic static Float parseFloat(String s)
s - The input Stringpublic static float floatValue(Number number)
number - public static float floatValue(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.