Package ch.randelshofer.fastdoubleparser
Class ConfigurableDoubleParser
- java.lang.Object
-
- ch.randelshofer.fastdoubleparser.ConfigurableDoubleParser
-
public final class ConfigurableDoubleParser extends java.lang.ObjectParses a floating point value with configurableNumberFormatSymbols.Syntax
Leading
Character.FORMATcharacters 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
- DecimalSeparator FractionPart
- 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()) - (one of
- 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.
-
-
Field Summary
Fields Modifier and Type Field Description private ConfigurableDoubleBitsFromByteArrayAsciibyteArrayAsciiParserprivate ConfigurableDoubleBitsFromByteArrayUtf8byteArrayUtf8Parserprivate ConfigurableDoubleBitsFromCharArraycharArrayParserprivate ConfigurableDoubleBitsFromCharSequencecharSequenceParserprivate booleanignoreCaseprivate booleanisAllSingleCharSymbolsAsciiprivate booleanisAsciiprivate booleanisDigitsAsciiprivate NumberFormatSymbolssymbols
-
Constructor Summary
Constructors Constructor Description ConfigurableDoubleParser()Creates a new instance withNumberFormatSymbols.fromDefault()which does not ignore case.ConfigurableDoubleParser(NumberFormatSymbols symbols)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.ConfigurableDoubleParser(java.text.DecimalFormatSymbols symbols)Creates a new instance with number format symbols derived from the specified symbols by callingNumberFormatSymbols.fromDecimalFormatSymbols(DecimalFormatSymbols).ConfigurableDoubleParser(java.text.DecimalFormatSymbols symbols, boolean ignoreCase)Creates a new instance with decimal format symbols and case sensitivity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ConfigurableDoubleBitsFromByteArrayAsciigetByteArrayAsciiParser()private ConfigurableDoubleBitsFromByteArrayUtf8getByteArrayUtf8Parser()private ConfigurableDoubleBitsFromCharArraygetCharArrayParser()private ConfigurableDoubleBitsFromCharSequencegetCharSequenceParser()NumberFormatSymbolsgetNumberFormatSymbols()Gets the number format symbols of this parser.booleanisIgnoreCase()Returns 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(java.lang.CharSequence str)Parses a double value from the specified char sequence.doubleparseDouble(java.lang.CharSequence str, int offset, int length)Parses a double value from a substring of the specified char sequence.
-
-
-
Field Detail
-
symbols
private final NumberFormatSymbols symbols
-
charSequenceParser
private ConfigurableDoubleBitsFromCharSequence charSequenceParser
-
charArrayParser
private ConfigurableDoubleBitsFromCharArray charArrayParser
-
ignoreCase
private final boolean ignoreCase
-
isAllSingleCharSymbolsAscii
private final boolean isAllSingleCharSymbolsAscii
-
isDigitsAscii
private final boolean isDigitsAscii
-
isAscii
private final boolean isAscii
-
byteArrayAsciiParser
private ConfigurableDoubleBitsFromByteArrayAscii byteArrayAsciiParser
-
byteArrayUtf8Parser
private ConfigurableDoubleBitsFromByteArrayUtf8 byteArrayUtf8Parser
-
-
Constructor Detail
-
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(java.text.DecimalFormatSymbols symbols)
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
public ConfigurableDoubleParser(NumberFormatSymbols symbols, boolean ignoreCase)
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
public ConfigurableDoubleParser(java.text.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 symbolsignoreCase- whether case should be ignored by the parser
-
ConfigurableDoubleParser
public ConfigurableDoubleParser()
Creates a new instance withNumberFormatSymbols.fromDefault()which does not ignore case.
-
-
Method Detail
-
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
-
getCharArrayParser
private ConfigurableDoubleBitsFromCharArray getCharArrayParser()
-
getByteArrayAsciiParser
private ConfigurableDoubleBitsFromByteArrayAscii getByteArrayAsciiParser()
-
getByteArrayUtf8Parser
private ConfigurableDoubleBitsFromByteArrayUtf8 getByteArrayUtf8Parser()
-
getCharSequenceParser
private ConfigurableDoubleBitsFromCharSequence getCharSequenceParser()
-
parseDouble
public double parseDouble(java.lang.CharSequence str)
Parses a double value from the specified char sequence.- Parameters:
str- a char sequence- Returns:
- a double value
- Throws:
java.lang.NumberFormatException- if the provided char sequence could not be parsed
-
parseDouble
public double parseDouble(java.lang.CharSequence str, int offset, int length)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:
java.lang.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:
java.lang.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:
java.lang.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:
java.lang.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:
java.lang.NumberFormatException- if the provided char array could not be parsed
-
-