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

public Class MutablePatternModifier

extends Object
implements Modifier, SymbolProvider, MicroPropsGenerator
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.number.MicroPropsGenerator, com.ibm.icu.impl.number.AffixUtils.SymbolProvider, com.ibm.icu.impl.number.Modifier
Imports
com.ibm.icu.impl.FormattedStringBuilder, .StandardPlural, com.ibm.icu.impl.number.AffixUtils.SymbolProvider, com.ibm.icu.number.NumberFormatter.SignDisplay, .NumberFormatter.UnitWidth, com.ibm.icu.text.DecimalFormatSymbols, .NumberFormat.Field, .PluralRules, com.ibm.icu.util.Currency

This class is a Modifier that wraps a decimal format pattern. It applies the pattern's affixes in Modifier#apply.

In addition to being a Modifier, this class contains the business logic for substituting the correct locale symbols into the affixes of the decimal format pattern.

In order to use this class, create a new instance and call the following four setters: setPatternInfo, setPatternAttributes, setSymbols, and setNumberProperties. After calling these four setters, the instance will be ready for use as a Modifier.

This is a MUTABLE, NON-THREAD-SAFE class designed for performance. Do NOT save references to this or attempt to use it from multiple threads! Instead, you can obtain a safe, immutable decimal format pattern modifier by calling MutablePatternModifier#createImmutable, in effect treating this instance as a builder for the immutable variant.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv Currency
pack-priv StringBuilder
pack-priv NumberFormat.Field
pack-priv final boolean
pack-priv MicroPropsGenerator
pack-priv AffixPatternProvider
pack-priv boolean
pack-priv StandardPlural
pack-priv PluralRules
pack-priv NumberFormatter.SignDisplay
pack-priv Modifier.Signum
pack-priv DecimalFormatSymbols
pack-priv NumberFormatter.UnitWidth

Constructor Summary

AccessConstructor and Description
public
MutablePatternModifier(boolean
Whether the modifier should be considered strong. For more information, see Modifier#isStrong(). Most of the time, decimal format pattern modifiers should be considered as non-strong.
isStrong
)

Method Summary

Modifier and TypeMethod and Description
public MicroPropsGenerator
addToChain(MicroPropsGenerator parent)

Used by the unsafe code path.

public int
apply(FormattedStringBuilder
The string builder to which to apply this modifier.
output
,
int
The left index of the string within the builder. Equal to 0 when only one number is being formatted.
leftIndex
,
int
The right index of the string within the string builder. Equal to length when only one number is being formatted.
rightIndex
)

Implements com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.
public boolean
containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.
private ConstantMultiFieldModifier

Returns:

The constant modifier object.
createConstantModifier
(FormattedStringBuilder
A working FormattedStringBuilder object; passed from the outside to prevent the need to create many new instances if this method is called in a loop.
a
,
FormattedStringBuilder
Another working FormattedStringBuilder object.
b
)

Uses the current properties to create a single ConstantMultiFieldModifier with currency spacing support if required.

public MutablePatternModifier.ImmutablePatternModifier

Returns:

An immutable that supports both positive and negative numbers.
createImmutable
()

Creates a new quantity-dependent Modifier that behaves the same as the current instance, but which is immutable and can be saved for future use.

public int
getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.
public String
getCurrencySymbolForUnitWidth()

Returns the currency symbol for the unit width specified in setSymbols()

public Modifier.Parameters
getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.
public int
getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix.
public CharSequence
getSymbol(int type)

Implements com.ibm.icu.impl.number.AffixUtils.SymbolProvider.getSymbol.

Returns the string that substitutes a given symbol type in a pattern.
private int
private int
public boolean
isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong.
public boolean
needsPlurals()

Returns true if the pattern represented by this MurkyModifier requires a plural keyword in order to localize.

private void
prepareAffix(boolean
true to prepare the prefix; false to prepare the suffix.
isPrefix
)

Pre-processes the prefix or suffix into the currentAffix field, creating and mutating that field if necessary.

public MicroProps
processQuantity(DecimalQuantity
The quantity for consideration and optional mutation.
fq
)

Implements com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Deprecated as a consequence of DecimalQuantity being deprecated.
Considers the given DecimalQuantity, optionally mutates it, and returns a MicroProps.
public boolean
semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Returns whether this Modifier is *semantically equivalent* to the other Modifier; in many cases, this is the same as equal, but parameters should be ignored.
public void
setNumberProperties(Modifier.Signum
-1 if negative; +1 if positive; or 0 if zero.
signum
,
StandardPlural
The plural form of the number, required only if the pattern contains the triple currency sign, "¤¤¤" (and as indicated by needsPlurals()).
plural
)

Sets attributes of the current number being processed.

public void
setPatternAttributes(NumberFormatter.SignDisplay
Whether to force a plus sign on positive numbers.
signDisplay
,
boolean
Whether to substitute the percent sign in the pattern with a permille sign.
perMille
,
boolean
Whether to prepend approximately to the sign
approximately
)

Sets attributes that imply changes to the literal interpretation of the pattern string affixes.

