Class SafeDoubleParser

java.lang.Object
org.jruby.util.SafeDecimalParser
org.jruby.util.SafeDoubleParser

public final class SafeDoubleParser extends SafeDecimalParser
A safer way to parse double values

Prevents brute force attacks using the famous Java bug.

  • Constructor Details

    • SafeDoubleParser

      public SafeDoubleParser()
  • Method Details

    • valueOf

      public static Double valueOf(String s)
      Safe way of parsing a Double value from a String
      Parameters:
      s - The input String
      Returns:
      the Double value
    • parseDouble

      public static Double parseDouble(String s)
      Safe way of parsing a Double value from a String
      Parameters:
      s - The input String
      Returns:
      the Double value
    • doubleValue

      public static double doubleValue(Number number)
      Safe way of getting the double value
      prevents BigDecimal from calling Double.parseDouble()
      Parameters:
      number -
      Returns:
      the double value
    • doubleValue

      public static double doubleValue(BigDecimal bigDecimal)
      Safe way of getting the double value
      Prevents BigDecimal from calling Double.parseDouble()
      Parameters:
      bigDecimal -
      Returns:
      the double value