Package org.jruby.util
Class SafeFloatParser
java.lang.Object
org.jruby.util.SafeDecimalParser
org.jruby.util.SafeFloatParser
A safer way to parse float values
Prevents brute force attacks using the famous Java bug.
-
Field Summary
Fields inherited from class org.jruby.util.SafeDecimalParser
LOWER, MIDDLE, TWO, UPPER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatfloatValue(Number number) Safe way of getting the float value
prevents BigDecimal from calling Float.parseFloat()static floatfloatValue(BigDecimal bigDecimal) Safe way of getting the float value
Prevents BigDecimal from calling Float.parseFloat()static FloatparseFloat(String s) Safe way of parsing a Float value from a Stringstatic FloatSafe way of parsing a Float value from a StringMethods inherited from class org.jruby.util.SafeDecimalParser
decimalValue, decimalValue, decimalValueOf, isSuspicious
-
Constructor Details
-
SafeFloatParser
public SafeFloatParser()
-
-
Method Details
-
valueOf
Safe way of parsing a Float value from a String- Parameters:
s- The input String- Returns:
- the Float value
-
parseFloat
Safe way of parsing a Float value from a String- Parameters:
s- The input String- Returns:
- the Float value
-
floatValue
Safe way of getting the float value
prevents BigDecimal from calling Float.parseFloat()- Parameters:
number-- Returns:
- the float value
-
floatValue
Safe way of getting the float value
Prevents BigDecimal from calling Float.parseFloat()- Parameters:
bigDecimal-- Returns:
- the float value
-