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

public Class PatternStringParser

extends Object
Class Inheritance
Imports
com.ibm.icu.impl.number.Padder.PadPosition

Implements a recursive descent parser for decimal format patterns.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PatternStringParser.ParsedPatternInfo

Contains raw information about the parsed decimal format pattern string.

public static class
private static class
PatternStringParser.ParserState

An internal class used for tracking the cursor during parsing of a pattern string.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static long
private static void
private static void
private static void
private static void
private static void
private static void
private static void
private static void
public static void
parseToExistingProperties(String
The pattern string, like "#,##0.00"
pattern
,
DecimalFormatProperties
The property bag object to overwrite.
properties
,
int ignoreRounding)

Parses a pattern string into an existing property bag.

public static void
private static void
parseToExistingPropertiesImpl(String pattern, DecimalFormatProperties properties, int ignoreRounding)

public static PatternStringParser.ParsedPatternInfo

Returns:

The results of the parse.
parseToPatternInfo
(String
The LDML decimal format pattern (Excel-style pattern) to parse.
patternString
)

Runs the recursive descent parser on the given pattern string, returning a data structure with raw information about the pattern string.

public static DecimalFormatProperties

Returns:

A property bag object.
parseToProperties
(String
The pattern string, like "#,##0.00"
pattern
,
int
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 of PatternStringParser#IGNORE_ROUNDING_ALWAYS, PatternStringParser#IGNORE_ROUNDING_IF_CURRENCY, or PatternStringParser#IGNORE_ROUNDING_NEVER.
ignoreRounding
)

Parses a pattern string into a new property bag.

public static DecimalFormatProperties
private static void
patternInfoToProperties(DecimalFormatProperties properties, PatternStringParser.ParsedPatternInfo patternInfo, int _ignoreRounding)

Finalizes the temporary data stored in the ParsedPatternInfo to the Properties.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IGNORE_ROUNDING_ALWAYSback to summary
public static final int IGNORE_ROUNDING_ALWAYS
IGNORE_ROUNDING_IF_CURRENCYback to summary
public static final int IGNORE_ROUNDING_IF_CURRENCY
IGNORE_ROUNDING_NEVERback to summary
public static final int IGNORE_ROUNDING_NEVER

Constructor Detail

PatternStringParserback to summary
public PatternStringParser()

Method Detail

consumeAffixback to summary
private static long consumeAffix(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result)
consumeExponentback to summary
private static void consumeExponent(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result)
consumeFormatback to summary
private static void consumeFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result)
consumeFractionFormatback to summary
private static void consumeFractionFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result)
consumeIntegerFormatback to summary
private static void consumeIntegerFormat(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result)
consumeLiteralback to summary
private static void consumeLiteral(PatternStringParser.ParserState state)
consumePaddingback to summary
private static void consumePadding(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result, Padder.PadPosition paddingLocation)
consumePatternback to summary
private static void consumePattern(PatternStringParser.ParserState state, PatternStringParser.ParsedPatternInfo result)
consumeSubpatternback to summary
private static void consumeSubpattern(PatternStringParser.ParserState state, PatternStringParser.ParsedSubpatternInfo result)
parseToExistingPropertiesback to summary
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:String

The pattern string, like "#,##0.00"

properties:DecimalFormatProperties

The property bag object to overwrite.

ignoreRounding:int

See parseToProperties(String pattern, int ignoreRounding).

