Package com.ibm.icu.impl.number.parse
Class NumberParserImpl
java.lang.Object
com.ibm.icu.impl.number.parse.NumberParserImpl
Primary number parsing implementation class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final List
<NumberParseMatcher> private final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMatcher
(NumberParseMatcher matcher) void
addMatchers
(Collection<? extends NumberParseMatcher> matchers) static NumberParserImpl
static NumberParserImpl
createParserFromProperties
(DecimalFormatProperties properties, DecimalFormatSymbols symbols, boolean parseCurrency) Creates a parser from the given DecimalFormatProperties.static NumberParserImpl
createSimpleParser
(ULocale locale, String pattern, int parseFlags) Creates a parser with most default options.void
freeze()
int
void
parse
(String input, boolean greedy, ParsedNumber result) void
parse
(String input, int start, boolean greedy, ParsedNumber result) Primary entrypoint to parsing code path.private void
parseGreedy
(StringSegment segment, ParsedNumber result) private void
parseLongestRecursive
(StringSegment segment, ParsedNumber result, int recursionLevels) static Number
parseStatic
(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols) Parses the string without returning a NumberParserImpl.static CurrencyAmount
parseStaticCurrency
(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols) Parses the string without returning a NumberParserImpl.toString()
-
Field Details
-
parseFlags
private final int parseFlags -
matchers
-
frozen
private boolean frozen
-
-
Constructor Details
-
NumberParserImpl
public NumberParserImpl(int parseFlags) Creates a new, empty parser.- Parameters:
parseFlags
- The parser settings defined in the PARSE_FLAG_* fields.
-
-
Method Details
-
createSimpleParser
Creates a parser with most default options. Used for testing, not production. -
parseStatic
public static Number parseStatic(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols) Parses the string without returning a NumberParserImpl. Used for testing, not production. -
parseStaticCurrency
public static CurrencyAmount parseStaticCurrency(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols) Parses the string without returning a NumberParserImpl. Used for testing, not production. -
createDefaultParserForLocale
-
createParserFromProperties
public static NumberParserImpl createParserFromProperties(DecimalFormatProperties properties, DecimalFormatSymbols symbols, boolean parseCurrency) Creates a parser from the given DecimalFormatProperties. This is the endpoint used by DecimalFormat in production code.- Parameters:
properties
- The property bag.symbols
- The locale's symbols.parseCurrency
- True to force a currency match and use monetary separators; false otherwise.- Returns:
- An immutable parser object.
-
addMatcher
-
addMatchers
-
freeze
public void freeze() -
getParseFlags
public int getParseFlags() -
parse
-
parse
Primary entrypoint to parsing code path.- Parameters:
input
- The string to parse. This is a String, not CharSequence, to enforce assumptions about immutability (CharSequences are not guaranteed to be immutable).start
- The index into the string at which to start parsing.greedy
- Whether to use the faster but potentially less accurate greedy code path.result
- Output variable to store results.
-
parseGreedy
-
parseLongestRecursive
-
toString
-