Class ConfigurableDoubleParser
java.lang.Object
ch.randelshofer.fastdoubleparser.ConfigurableDoubleParser
Parses a floating point value with configurable
NumberFormatSymbols.
Syntax
Leading Character.FORMAT characters in the string are ignored.
Maximal input length supported by this parser:
- 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())
FloatingPointLiteralwith leadingCharacter.FORMATcharacters:Integer.MAX_VALUE- 4 = 2,147,483,643 characters.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance withNumberFormatSymbols.fromDefault()which does not ignore case.Creates a new instance with the specified number format symbols.ConfigurableDoubleParser(NumberFormatSymbols symbols, boolean ignoreCase) Creates a new instance with the specified number format symbols and case sensitivity.Creates a new instance with number format symbols derived from the specified symbols by callingNumberFormatSymbols.fromDecimalFormatSymbols(DecimalFormatSymbols).ConfigurableDoubleParser(DecimalFormatSymbols symbols, boolean ignoreCase) Creates a new instance with decimal format symbols and case sensitivity. -
Method Summary
Modifier and TypeMethodDescriptionGets the number format symbols of this parser.booleanReturns true of this parser ignores case.doubleparseDouble(byte[] str) Parses a double value from the specified byte array.doubleparseDouble(byte[] str, int offset, int length) Parses a double value from a substring of the specified byte array.doubleparseDouble(char[] str) Parses a double value from the specified char array.doubleparseDouble(char[] str, int offset, int length) Parses a double value from a substring of the specified char array.doubleparseDouble(CharSequence str) Parses a double value from the specified char sequence.doubleparseDouble(CharSequence str, int offset, int length) Parses a double value from a substring of the specified char sequence.
-
Constructor Details
-
ConfigurableDoubleParser
Creates a new instance with the specified number format symbols.The parser does not ignore case.
- Parameters:
symbols- the number format symbols
-
ConfigurableDoubleParser
Creates a new instance with number format symbols derived from the specified symbols by callingNumberFormatSymbols.fromDecimalFormatSymbols(DecimalFormatSymbols).The parser does not ignore case.
- Parameters:
symbols- the decimal format symbols
-
ConfigurableDoubleParser
Creates a new instance with the specified number format symbols and case sensitivity.- Parameters:
symbols- the number format symbolsignoreCase- whether case should be ignored by the parser
-
ConfigurableDoubleParser
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 symbolsignoreCase- whether case should be ignored by the parser
-
ConfigurableDoubleParser
public ConfigurableDoubleParser()Creates a new instance withNumberFormatSymbols.fromDefault()which does not ignore case.
-
-
Method Details
-
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
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
Parses a double value from a substring of the specified char sequence.- Parameters:
str- a char sequenceoffset- the start offset of the substringlength- 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 arrayoffset- the start offset of the substringlength- 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 arrayoffset- the start offset of the substringlength- the length of the substring- Throws:
NumberFormatException- if the provided char array could not be parsed
-