Package com.ibm.icu.impl.number
Class PatternStringParser
- java.lang.Object
-
- com.ibm.icu.impl.number.PatternStringParser
-
public class PatternStringParser extends java.lang.Object
Implements a recursive descent parser for decimal format patterns.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PatternStringParser.ParsedPatternInfo
Contains raw information about the parsed decimal format pattern string.static class
PatternStringParser.ParsedSubpatternInfo
private static class
PatternStringParser.ParserState
An internal class used for tracking the cursor during parsing of a pattern string.
-
Field Summary
Fields Modifier and Type Field Description static int
IGNORE_ROUNDING_ALWAYS
static int
IGNORE_ROUNDING_IF_CURRENCY
static int
IGNORE_ROUNDING_NEVER
-
Constructor Summary
Constructors Constructor Description PatternStringParser()
-
Method Summary
-
-
-
Field Detail
-
IGNORE_ROUNDING_NEVER
public static final int IGNORE_ROUNDING_NEVER
- See Also:
- Constant Field Values
-
IGNORE_ROUNDING_IF_CURRENCY
public static final int IGNORE_ROUNDING_IF_CURRENCY
- See Also:
- Constant Field Values
-
IGNORE_ROUNDING_ALWAYS
public static final int IGNORE_ROUNDING_ALWAYS
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseToPatternInfo
public static PatternStringParser.ParsedPatternInfo parseToPatternInfo(java.lang.String patternString)
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(java.lang.String, int)
instead.- Parameters:
patternString
- The LDML decimal format pattern (Excel-style pattern) to parse.- Returns:
- The results of the parse.
-
parseToProperties
public static DecimalFormatProperties parseToProperties(java.lang.String pattern, int ignoreRounding)
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:
java.lang.IllegalArgumentException
- If there is a syntax error in the pattern string.
-
parseToProperties
public static DecimalFormatProperties parseToProperties(java.lang.String pattern)
-
parseToExistingProperties
public static void parseToExistingProperties(java.lang.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:
java.lang.IllegalArgumentException
- If there was a syntax error in the pattern string.
-
parseToExistingProperties
public static void parseToExistingProperties(java.lang.String pattern, DecimalFormatProperties properties)
-
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
private static void consumeLiteral(PatternStringParser.ParserState state)
-
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(java.lang.String pattern, DecimalFormatProperties properties, int ignoreRounding)
-
patternInfoToProperties
private static void patternInfoToProperties(DecimalFormatProperties properties, PatternStringParser.ParsedPatternInfo patternInfo, int _ignoreRounding)
Finalizes the temporary data stored in the ParsedPatternInfo to the Properties.
-
-