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

pack-priv Class NumberFormatterImpl

extends Object
Class Inheritance
Imports
com.ibm.icu.impl.FormattedStringBuilder, .IllegalIcuArgumentException, .StandardPlural, com.ibm.icu.impl.number.AffixPatternProvider, .CompactData.CompactType, .ConstantAffixModifier, .DecimalQuantity, .DecimalQuantity_DualStorageBCD, .Grouper, .LongNameHandler, .LongNameMultiplexer, .MacroProps, .MicroProps, .MicroPropsGenerator, .MixedUnitLongNameHandler, .MultiplierFormatHandler, .MutablePatternModifier, .MutablePatternModifier.ImmutablePatternModifier, .Padder, .PatternStringParser, .PatternStringParser.ParsedPatternInfo, .RoundingUtils, .UnitConversionHandler, .UsagePrefsHandler, com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay, .NumberFormatter.GroupingStrategy, .NumberFormatter.SignDisplay, .NumberFormatter.UnitWidth, com.ibm.icu.text.DecimalFormatSymbols, .NumberFormat, .NumberingSystem, .PluralRules, com.ibm.icu.util.Currency, .MeasureUnit

This is the "brain" of the number formatting pipeline. It ties all the pieces together, taking in a MacroProps and a DecimalQuantity and outputting a properly formatted number string.

This class, as well as NumberPropertyMapper, could go into the impl package, but they depend on too many package-private members of the public APIs.

Field Summary

Modifier and TypeField and Description
private static final Currency
pack-priv final MicroPropsGenerator
pack-priv final MicroProps

Constructor Summary

AccessConstructor and Description
public
NumberFormatterImpl(MacroProps macros)

Builds a "safe" MicroPropsGenerator, which is thread-safe and can be used repeatedly.

Method Summary

Modifier and TypeMethod and Description
public MicroProps
format(DecimalQuantity inValue, FormattedStringBuilder outString)

Deprecated as a consequence of DecimalQuantity being deprecated.
Evaluates the "safe" MicroPropsGenerator created by "fromMacros".
public static MicroProps
formatStatic(MacroProps macros, DecimalQuantity inValue, FormattedStringBuilder outString)

Deprecated as a consequence of DecimalQuantity being deprecated.
Builds and evaluates an "unsafe" MicroPropsGenerator, which is cheaper but can be used only once.
public int
private static int
public static int

Returns:

The index into the output at which the prefix ends and the suffix starts; in other words, the prefix length.
getPrefixSuffixStatic
(MacroProps macros, byte signum, StandardPlural plural, FormattedStringBuilder output)

Prints only the prefix and suffix; used for DecimalFormat getters.

public MicroProps
private static MicroPropsGenerator
macrosToMicroGenerator(MacroProps
The MacroProps to consume. This method does not mutate the MacroProps instance.
macros
,
MicroProps micros, boolean
If true, the returned MicroPropsGenerator will be thread-safe. If false, the returned value will not be thread-safe, intended for a single "one-shot" use only. Building the thread-safe object is more expensive.
safe
)

Synthesizes the MacroProps into a MicroPropsGenerator.

public MicroProps
preProcess(DecimalQuantity inValue)

Deprecated as a consequence of DecimalQuantity being deprecated.
Like format(), but saves the result into an output MicroProps without additional processing.
private static MicroProps
preProcessUnsafe(MacroProps macros, DecimalQuantity inValue)

Deprecated as a consequence of DecimalQuantity being deprecated.
private static boolean
private static boolean
private static boolean
private static boolean
public static int
writeAffixes(MicroProps micros, FormattedStringBuilder string, int start, int end)

Adds the affixes.

private static int
writeFractionDigits(MicroProps micros, DecimalQuantity quantity, FormattedStringBuilder string, int index)

Deprecated as a consequence of DecimalQuantity being deprecated.
private static int
writeIntegerDigits(MicroProps micros, DecimalQuantity quantity, FormattedStringBuilder string, int index)

Deprecated as a consequence of DecimalQuantity being deprecated.
public static int
writeNumber(MicroProps micros, DecimalQuantity quantity, FormattedStringBuilder string, int index)

