Class PatternStringParser
java.lang.Object
com.ibm.icu.impl.number.PatternStringParser
Implements a recursive descent parser for decimal format patterns.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContains raw information about the parsed decimal format pattern string.static classprivate static classAn internal class used for tracking the cursor during parsing of a pattern string. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static longconsumeAffix(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) private static voidconsumeExponent(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) private static voidconsumeFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) private static voidconsumeFractionFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) private static voidconsumeIntegerFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) private static voidprivate static voidconsumePadding(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result, Padder.PadPosition paddingLocation) private static voidprivate static voidconsumeSubpattern(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) static voidparseToExistingProperties(String pattern, DecimalFormatProperties properties) static voidparseToExistingProperties(String pattern, DecimalFormatProperties properties, int ignoreRounding) Parses a pattern string into an existing property bag.private static voidparseToExistingPropertiesImpl(String pattern, DecimalFormatProperties properties, int ignoreRounding) //////////////////////////////////////////////// END RECURSIVE DESCENT PARSER IMPLEMENTATION /// ////////////////////////////////////////////////parseToPatternInfo(String patternString) Runs the recursive descent parser on the given pattern string, returning a data structure with raw information about the pattern string.static DecimalFormatPropertiesparseToProperties(String pattern) static DecimalFormatPropertiesparseToProperties(String pattern, int ignoreRounding) Parses a pattern string into a new property bag.private static voidpatternInfoToProperties(DecimalFormatProperties properties, PatternStringParser.ParsedPatternInfo patternInfo, int _ignoreRounding) Finalizes the temporary data stored in the ParsedPatternInfo to the Properties.
-
Field Details
-
IGNORE_ROUNDING_NEVER
public static final int IGNORE_ROUNDING_NEVER- See Also:
-
IGNORE_ROUNDING_IF_CURRENCY
public static final int IGNORE_ROUNDING_IF_CURRENCY- See Also:
-
IGNORE_ROUNDING_ALWAYS
public static final int IGNORE_ROUNDING_ALWAYS- See Also:
-
-
Constructor Details
-
PatternStringParser
public PatternStringParser()
-
-
Method Details
-
parseToPatternInfo
Runs the recursive descent parser on the given pattern string, returning a data structure with raw information about the pattern string.To obtain a more useful form of the data, consider using
parseToProperties(String, int)instead.- Parameters:
patternString- The LDML decimal format pattern (Excel-style pattern) to parse.- Returns:
- The results of the parse.
-
parseToProperties
Parses a pattern string into a new property bag.- Parameters:
pattern- The pattern string, like "#,##0.00"ignoreRounding- Whether to leave out rounding information (minFrac, maxFrac, and rounding increment) when parsing the pattern. This may be desirable if a custom rounding mode, such as CurrencyUsage, is to be used instead. One ofIGNORE_ROUNDING_ALWAYS,IGNORE_ROUNDING_IF_CURRENCY, orIGNORE_ROUNDING_NEVER.- Returns:
- A property bag object.
- Throws:
IllegalArgumentException- If there is a syntax error in the pattern string.
-
parseToProperties
-
parseToExistingProperties
public static void parseToExistingProperties(String pattern, DecimalFormatProperties properties, int ignoreRounding) Parses a pattern string into an existing property bag. All properties that can be encoded into a pattern string will be overwritten with either their default value or with the value coming from the pattern string. Properties that cannot be encoded into a pattern string, such as rounding mode, are not modified.- Parameters:
pattern- The pattern string, like "#,##0.00"properties- The property bag object to overwrite.ignoreRounding- SeeparseToProperties(String pattern, int ignoreRounding).- Throws:
IllegalArgumentException- If there was a syntax error in the pattern string.
-
parseToExistingProperties
-
consumePattern
private static void consumePattern(PatternStringParser.ParserState state, PatternStringParser.ParsedPatternInfo result) -
consumeSubpattern
private static void consumeSubpattern(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) -
consumePadding
private static void consumePadding(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result, Padder.PadPosition paddingLocation) -
consumeAffix
private static long consumeAffix(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) -
consumeLiteral
-
consumeFormat
private static void consumeFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) -
consumeIntegerFormat
private static void consumeIntegerFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) -
consumeFractionFormat
private static void consumeFractionFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) -
consumeExponent
private static void consumeExponent(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result) -
parseToExistingPropertiesImpl
private static void parseToExistingPropertiesImpl(String pattern, DecimalFormatProperties properties, int ignoreRounding) //////////////////////////////////////////////// END RECURSIVE DESCENT PARSER IMPLEMENTATION /// //////////////////////////////////////////////// -
patternInfoToProperties
private static void patternInfoToProperties(DecimalFormatProperties properties, PatternStringParser.ParsedPatternInfo patternInfo, int _ignoreRounding) Finalizes the temporary data stored in the ParsedPatternInfo to the Properties.
-