Exceptions
IllegalArgumentException:
If there was a syntax error in the pattern string.
parseToExistingPropertiesback to summary
public static void parseToExistingProperties(String pattern, DecimalFormatProperties properties)
parseToExistingPropertiesImplback to summary
private static void parseToExistingPropertiesImpl(String pattern, DecimalFormatProperties properties, int ignoreRounding)
parseToPatternInfoback to summary
public static PatternStringParser.ParsedPatternInfo parseToPatternInfo(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 instead.

Parameters
patternString:String

The LDML decimal format pattern (Excel-style pattern) to parse.

Returns:PatternStringParser.ParsedPatternInfo

The results of the parse.

parseToPropertiesback to summary
public static DecimalFormatProperties parseToProperties(String pattern, int ignoreRounding)

Parses a pattern string into a new property bag.

Parameters
pattern:String

The pattern string, like "#,##0.00"

ignoreRounding:int

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 of PatternStringParser#IGNORE_ROUNDING_ALWAYS, PatternStringParser#IGNORE_ROUNDING_IF_CURRENCY, or PatternStringParser#IGNORE_ROUNDING_NEVER.

Returns:DecimalFormatProperties

A property bag object.

Exceptions
IllegalArgumentException:
If there is a syntax error in the pattern string.
parseToPropertiesback to summary
public static DecimalFormatProperties parseToProperties(String pattern)
patternInfoToPropertiesback to summary
private static void patternInfoToProperties(DecimalFormatProperties properties, PatternStringParser.ParsedPatternInfo patternInfo, int _ignoreRounding)

Finalizes the temporary data stored in the ParsedPatternInfo to the Properties.

com.ibm.icu.impl.number back to summary

public Class PatternStringParser.ParsedPatternInfo

extends Object
implements AffixPatternProvider
Class Inheritance
  • java.lang.Object
  • com.ibm.icu.impl.number.PatternStringParser.ParsedPatternInfo
All Implemented Interfaces
com.ibm.icu.impl.number.AffixPatternProvider

Contains raw information about the parsed decimal format pattern string.

Field Summary

Modifier and TypeField and Description
public PatternStringParser.ParsedSubpatternInfo
public String
public PatternStringParser.ParsedSubpatternInfo

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public char
public boolean
public boolean
currencyAsDecimal()

Implements com.ibm.icu.impl.number.AffixPatternProvider.currencyAsDecimal.

True if the currency symbol should replace the decimal separator.
private long
getEndpoints(int flags)

public static int
getLengthFromEndpoints(long endpoints)

public String
public boolean
hasBody()

Implements com.ibm.icu.impl.number.AffixPatternProvider.hasBody.

True if the pattern has a number placeholder like "0" or "#,##0.00"; false if the pattern does not have one.
public boolean
public boolean
public int
public boolean
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

negativeback to summary
public PatternStringParser.ParsedSubpatternInfo negative
patternback to summary
public String pattern
positiveback to summary
public PatternStringParser.ParsedSubpatternInfo positive

Constructor Detail

ParsedPatternInfoback to summary
private ParsedPatternInfo(String pattern)

Method Detail

charAtback to summary
public char charAt(int flags, int index)

Implements com.ibm.icu.impl.number.AffixPatternProvider.charAt.

Annotations
@Override
containsSymbolTypeback to summary
public boolean containsSymbolType(int type)

Implements com.ibm.icu.impl.number.AffixPatternProvider.containsSymbolType.

Annotations
@Override
currencyAsDecimalback to summary
public boolean currencyAsDecimal()

Implements com.ibm.icu.impl.number.AffixPatternProvider.currencyAsDecimal.

Doc from com.ibm.icu.impl.number.AffixPatternProvider.currencyAsDecimal.

True if the currency symbol should replace the decimal separator.

Annotations
@Override
getEndpointsback to summary
private long getEndpoints(int flags)
getLengthFromEndpointsback to summary
public static int getLengthFromEndpoints(long endpoints)
getStringback to summary
public String getString(int flags)

Implements com.ibm.icu.impl.number.AffixPatternProvider.getString.

Annotations
@Override
hasBodyback to summary
public boolean hasBody()

Implements com.ibm.icu.impl.number.AffixPatternProvider.hasBody.

Doc from com.ibm.icu.impl.number.AffixPatternProvider.hasBody.

True if the pattern has a number placeholder like "0" or "#,##0.00"; false if the pattern does not have one. This is used in cases like compact notation, where the pattern replaces the entire number instead of rendering the number.

Annotations
@Override
hasCurrencySignback to summary
public boolean hasCurrencySign()

Implements com.ibm.icu.impl.number.AffixPatternProvider.hasCurrencySign.

Annotations
@Override
hasNegativeSubpatternback to summary
public boolean hasNegativeSubpattern()

Implements com.ibm.icu.impl.number.AffixPatternProvider.hasNegativeSubpattern.

Annotations
@Override
lengthback to summary
public int length(int flags)

Implements com.ibm.icu.impl.number.AffixPatternProvider.length.

Annotations
@Override
negativeHasMinusSignback to summary
public boolean negativeHasMinusSign()

Implements com.ibm.icu.impl.number.AffixPatternProvider.negativeHasMinusSign.

Annotations
@Override
positiveHasPlusSignback to summary
public boolean positiveHasPlusSign()

Implements com.ibm.icu.impl.number.AffixPatternProvider.positiveHasPlusSign.

Annotations
@Override
com.ibm.icu.impl.number back to summary

public Class PatternStringParser.ParsedSubpatternInfo

extends Object
Class Inheritance
  • java.lang.Object
  • com.ibm.icu.impl.number.PatternStringParser.ParsedSubpatternInfo

Field Summary

Modifier and TypeField and Description
public boolean
public int
public int
public int
public int
public long
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public int
public int
public int
public int
public int
public long
public Padder.PadPosition
public long
public DecimalQuantity_DualStorageBCD
rounding

Deprecated as a consequence of DecimalQuantity_DualStorageBCD being deprecated.
public long
public int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exponentHasPlusSignback to summary
public boolean exponentHasPlusSign
exponentZerosback to summary
public int exponentZeros
fractionHashSignsback to summary
public int fractionHashSigns
fractionNumeralsback to summary
public int fractionNumerals
fractionTotalback to summary
public int fractionTotal
groupingSizesback to summary
public long groupingSizes
hasCurrencyDecimalback to summary
public boolean hasCurrencyDecimal
hasCurrencySignback to summary
public boolean hasCurrencySign
hasDecimalback to summary
public boolean hasDecimal
hasMinusSignback to summary
public boolean hasMinusSign
hasPercentSignback to summary
public boolean hasPercentSign
hasPerMilleSignback to summary
public boolean hasPerMilleSign
hasPlusSignback to summary
public boolean hasPlusSign
integerAtSignsback to summary
public int integerAtSigns
integerLeadingHashSignsback to summary
public int integerLeadingHashSigns
integerNumeralsback to summary
public int integerNumerals
integerTotalback to summary
public int integerTotal
integerTrailingHashSignsback to summary
public int integerTrailingHashSigns
paddingEndpointsback to summary
public long paddingEndpoints
paddingLocationback to summary
public Padder.PadPosition paddingLocation
prefixEndpointsback to summary
public long prefixEndpoints
roundingback to summary
public DecimalQuantity_DualStorageBCD rounding

Deprecated

as a consequence of DecimalQuantity_DualStorageBCD being deprecated. See corresponding docs for further information.

suffixEndpointsback to summary
public long suffixEndpoints
widthExceptAffixesback to summary
public int widthExceptAffixes

Constructor Detail

ParsedSubpatternInfoback to summary
public ParsedSubpatternInfo()
com.ibm.icu.impl.number back to summary

private Class PatternStringParser.ParserState

extends Object
Class Inheritance

An internal class used for tracking the cursor during parsing of a pattern string.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv int
next()

Returns the next code point and then steps forward.

pack-priv int
peek()

Returns the next code point, or -1 if string is too short.

pack-priv int
peek2()

Returns the code point after the next code point, or -1 if string is too short.

pack-priv IllegalArgumentException
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

offsetback to summary
pack-priv int offset
patternback to summary
pack-priv final String pattern

Constructor Detail

ParserStateback to summary
pack-priv ParserState(String pattern)

Method Detail

nextback to summary
pack-priv int next()

Returns the next code point and then steps forward.

peekback to summary
pack-priv int peek()

Returns the next code point, or -1 if string is too short.

peek2back to summary
pack-priv int peek2()

Returns the code point after the next code point, or -1 if string is too short.

toParseExceptionback to summary
pack-priv IllegalArgumentException toParseException(String message)