Deprecated as a consequence of DecimalQuantity being deprecated.
Synthesizes the output string from a MicroProps and DecimalQuantity.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CURRENCYback to summary
private static final Currency DEFAULT_CURRENCY
microPropsGeneratorback to summary
pack-priv final MicroPropsGenerator microPropsGenerator
microsback to summary
pack-priv final MicroProps micros

Constructor Detail

NumberFormatterImplback to summary
public NumberFormatterImpl(MacroProps macros)

Builds a "safe" MicroPropsGenerator, which is thread-safe and can be used repeatedly.

Method Detail

formatback to summary
public MicroProps format(DecimalQuantity inValue, FormattedStringBuilder outString)

Deprecated

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

Evaluates the "safe" MicroPropsGenerator created by "fromMacros".

formatStaticback to summary
public static MicroProps formatStatic(MacroProps macros, DecimalQuantity inValue, FormattedStringBuilder outString)

Deprecated

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

Builds and evaluates an "unsafe" MicroPropsGenerator, which is cheaper but can be used only once.

getPrefixSuffixback to summary
public int getPrefixSuffix(byte signum, StandardPlural plural, FormattedStringBuilder output)
getPrefixSuffixImplback to summary
private static int getPrefixSuffixImpl(MicroPropsGenerator generator, byte signum, FormattedStringBuilder output)
getPrefixSuffixStaticback to summary
public static int getPrefixSuffixStatic(MacroProps macros, byte signum, StandardPlural plural, FormattedStringBuilder output)

Prints only the prefix and suffix; used for DecimalFormat getters.

Returns:int

The index into the output at which the prefix ends and the suffix starts; in other words, the prefix length.

getRawMicroPropsback to summary
public MicroProps getRawMicroProps()
macrosToMicroGeneratorback to summary
private static MicroPropsGenerator macrosToMicroGenerator(MacroProps macros, MicroProps micros, boolean safe)

Synthesizes the MacroProps into a MicroPropsGenerator. All information, including the locale, is encoded into the MicroPropsGenerator, except for the quantity itself, which is left abstract and must be provided to the returned MicroPropsGenerator instance.

Parameters
macros:MacroProps

The MacroProps to consume. This method does not mutate the MacroProps instance.

safe:boolean

If true, the returned MicroPropsGenerator will be thread-safe. If false, the returned value will not be thread-safe, intended for a single "one-shot" use only. Building the thread-safe object is more expensive.

See Also
MicroPropsGenerator
preProcessback to summary
public MicroProps preProcess(DecimalQuantity inValue)

Deprecated

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

Like format(), but saves the result into an output MicroProps without additional processing.

preProcessUnsafeback to summary
private static MicroProps preProcessUnsafe(MacroProps macros, DecimalQuantity inValue)

Deprecated

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

unitIsBaseUnitback to summary
private static boolean unitIsBaseUnit(MeasureUnit unit)
unitIsCurrencyback to summary
private static boolean unitIsCurrency(MeasureUnit unit)
unitIsPercentback to summary
private static boolean unitIsPercent(MeasureUnit unit)
unitIsPermilleback to summary
private static boolean unitIsPermille(MeasureUnit unit)
writeAffixesback to summary
public static int writeAffixes(MicroProps micros, FormattedStringBuilder string, int start, int end)

Adds the affixes. Intended to be called immediately after formatNumber.

writeFractionDigitsback to summary
private static int writeFractionDigits(MicroProps micros, DecimalQuantity quantity, FormattedStringBuilder string, int index)

Deprecated

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

writeIntegerDigitsback to summary
private static int writeIntegerDigits(MicroProps micros, DecimalQuantity quantity, FormattedStringBuilder string, int index)

Deprecated

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

writeNumberback to summary
public static int writeNumber(MicroProps micros, DecimalQuantity quantity, FormattedStringBuilder string, int index)

Deprecated

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

Synthesizes the output string from a MicroProps and DecimalQuantity. This method formats only the main number, not affixes.