Class ConfigurableDoubleParser

java.lang.Object
ch.randelshofer.fastdoubleparser.ConfigurableDoubleParser

public final class ConfigurableDoubleParser extends Object
Parses a floating point value with configurable NumberFormatSymbols.

Syntax

Leading Character.FORMAT characters in the string are ignored.

FloatingPointLiteral:
[Sign] NaN
[Sign] Infinity
NaN [Sign]
Infinity [Sign]
DecimalFloatingPointLiteral
DecimalFloatingPointLiteral:
[Sign] DecSignificand [DecExponent]
DecSignificand [Sign] [DecExponent]
DecSignificand:
IntegerPart DecimalSeparator [FractionPart]
DecimalSeparator FractionPart
IntegerPart
IntegerPart:
GroupedDigits
FractionPart:
Digits
DecimalSeparator:
(one of NumberFormatSymbols.decimalSeparator())
DecExponent:
ExponentIndicator [Sign] Digits
ExponentIndicator Digits [Sign]
ExponentIndicator:
(one of NumberFormatSymbols.exponentSeparator())
Sign:
(one of NumberFormatSymbols.minusSign())
(one of NumberFormatSymbols.plusSign())
Digits:
Digit {Digit}
GroupedDigits:
DigitOrGrouping {DigitOrGrouping}
DigitOrGrouping:
Digit
Grouping
Digit:
(one of digits 0 through 9 starting with NumberFormatSymbols.digits())
Sign:
(one of NumberFormatSymbols.groupingSeparator())
NaN:
(one of NumberFormatSymbols.nan())
Infinity:
(one of NumberFormatSymbols.infinity())
Maximal input length supported by this parser:
  • Constructor Details

    • ConfigurableDoubleParser

      public ConfigurableDoubleParser(NumberFormatSymbols symbols)
      Creates a new instance with the specified number format symbols.

      The parser does not ignore case.

      Parameters:
      symbols - the number format symbols
    • ConfigurableDoubleParser

      public ConfigurableDoubleParser(DecimalFormatSymbols symbols)
      Creates a new instance with number format symbols derived from the specified symbols by calling NumberFormatSymbols.fromDecimalFormatSymbols(DecimalFormatSymbols).

      The parser does not ignore case.

      Parameters:
      symbols - the decimal format symbols
    • ConfigurableDoubleParser

      public ConfigurableDoubleParser(NumberFormatSymbols symbols, boolean ignoreCase)
      Creates a new instance with the specified number format symbols and case sensitivity.
      Parameters:
      symbols - the number format symbols
      ignoreCase - whether case should be ignored by the parser
    • ConfigurableDoubleParser

      public ConfigurableDoubleParser(DecimalFormatSymbols symbols, boolean ignoreCase)
      Creates a new instance with decimal format symbols and case sensitivity.

      The number format symbols are derived from the specified decimal format symbols by calling NumberFormatSymbols.fromDecimalFormatSymbols(DecimalFormatSymbols).

      Parameters:
      symbols - the decimal format symbols
      ignoreCase - whether case should be ignored by the parser
    • ConfigurableDoubleParser

      public ConfigurableDoubleParser()
      Creates a new instance with NumberFormatSymbols.fromDefault() which does not ignore case.
  • Method Details

    • getNumberFormatSymbols

      public NumberFormatSymbols getNumberFormatSymbols()
      Gets the number format symbols of this parser.
      Returns:
      the number format symbols
    • isIgnoreCase

      public boolean isIgnoreCase()
      Returns true of this parser ignores case.
      Returns:
      true if case is ignored
    • parseDouble

      public double parseDouble(CharSequence str)
      Parses a double value from the specified char sequence.
      Parameters:
      str - a char sequence
      Returns:
      a double value
      Throws:
      NumberFormatException - if the provided char sequence could not be parsed
    • parseDouble

      public double parseDouble(CharSequence str, int offset, int length)
      Parses a double value from a substring of the specified char sequence.
      Parameters:
      str - a char sequence
      offset - the start offset of the substring
      length - the length of the substring
      Throws:
      NumberFormatException - if the provided char sequence could not be parsed
    • parseDouble

      public double parseDouble(char[] str)
      Parses a double value from the specified char array.
      Parameters:
      str - a char array
      Returns:
      a double value
      Throws:
      NumberFormatException - if the provided char array could not be parsed
    • parseDouble

      public double parseDouble(char[] str, int offset, int length)
      Parses a double value from a substring of the specified char array.
      Parameters:
      str - a char array
      offset - the start offset of the substring
      length - the length of the substring
      Throws:
      NumberFormatException - if the provided char array could not be parsed
    • parseDouble

      public double parseDouble(byte[] str)
      Parses a double value from the specified byte array.
      Parameters:
      str - a byte array
      Returns:
      a double value
      Throws:
      NumberFormatException - if the provided char array could not be parsed
    • parseDouble

      public double parseDouble(byte[] str, int offset, int length)
      Parses a double value from a substring of the specified byte array.
      Parameters:
      str - a byte array
      offset - the start offset of the substring
      length - the length of the substring
      Throws:
      NumberFormatException - if the provided char array could not be parsed