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

public Class PatternStringUtils

extends Object
Class Inheritance
Imports
java.math.BigDecimal, com.ibm.icu.impl.StandardPlural, com.ibm.icu.impl.number.Modifier.Signum, .Padder.PadPosition, com.ibm.icu.number.NumberFormatter.SignDisplay, com.ibm.icu.text.DecimalFormatSymbols

Assorted utilities relating to decimal formatting pattern strings.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

The pattern expressed in the other notation.
convertLocalized
(String
The pattern to convert.
input
,
DecimalFormatSymbols
The symbols corresponding to the localized pattern.
symbols
,
boolean
true to convert from standard to localized notation; false to convert from localized to standard notation.
toLocalized
)

Converts a pattern between standard notation and localized notation.

private static int

Returns:

The number of chars inserted.
escapePaddingString
(CharSequence input, StringBuilder output, int startIndex)

public static boolean

Returns:

true if roundIncr should be ignored for formatting.
ignoreRoundingIncrement
(BigDecimal
The roundingIncrement to be checked. Must be non-null.
roundIncrDec
,
int
The current maximum fraction digits value.
maxFrac
)

Determine whether a given roundingIncrement should be ignored for formatting based on the current maxFrac value (maximum fraction digits).

public static void
patternInfoToStringBuilder(AffixPatternProvider patternInfo, boolean isPrefix, PatternStringUtils.PatternSignType patternSignType, boolean approximately, StandardPlural plural, boolean perMilleReplacesPercent, StringBuilder output)

This method contains the heart of the logic for rendering LDML affix strings.

public static String

Returns:

A pattern string approximately serializing the property bag.
propertiesToPatternString
(DecimalFormatProperties
The property bag to serialize.
properties
)

Creates a pattern string from a property bag.

public static PatternStringUtils.PatternSignType
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PatternStringUtilsback to summary
public PatternStringUtils()

Method Detail

convertLocalizedback to summary
public static String convertLocalized(String input, DecimalFormatSymbols symbols, boolean toLocalized)

Converts a pattern between standard notation and localized notation. Localized notation means that instead of using generic placeholders in the pattern, you use the corresponding locale-specific characters instead. For example, in locale fr-FR, the period in the pattern "0.000" means "decimal" in standard notation (as it does in every other locale), but it means "grouping" in localized notation.

A greedy string-substitution strategy is used to substitute locale symbols. If two symbols are ambiguous or have the same prefix, the result is not well-defined.

Locale symbols are not allowed to contain the ASCII quote character.

This method is provided for backwards compatibility and should not be used in any new code.

Parameters
input:String

The pattern to convert.

symbols:DecimalFormatSymbols

The symbols corresponding to the localized pattern.

toLocalized:boolean

true to convert from standard to localized notation; false to convert from localized to standard notation.

Returns:String

The pattern expressed in the other notation.

escapePaddingStringback to summary
private static int escapePaddingString(CharSequence input, StringBuilder output, int startIndex)
Returns:int

The number of chars inserted.

ignoreRoundingIncrementback to summary
public static boolean ignoreRoundingIncrement(BigDecimal roundIncrDec, int maxFrac)

Determine whether a given roundingIncrement should be ignored for formatting based on the current maxFrac value (maximum fraction digits). For example a roundingIncrement of 0.01 should be ignored if maxFrac is 1, but not if maxFrac is 2 or more. Note that roundingIncrements are rounded up in significance, so a roundingIncrement of 0.006 is treated like 0.01 for this determination, i.e. it should not be ignored if maxFrac is 2 or more (but a roundingIncrement of 0.005 is treated like 0.001 for significance). This test is needed for both NumberPropertyMapper.oldToNew and PatternStringUtils.propertiesToPatternString, but NumberPropertyMapper is package-private so we have it here.

Parameters
roundIncrDec:BigDecimal

The roundingIncrement to be checked. Must be non-null.

maxFrac:int

The current maximum fraction digits value.

Returns:boolean

true if roundIncr should be ignored for formatting.

patternInfoToStringBuilderback to summary
public static void patternInfoToStringBuilder(AffixPatternProvider patternInfo, boolean isPrefix, PatternStringUtils.PatternSignType patternSignType, boolean approximately, StandardPlural plural, boolean perMilleReplacesPercent, StringBuilder output)

This method contains the heart of the logic for rendering LDML affix strings. It handles sign-always-shown resolution, whether to use the positive or negative subpattern, permille substitution, and plural forms for CurrencyPluralInfo.

propertiesToPatternStringback to summary
public static String propertiesToPatternString(DecimalFormatProperties properties)

Creates a pattern string from a property bag.

Since pattern strings support only a subset of the functionality available in a property bag, a new property bag created from the string returned by this function may not be the same as the original property bag.

Parameters
properties:DecimalFormatProperties

The property bag to serialize.

Returns:String

A pattern string approximately serializing the property bag.

resolveSignDisplayback to summary
public static PatternStringUtils.PatternSignType resolveSignDisplay(NumberFormatter.SignDisplay signDisplay, Modifier.Signum signum)
com.ibm.icu.impl.number back to summary

public final Enum PatternStringUtils.PatternSignType

extends Enum<PatternStringUtils.PatternSignType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PatternStringUtils.PatternSignType
public static final PatternStringUtils.PatternSignType
public static final PatternStringUtils.PatternSignType
public static final PatternStringUtils.PatternSignType[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PatternStringUtils.PatternSignType
public static PatternStringUtils.PatternSignType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NEGback to summary
public static final PatternStringUtils.PatternSignType NEG
POSback to summary
public static final PatternStringUtils.PatternSignType POS
POS_SIGNback to summary
public static final PatternStringUtils.PatternSignType POS_SIGN
VALUESback to summary
public static final PatternStringUtils.PatternSignType[] VALUES

Constructor Detail

PatternSignTypeback to summary
private PatternSignType()

Method Detail

valueOfback to summary
public static PatternStringUtils.PatternSignType valueOf(String name)
valuesback to summary
public static PatternStringUtils.PatternSignType[] values()