Package com.ibm.icu.number
Class NumberRangeFormatterSettings<T extends NumberRangeFormatterSettings<?>>
- java.lang.Object
-
- com.ibm.icu.number.NumberRangeFormatterSettings<T>
-
- Direct Known Subclasses:
LocalizedNumberRangeFormatter
,UnlocalizedNumberRangeFormatter
public abstract class NumberRangeFormatterSettings<T extends NumberRangeFormatterSettings<?>> extends java.lang.Object
An abstract base class for specifying settings related to number formatting. This class is implemented byUnlocalizedNumberRangeFormatter
andLocalizedNumberRangeFormatter
. This class is not intended for public subclassing.- See Also:
NumberRangeFormatter
-
-
Field Summary
Fields Modifier and Type Field Description private int
key
(package private) static int
KEY_COLLAPSE
(package private) static int
KEY_FORMATTER_1
(package private) static int
KEY_FORMATTER_2
(package private) static int
KEY_IDENTITY_FALLBACK
(package private) static int
KEY_LOCALE
(package private) static int
KEY_MACROS
(package private) static int
KEY_MAX
(package private) static int
KEY_SAME_FORMATTERS
private NumberRangeFormatterSettings<?>
parent
private RangeMacroProps
resolvedMacros
private java.lang.Object
value
-
Constructor Summary
Constructors Constructor Description NumberRangeFormatterSettings(NumberRangeFormatterSettings<?> parent, int key, java.lang.Object value)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
collapse(NumberRangeFormatter.RangeCollapse collapse)
Sets the aggressiveness of "collapsing" fields across the range separator.(package private) abstract T
create(int key, java.lang.Object value)
boolean
equals(java.lang.Object other)
int
hashCode()
T
identityFallback(NumberRangeFormatter.RangeIdentityFallback identityFallback)
Sets the behavior when the two sides of the range are the same.T
numberFormatterBoth(UnlocalizedNumberFormatter formatter)
Sets the NumberFormatter instance to use for the numbers in the range.T
numberFormatterFirst(UnlocalizedNumberFormatter formatterFirst)
Sets the NumberFormatter instance to use for the first number in the range.T
numberFormatterSecond(UnlocalizedNumberFormatter formatterSecond)
Sets the NumberFormatter instances to use for the second number in the range.(package private) RangeMacroProps
resolve()
-
-
-
Field Detail
-
KEY_MACROS
static final int KEY_MACROS
- See Also:
- Constant Field Values
-
KEY_LOCALE
static final int KEY_LOCALE
- See Also:
- Constant Field Values
-
KEY_FORMATTER_1
static final int KEY_FORMATTER_1
- See Also:
- Constant Field Values
-
KEY_FORMATTER_2
static final int KEY_FORMATTER_2
- See Also:
- Constant Field Values
-
KEY_SAME_FORMATTERS
static final int KEY_SAME_FORMATTERS
- See Also:
- Constant Field Values
-
KEY_COLLAPSE
static final int KEY_COLLAPSE
- See Also:
- Constant Field Values
-
KEY_IDENTITY_FALLBACK
static final int KEY_IDENTITY_FALLBACK
- See Also:
- Constant Field Values
-
KEY_MAX
static final int KEY_MAX
- See Also:
- Constant Field Values
-
parent
private final NumberRangeFormatterSettings<?> parent
-
key
private final int key
-
value
private final java.lang.Object value
-
resolvedMacros
private volatile RangeMacroProps resolvedMacros
-
-
Constructor Detail
-
NumberRangeFormatterSettings
NumberRangeFormatterSettings(NumberRangeFormatterSettings<?> parent, int key, java.lang.Object value)
-
-
Method Detail
-
numberFormatterBoth
public T numberFormatterBoth(UnlocalizedNumberFormatter formatter)
Sets the NumberFormatter instance to use for the numbers in the range. The same formatter is applied to both sides of the range.The NumberFormatter instances must not have a locale applied yet; the locale specified on the NumberRangeFormatter will be used.
- Parameters:
formatter
- The formatter to use for both numbers in the range.- Returns:
- The fluent chain.
- See Also:
NumberFormatter
,NumberRangeFormatter
-
numberFormatterFirst
public T numberFormatterFirst(UnlocalizedNumberFormatter formatterFirst)
Sets the NumberFormatter instance to use for the first number in the range.The NumberFormatter instance must not have a locale applied yet; the locale specified on the NumberRangeFormatter will be used.
- Parameters:
formatterFirst
- The formatter to use for the first number in the range.- Returns:
- The fluent chain.
- See Also:
NumberFormatter
,NumberRangeFormatter
-
numberFormatterSecond
public T numberFormatterSecond(UnlocalizedNumberFormatter formatterSecond)
Sets the NumberFormatter instances to use for the second number in the range.The NumberFormatter instance must not have a locale applied yet; the locale specified on the NumberRangeFormatter will be used.
- Parameters:
formatterSecond
- The formatter to use for the second number in the range.- Returns:
- The fluent chain.
- See Also:
NumberFormatter
,NumberRangeFormatter
-
collapse
public T collapse(NumberRangeFormatter.RangeCollapse collapse)
Sets the aggressiveness of "collapsing" fields across the range separator. Possible values:- ALL: "3-5K miles"
- UNIT: "3K - 5K miles"
- NONE: "3K miles - 5K miles"
- AUTO: usually UNIT or NONE, depending on the locale and formatter settings
The default value is AUTO.
- Parameters:
collapse
- The collapsing strategy to use for this range.- Returns:
- The fluent chain.
- See Also:
NumberRangeFormatter
-
identityFallback
public T identityFallback(NumberRangeFormatter.RangeIdentityFallback identityFallback)
Sets the behavior when the two sides of the range are the same. This could happen if the same two numbers are passed to the formatRange function, or if different numbers are passed to the function but they become the same after rounding rules are applied. Possible values:- SINGLE_VALUE: "5 miles"
- APPROXIMATELY_OR_SINGLE_VALUE: "~5 miles" or "5 miles", depending on whether the number was the same before rounding was applied
- APPROXIMATELY: "~5 miles"
- RANGE: "5-5 miles" (with collapse=UNIT)
The default value is APPROXIMATELY.
- Parameters:
identityFallback
- The strategy to use when formatting two numbers that end up being the same.- Returns:
- The fluent chain.
- See Also:
NumberRangeFormatter
-
create
abstract T create(int key, java.lang.Object value)
-
resolve
RangeMacroProps resolve()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
-