Top Description Fields Constructors Methods
com.ibm.icu.impl.number.parse

public Class NumberParserImpl

extends Object
Class Inheritance
Imports
java.text.ParsePosition, java.util.ArrayList, .Collection, .List, com.ibm.icu.impl.StringSegment, com.ibm.icu.impl.number.AffixPatternProvider, .AffixUtils, .CustomSymbolCurrency, .DecimalFormatProperties, .DecimalFormatProperties.ParseMode, .Grouper, .PatternStringParser, .PatternStringParser.ParsedPatternInfo, .PropertiesAffixPatternProvider, .RoundingUtils, com.ibm.icu.number.NumberFormatter.GroupingStrategy, .Scale, com.ibm.icu.text.DecimalFormatSymbols, com.ibm.icu.util.Currency, .CurrencyAmount, .ULocale

Primary number parsing implementation class.
Author
sffc

Field Summary

Modifier and TypeField and Description
private boolean
private final List<NumberParseMatcher>
private final int

Constructor Summary

AccessConstructor and Description
public
NumberParserImpl(int
The parser settings defined in the PARSE_FLAG_* fields.
parseFlags
)

Creates a new, empty parser.

Method Summary

Modifier and TypeMethod and Description
public void
public void
public static NumberParserImpl
public static NumberParserImpl

Returns:

An immutable parser object.
createParserFromProperties
(DecimalFormatProperties
The property bag.
properties
,
DecimalFormatSymbols
The locale's symbols.
symbols
,
boolean
True to force a currency match and use monetary separators; false otherwise.
parseCurrency
)

Creates a parser from the given DecimalFormatProperties.

public static NumberParserImpl
createSimpleParser(ULocale locale, String pattern, int parseFlags)

Creates a parser with most default options.

public void
public int
public void
parse(String input, boolean greedy, ParsedNumber result)

public void
parse(String
The string to parse. This is a String, not CharSequence, to enforce assumptions about immutability (CharSequences are not guaranteed to be immutable).
input
,
int
The index into the string at which to start parsing.
start
,
boolean
Whether to use the faster but potentially less accurate greedy code path.
greedy
,
ParsedNumber
Output variable to store results.
result
)

Primary entrypoint to parsing code path.

private void
private void
parseLongestRecursive(StringSegment segment, ParsedNumber result, int recursionLevels)

public static Number
parseStatic(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)

Parses the string without returning a NumberParserImpl.

public static CurrencyAmount
parseStaticCurrency(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)

Parses the string without returning a NumberParserImpl.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

frozenback to summary
private boolean frozen
matchersback to summary
private final List<NumberParseMatcher> matchers
parseFlagsback to summary
private final int parseFlags

Constructor Detail

NumberParserImplback to summary
public NumberParserImpl(int parseFlags)

Creates a new, empty parser.

Parameters
parseFlags:int

The parser settings defined in the PARSE_FLAG_* fields.

Method Detail

addMatcherback to summary
public void addMatcher(NumberParseMatcher matcher)
addMatchersback to summary
public void addMatchers(Collection<? extends NumberParseMatcher> matchers)
createDefaultParserForLocaleback to summary
public static NumberParserImpl createDefaultParserForLocale(ULocale loc)
createParserFromPropertiesback to summary
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:DecimalFormatProperties

The property bag.

symbols:DecimalFormatSymbols

The locale's symbols.

parseCurrency:boolean

True to force a currency match and use monetary separators; false otherwise.

Returns:NumberParserImpl

An immutable parser object.

createSimpleParserback to summary
public static NumberParserImpl createSimpleParser(ULocale locale, String pattern, int parseFlags)

Creates a parser with most default options. Used for testing, not production.

freezeback to summary
public void freeze()
getParseFlagsback to summary
public int getParseFlags()
parseback to summary
public void parse(String input, boolean greedy, ParsedNumber result)
parseback to summary
public void parse(String input, int start, boolean greedy, ParsedNumber result)

Primary entrypoint to parsing code path.

Parameters
input:String

The string to parse. This is a String, not CharSequence, to enforce assumptions about immutability (CharSequences are not guaranteed to be immutable).

start:int

The index into the string at which to start parsing.

greedy:boolean

Whether to use the faster but potentially less accurate greedy code path.

result:ParsedNumber

Output variable to store results.

parseGreedyback to summary
private void parseGreedy(StringSegment segment, ParsedNumber result)
parseLongestRecursiveback to summary
private void parseLongestRecursive(StringSegment segment, ParsedNumber result, int recursionLevels)
parseStaticback to summary
public static Number parseStatic(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)

Parses the string without returning a NumberParserImpl. Used for testing, not production.

parseStaticCurrencyback to summary
public static CurrencyAmount parseStaticCurrency(String input, ParsePosition ppos, DecimalFormatProperties properties, DecimalFormatSymbols symbols)

Parses the string without returning a NumberParserImpl. Used for testing, not production.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override