|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jruby.util.SafeFloatParser
public final class SafeFloatParser
A safer way to parse float values
Prevents brute force attacks using the famous Java bug.
| Field Summary | |
|---|---|
protected static java.math.BigDecimal |
LOWER
Lower allowed value |
protected static java.math.BigDecimal |
MIDDLE
The middle of the bad interval - used for rounding bad values |
protected static java.math.BigDecimal |
TWO
Constant 2 |
protected static java.math.BigDecimal |
UPPER
Upper allowed value |
| Constructor Summary | |
|---|---|
SafeFloatParser()
|
|
| Method Summary | |
|---|---|
protected static double |
decimalValue(java.math.BigDecimal bigDecimal)
Safe way of getting the double value Prevents BigDecimal from calling Double.parseDouble() |
protected static double |
decimalValue(java.lang.Number number)
Safe way of getting the double value prevents BigDecimal from calling Double.parseDouble() |
protected static java.lang.Double |
decimalValueOf(java.lang.String s)
Safe parsing of a String into a Double |
static float |
floatValue(java.math.BigDecimal bigDecimal)
Safe way of getting the float value Prevents BigDecimal from calling Float.parseFloat() |
static float |
floatValue(java.lang.Number number)
Safe way of getting the float value prevents BigDecimal from calling Float.parseFloat() |
protected static boolean |
isSuspicious(java.lang.String s)
Heuristic test if we should look closer at the value |
static java.lang.Float |
parseFloat(java.lang.String s)
Safe way of parsing a Float value from a String |
static java.lang.Float |
valueOf(java.lang.String s)
Safe way of parsing a Float value from a String |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.math.BigDecimal TWO
protected static final java.math.BigDecimal LOWER
protected static final java.math.BigDecimal UPPER
protected static final java.math.BigDecimal MIDDLE
| Constructor Detail |
|---|
public SafeFloatParser()
| Method Detail |
|---|
public static java.lang.Float valueOf(java.lang.String s)
s - The input String
public static java.lang.Float parseFloat(java.lang.String s)
s - The input String
public static float floatValue(java.lang.Number number)
number -
public static float floatValue(java.math.BigDecimal bigDecimal)
bigDecimal -
protected static final boolean isSuspicious(java.lang.String s)
s - The non-null input String
true if the value is suspicious, false otherwiseprotected static final java.lang.Double decimalValueOf(java.lang.String s)
s - The input String, can be null
protected static final double decimalValue(java.lang.Number number)
number -
protected static final double decimalValue(java.math.BigDecimal bigDecimal)
bigDecimal -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||