Package com.ibm.icu.number
Class LocalizedNumberFormatter
- java.lang.Object
-
- com.ibm.icu.number.NumberFormatterSettings<LocalizedNumberFormatter>
-
- com.ibm.icu.number.LocalizedNumberFormatter
-
public class LocalizedNumberFormatter extends NumberFormatterSettings<LocalizedNumberFormatter>
A NumberFormatter that has a locale associated with it; this means .format() methods are available. Instances of this class are immutable and thread-safe.- See Also:
NumberFormatter
,NumberFormatter
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.concurrent.atomic.AtomicLongFieldUpdater<LocalizedNumberFormatter>
callCount
(package private) long
callCountInternal
(package private) NumberFormatterImpl
compiled
(package private) LocalizedNumberFormatter
savedWithUnit
-
Fields inherited from class com.ibm.icu.number.NumberFormatterSettings
KEY_DECIMAL, KEY_GROUPING, KEY_INTEGER, KEY_LOCALE, KEY_MACROS, KEY_MAX, KEY_NOTATION, KEY_PADDER, KEY_PER_UNIT, KEY_PRECISION, KEY_ROUNDING_MODE, KEY_SCALE, KEY_SIGN, KEY_SYMBOLS, KEY_THRESHOLD, KEY_UNIT, KEY_UNIT_DISPLAY_CASE, KEY_UNIT_WIDTH, KEY_USAGE
-
-
Constructor Summary
Constructors Constructor Description LocalizedNumberFormatter(NumberFormatterSettings<?> parent, int key, java.lang.Object value)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private boolean
computeCompiled()
(package private) LocalizedNumberFormatter
create(int key, java.lang.Object value)
FormattedNumber
format(double input)
Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.FormattedNumber
format(long input)
Format the given byte, short, int, or long to a string using the settings specified in the NumberFormatter fluent setting chain.private FormattedNumber
format(DecimalQuantity fq)
Helper method that creates a FormattedStringBuilder and formats.FormattedNumber
format(Measure input)
Format the givenMeasure
orCurrencyAmount
to a string using the settings specified in the NumberFormatter fluent setting chain.FormattedNumber
format(java.lang.Number input)
Format the givenBigInteger
,BigDecimal
, or otherNumber
to a string using the settings specified in the NumberFormatter fluent setting chain.MicroProps
formatImpl(DecimalQuantity fq, FormattedStringBuilder string)
Deprecated.ICU 60 This API is ICU internal only.MicroProps
formatImpl(DecimalQuantity fq, MeasureUnit unit, FormattedStringBuilder string)
Deprecated.ICU 67 This API is ICU internal only.java.lang.String
getAffixImpl(boolean isPrefix, boolean isNegative)
Deprecated.This API is ICU internal only.java.text.Format
toFormat()
Creates a representation of this LocalizedNumberFormat as aFormat
, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.UnlocalizedNumberFormatter
withoutLocale()
Disassociate the locale from this formatter.-
Methods inherited from class com.ibm.icu.number.NumberFormatterSettings
decimal, displayOptions, equals, grouping, hashCode, integerWidth, macros, notation, padding, perUnit, precision, resolve, roundingMode, scale, sign, symbols, symbols, threshold, toSkeleton, unit, unitDisplayCase, unitWidth, usage
-
-
-
-
Field Detail
-
callCount
static final java.util.concurrent.atomic.AtomicLongFieldUpdater<LocalizedNumberFormatter> callCount
-
callCountInternal
volatile long callCountInternal
-
savedWithUnit
volatile LocalizedNumberFormatter savedWithUnit
-
compiled
volatile NumberFormatterImpl compiled
-
-
Constructor Detail
-
LocalizedNumberFormatter
LocalizedNumberFormatter(NumberFormatterSettings<?> parent, int key, java.lang.Object value)
-
-
Method Detail
-
format
public FormattedNumber format(long input)
Format the given byte, short, int, or long to a string using the settings specified in the NumberFormatter fluent setting chain.- Parameters:
input
- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
NumberFormatter
-
format
public FormattedNumber format(double input)
Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting chain.- Parameters:
input
- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
NumberFormatter
-
format
public FormattedNumber format(java.lang.Number input)
Format the givenBigInteger
,BigDecimal
, or otherNumber
to a string using the settings specified in the NumberFormatter fluent setting chain.- Parameters:
input
- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
NumberFormatter
-
format
public FormattedNumber format(Measure input)
Format the givenMeasure
orCurrencyAmount
to a string using the settings specified in the NumberFormatter fluent setting chain.The unit specified here overrides any unit that may have been specified in the setter chain. This method is intended for cases when each input to the number formatter has a different unit.
- Parameters:
input
- The number to format.- Returns:
- A FormattedNumber object; call .toString() to get the string.
- See Also:
NumberFormatter
-
toFormat
public java.text.Format toFormat()
Creates a representation of this LocalizedNumberFormat as aFormat
, enabling the use of this number formatter with APIs that need an object of that type, such as MessageFormat.This API is not intended to be used other than for enabling API compatibility. The
format(long)
methods should normally be used when formatting numbers, not the Format object returned by this method.- Returns:
- A Format wrapping this LocalizedNumberFormatter.
- See Also:
NumberFormatter
-
withoutLocale
public UnlocalizedNumberFormatter withoutLocale()
Disassociate the locale from this formatter.- Returns:
- The fluent chain.
-
format
private FormattedNumber format(DecimalQuantity fq)
Helper method that creates a FormattedStringBuilder and formats.
-
formatImpl
@Deprecated public MicroProps formatImpl(DecimalQuantity fq, FormattedStringBuilder string)
Deprecated.ICU 60 This API is ICU internal only.This is the core entrypoint to the number formatting pipeline. It performs self-regulation: a static code path for the first few calls, and compiling a more efficient data structure if called repeatedly.This function is very hot, being called in every call to the number formatting pipeline.
- Parameters:
fq
- The quantity to be formatted.string
- The string builder into which to insert the result.
-
formatImpl
@Deprecated public MicroProps formatImpl(DecimalQuantity fq, MeasureUnit unit, FormattedStringBuilder string)
Deprecated.ICU 67 This API is ICU internal only.Version of above for unit override.
-
getAffixImpl
@Deprecated public java.lang.String getAffixImpl(boolean isPrefix, boolean isNegative)
Deprecated.This API is ICU internal only. UseFormattedNumber.nextPosition(com.ibm.icu.text.ConstrainedFieldPosition)
for related functionality.
-
computeCompiled
private boolean computeCompiled()
-
create
LocalizedNumberFormatter create(int key, java.lang.Object value)
- Specified by:
create
in classNumberFormatterSettings<LocalizedNumberFormatter>
-
-