Package com.ibm.icu.impl.number.parse
Class NumberParserImpl
- java.lang.Object
-
- com.ibm.icu.impl.number.parse.NumberParserImpl
-
public class NumberParserImpl extends java.lang.Object
Primary number parsing implementation class.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
frozen
private java.util.List<NumberParseMatcher>
matchers
private int
parseFlags
-
Constructor Summary
Constructors Constructor Description NumberParserImpl(int parseFlags)
Creates a new, empty parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMatcher(NumberParseMatcher matcher)
void
addMatchers(java.util.Collection<? extends NumberParseMatcher> matchers)
static NumberParserImpl
createDefaultParserForLocale(ULocale loc)
static NumberParserImpl
createParserFromProperties(DecimalFormatProperties properties, DecimalFormatSymbols symbols, boolean parseCurrency)
Creates a parser from the given DecimalFormatProperties.static NumberParserImpl
createSimpleParser(ULocale locale, java.lang.String pattern, int parseFlags)
Creates a parser with most default options.void
freeze()
int
getParseFlags()
void
parse(java.lang.String input, boolean greedy, ParsedNumber result)
void
parse(java.lang.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 java.lang.Number
parseStatic(java.lang.String input, java.text.ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)
Parses the string without returning a NumberParserImpl.static CurrencyAmount
parseStaticCurrency(java.lang.String input, java.text.ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)
Parses the string without returning a NumberParserImpl.java.lang.String
toString()
-
-
-
Field Detail
-
parseFlags
private final int parseFlags
-
matchers
private final java.util.List<NumberParseMatcher> matchers
-
frozen
private boolean frozen
-
-
Method Detail
-
createSimpleParser
public static NumberParserImpl createSimpleParser(ULocale locale, java.lang.String pattern, int parseFlags)
Creates a parser with most default options. Used for testing, not production.
-
parseStatic
public static java.lang.Number parseStatic(java.lang.String input, java.text.ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)
Parses the string without returning a NumberParserImpl. Used for testing, not production.
-
parseStaticCurrency
public static CurrencyAmount parseStaticCurrency(java.lang.String input, java.text.ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)
Parses the string without returning a NumberParserImpl. Used for testing, not production.
-
createDefaultParserForLocale
public static NumberParserImpl createDefaultParserForLocale(ULocale loc)
-
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
public void addMatcher(NumberParseMatcher matcher)
-
addMatchers
public void addMatchers(java.util.Collection<? extends NumberParseMatcher> matchers)
-
freeze
public void freeze()
-
getParseFlags
public int getParseFlags()
-
parse
public void parse(java.lang.String input, boolean greedy, ParsedNumber result)
-
parse
public void parse(java.lang.String input, int start, boolean greedy, ParsedNumber result)
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
private void parseGreedy(StringSegment segment, ParsedNumber result)
-
parseLongestRecursive
private void parseLongestRecursive(StringSegment segment, ParsedNumber result, int recursionLevels)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-