public void
setPatternInfo(AffixPatternProvider patternInfo, NumberFormat.Field
Which field to use for literal characters in the pattern.
field
)

Sets a reference to the parsed decimal format pattern, usually obtained from PatternStringParser#parseToPatternInfo(String), but any implementation of AffixPatternProvider is accepted.

public void
setSymbols(DecimalFormatSymbols
The desired instance of DecimalFormatSymbols.
symbols
,
Currency
The currency to be used when substituting currency values into the affixes.
currency
,
NumberFormatter.UnitWidth
The width used to render currencies.
unitWidth
,
PluralRules
Required if the triple currency sign, "¤¤¤", appears in the pattern, which can be determined from the convenience method needsPlurals().
rules
)

Sets locale-specific details that affect the symbols substituted into the pattern string affixes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

approximatelyback to summary
pack-priv boolean approximately
currencyback to summary
pack-priv Currency currency
currentAffixback to summary
pack-priv StringBuilder currentAffix
fieldback to summary
pack-priv NumberFormat.Field field
isStrongback to summary
pack-priv final boolean isStrong
parentback to summary
pack-priv MicroPropsGenerator parent
patternInfoback to summary
pack-priv AffixPatternProvider patternInfo
perMilleReplacesPercentback to summary
pack-priv boolean perMilleReplacesPercent
pluralback to summary
pack-priv StandardPlural plural
rulesback to summary
pack-priv PluralRules rules
signDisplayback to summary
pack-priv NumberFormatter.SignDisplay signDisplay
signumback to summary
pack-priv Modifier.Signum signum
symbolsback to summary
pack-priv DecimalFormatSymbols symbols
unitWidthback to summary
pack-priv NumberFormatter.UnitWidth unitWidth

Constructor Detail

MutablePatternModifierback to summary
public MutablePatternModifier(boolean isStrong)
Parameters
isStrong:boolean

Whether the modifier should be considered strong. For more information, see Modifier#isStrong(). Most of the time, decimal format pattern modifiers should be considered as non-strong.

Method Detail

addToChainback to summary
public MicroPropsGenerator addToChain(MicroPropsGenerator parent)

Used by the unsafe code path.

applyback to summary
public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex)

Implements com.ibm.icu.impl.number.Modifier.apply.

Doc from com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.

Parameters
output:FormattedStringBuilder

The string builder to which to apply this modifier.

leftIndex:int

The left index of the string within the builder. Equal to 0 when only one number is being formatted.

rightIndex:int

The right index of the string within the string builder. Equal to length when only one number is being formatted.

Returns:int

The number of characters (UTF-16 code units) that were added to the string builder.

Annotations
@Override
containsFieldback to summary
public boolean containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Doc from com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.

Annotations
@Override
createConstantModifierback to summary
private ConstantMultiFieldModifier createConstantModifier(FormattedStringBuilder a, FormattedStringBuilder b)

Uses the current properties to create a single ConstantMultiFieldModifier with currency spacing support if required.

Parameters
a:FormattedStringBuilder

A working FormattedStringBuilder object; passed from the outside to prevent the need to create many new instances if this method is called in a loop.

b:FormattedStringBuilder

Another working FormattedStringBuilder object.

Returns:ConstantMultiFieldModifier

The constant modifier object.

createImmutableback to summary
public MutablePatternModifier.ImmutablePatternModifier createImmutable()

Creates a new quantity-dependent Modifier that behaves the same as the current instance, but which is immutable and can be saved for future use. The number properties in the current instance are mutated; all other properties are left untouched.

The resulting modifier cannot be used in a QuantityChain.

Returns:MutablePatternModifier.ImmutablePatternModifier

An immutable that supports both positive and negative numbers.

getCodePointCountback to summary
public int getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Doc from com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.

Annotations
@Override
getCurrencySymbolForUnitWidthback to summary
public String getCurrencySymbolForUnitWidth()

Returns the currency symbol for the unit width specified in setSymbols()

getParametersback to summary
public Modifier.Parameters getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Doc from com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.

Annotations
@Override
getPrefixLengthback to summary
public int getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Doc from com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix. This information can be used in combination with apply to extract the prefix and suffix strings.

Returns:int

The number of characters (UTF-16 code units) in the prefix.

Annotations
@Override
getSymbolback to summary
public CharSequence getSymbol(int type)

Implements com.ibm.icu.impl.number.AffixUtils.SymbolProvider.getSymbol.

Returns the string that substitutes a given symbol type in a pattern.

Annotations
@Override
insertPrefixback to summary
private int insertPrefix(FormattedStringBuilder sb, int position)
insertSuffixback to summary
private int insertSuffix(FormattedStringBuilder sb, int position)
isStrongback to summary
public boolean isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Doc from com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong. If a modifier is strong, it should always be applied immediately and not allowed to bubble up. With regard to padding, strong modifiers are considered to be on the inside of the prefix and suffix.

Returns:boolean

Whether the modifier is strong.

Annotations
@Override
needsPluralsback to summary
public boolean needsPlurals()

