Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jruby.util;
 
A safer way to parse double values

Prevents brute force attacks using the famous Java bug.

 
final public class SafeDoubleParser extends SafeDecimalParser {

    
Safe way of parsing a Double value from a String

Parameters:
s The input String
Returns:
the Double value
    public static Double valueOf(String s) {
        return decimalValueOf(s);
    }

    
Safe way of parsing a Double value from a String

Parameters:
s The input String
Returns:
the Double value
    public static Double parseDouble(String s) {
        return valueOf(s);
    }

    
Safe way of getting the double value
prevents BigDecimal from calling Double.parseDouble()

Parameters:
number
Returns:
the double value
    public static double doubleValue(Number number) {
        return decimalValue(number);
    }

    
Safe way of getting the double value
Prevents BigDecimal from calling Double.parseDouble()

Parameters:
bigDecimal
Returns:
the double value
    public static double doubleValue(BigDecimal bigDecimal) {
        return decimalValue(bigDecimal);
    }
New to GrepCode? Check out our FAQ X