Class SafeFloatParser

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

public final class SafeFloatParser extends SafeDecimalParser
A safer way to parse float values

Prevents brute force attacks using the famous Java bug.

  • Constructor Details

    • SafeFloatParser

      public SafeFloatParser()
  • Method Details

    • valueOf

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

      public static Float parseFloat(String s)
      Safe way of parsing a Float value from a String
      Parameters:
      s - The input String
      Returns:
      the Float value
    • floatValue

      public static float floatValue(Number number)
      Safe way of getting the float value
      prevents BigDecimal from calling Float.parseFloat()
      Parameters:
      number -
      Returns:
      the float value
    • floatValue

      public static float floatValue(BigDecimal bigDecimal)
      Safe way of getting the float value
      Prevents BigDecimal from calling Float.parseFloat()
      Parameters:
      bigDecimal -
      Returns:
      the float value