Returns true if the pattern represented by this MurkyModifier requires a plural keyword in order to localize. This is currently true only if there is a currency long name placeholder in the pattern ("¤¤¤").

prepareAffixback to summary
private void prepareAffix(boolean isPrefix)

Pre-processes the prefix or suffix into the currentAffix field, creating and mutating that field if necessary. Calls down to PatternStringUtils#affixPatternProviderToStringBuilder.

Parameters
isPrefix:boolean

true to prepare the prefix; false to prepare the suffix.

processQuantityback to summary
public MicroProps processQuantity(DecimalQuantity fq)

Implements com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Doc from com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Deprecated

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

Considers the given DecimalQuantity, optionally mutates it, and returns a MicroProps.

Parameters
fq:DecimalQuantity

The quantity for consideration and optional mutation.

Returns:MicroProps

A MicroProps instance resolved for the quantity.

Annotations
@Override
semanticallyEquivalentback to summary
public boolean semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Doc from com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Returns whether this Modifier is *semantically equivalent* to the other Modifier; in many cases, this is the same as equal, but parameters should be ignored.

Annotations
@Override
setNumberPropertiesback to summary
public void setNumberProperties(Modifier.Signum signum, StandardPlural plural)

Sets attributes of the current number being processed.

Parameters
signum:Modifier.Signum

-1 if negative; +1 if positive; or 0 if zero.

plural:StandardPlural

The plural form of the number, required only if the pattern contains the triple currency sign, "¤¤¤" (and as indicated by needsPlurals()).

setPatternAttributesback to summary
public void setPatternAttributes(NumberFormatter.SignDisplay signDisplay, boolean perMille, boolean approximately)

Sets attributes that imply changes to the literal interpretation of the pattern string affixes.

Parameters
signDisplay:NumberFormatter.SignDisplay

Whether to force a plus sign on positive numbers.

perMille:boolean

Whether to substitute the percent sign in the pattern with a permille sign.

approximately:boolean

Whether to prepend approximately to the sign

setPatternInfoback to summary
public void setPatternInfo(AffixPatternProvider patternInfo, NumberFormat.Field field)

Sets a reference to the parsed decimal format pattern, usually obtained from PatternStringParser#parseToPatternInfo(String), but any implementation of AffixPatternProvider is accepted.

Parameters
field:NumberFormat.Field

Which field to use for literal characters in the pattern.

setSymbolsback to summary
public void setSymbols(DecimalFormatSymbols symbols, Currency currency, NumberFormatter.UnitWidth unitWidth, PluralRules rules)

Sets locale-specific details that affect the symbols substituted into the pattern string affixes.

Parameters
symbols:DecimalFormatSymbols

The desired instance of DecimalFormatSymbols.

currency:Currency

The currency to be used when substituting currency values into the affixes.

unitWidth:NumberFormatter.UnitWidth

The width used to render currencies.

rules:PluralRules

Required if the triple currency sign, "¤¤¤", appears in the pattern, which can be determined from the convenience method needsPlurals().

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

public Class MutablePatternModifier.ImmutablePatternModifier

extends Object
implements MicroPropsGenerator
Class Inheritance
  • java.lang.Object
  • com.ibm.icu.impl.number.MutablePatternModifier.ImmutablePatternModifier
All Implemented Interfaces
com.ibm.icu.impl.number.MicroPropsGenerator

Field Summary

Modifier and TypeField and Description
pack-priv MicroPropsGenerator
pack-priv final AdoptingModifierStore
pack-priv final PluralRules

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public MutablePatternModifier.ImmutablePatternModifier
public void
applyToMicros(MicroProps micros, DecimalQuantity quantity)

Deprecated as a consequence of DecimalQuantity being deprecated.
public MicroProps
processQuantity(DecimalQuantity
The quantity for consideration and optional mutation.
quantity
)

Implements com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Deprecated as a consequence of DecimalQuantity being deprecated.
Considers the given DecimalQuantity, optionally mutates it, and returns a MicroProps.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

parentback to summary
pack-priv MicroPropsGenerator parent
pmback to summary
pack-priv final AdoptingModifierStore pm
rulesback to summary
pack-priv final PluralRules rules

Constructor Detail

ImmutablePatternModifierback to summary
pack-priv ImmutablePatternModifier(AdoptingModifierStore pm, PluralRules rules)

Method Detail

addToChainback to summary
public MutablePatternModifier.ImmutablePatternModifier addToChain(MicroPropsGenerator parent)
applyToMicrosback to summary
public void applyToMicros(MicroProps micros, DecimalQuantity quantity)

Deprecated

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

processQuantityback to summary
public MicroProps processQuantity(DecimalQuantity quantity)

Implements com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Doc from com.ibm.icu.impl.number.MicroPropsGenerator.processQuantity.

Deprecated

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

Considers the given DecimalQuantity, optionally mutates it, and returns a MicroProps.

Parameters
quantity:DecimalQuantity

The quantity for consideration and optional mutation.

Returns:MicroProps

A MicroProps instance resolved for the quantity.

Annotations
@Override