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

public abstract Class NumberRangeFormatterSettings<T extends com.ibm.icu.number.NumberRangeFormatterSettings<?>>

extends Object
Class Inheritance
Known Direct Subclasses
com.ibm.icu.number.UnlocalizedNumberRangeFormatter, com.ibm.icu.number.LocalizedNumberRangeFormatter
Imports
com.ibm.icu.impl.number.range.RangeMacroProps, com.ibm.icu.number.NumberRangeFormatter.RangeCollapse, .NumberRangeFormatter.RangeIdentityFallback, com.ibm.icu.util.ULocale

An abstract base class for specifying settings related to number formatting. This class is implemented by UnlocalizedNumberRangeFormatter and LocalizedNumberRangeFormatter. This class is not intended for public subclassing.
Author
sffc
ICU Status
Stable since ICU 63.
See Also
NumberRangeFormatter

Field Summary

Modifier and TypeField and Description
private final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
private final NumberRangeFormatterSettings<?>
private volatile RangeMacroProps
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

The fluent chain.
collapse
(NumberRangeFormatter.RangeCollapse
The collapsing strategy to use for this range.
collapse
)

Sets the aggressiveness of "collapsing" fields across the range separator.

pack-priv abstract T
create(int key, Object value)

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public T

Returns:

The fluent chain.
identityFallback
(NumberRangeFormatter.RangeIdentityFallback
The strategy to use when formatting two numbers that end up being the same.
identityFallback
)

Sets the behavior when the two sides of the range are the same.

public T

Returns:

The fluent chain.
numberFormatterBoth
(UnlocalizedNumberFormatter
The formatter to use for both numbers in the range.
formatter
)

Sets the NumberFormatter instance to use for the numbers in the range.

public T

Returns:

The fluent chain.
numberFormatterFirst
(UnlocalizedNumberFormatter
The formatter to use for the first number in the range.
formatterFirst
)

Sets the NumberFormatter instance to use for the first number in the range.

public T

Returns:

The fluent chain.
numberFormatterSecond
(UnlocalizedNumberFormatter
The formatter to use for the second number in the range.
formatterSecond
)

Sets the NumberFormatter instances to use for the second number in the range.

pack-priv RangeMacroProps
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final int key
KEY_COLLAPSEback to summary
pack-priv static final int KEY_COLLAPSE
KEY_FORMATTER_1back to summary
pack-priv static final int KEY_FORMATTER_1
KEY_FORMATTER_2back to summary
pack-priv static final int KEY_FORMATTER_2
KEY_IDENTITY_FALLBACKback to summary
pack-priv static final int KEY_IDENTITY_FALLBACK
KEY_LOCALEback to summary
pack-priv static final int KEY_LOCALE
KEY_MACROSback to summary
pack-priv static final int KEY_MACROS
KEY_MAXback to summary
pack-priv static final int KEY_MAX
KEY_SAME_FORMATTERSback to summary
pack-priv static final int KEY_SAME_FORMATTERS
parentback to summary
private final NumberRangeFormatterSettings<?> parent
resolvedMacrosback to summary
private volatile RangeMacroProps resolvedMacros
valueback to summary
private final Object value

Constructor Detail

NumberRangeFormatterSettingsback to summary
pack-priv NumberRangeFormatterSettings(NumberRangeFormatterSettings<?> parent, int key, Object value)

Method Detail

collapseback to summary
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:NumberRangeFormatter.RangeCollapse

The collapsing strategy to use for this range.

Returns:T

The fluent chain.

ICU Status
Stable since ICU 63.
See Also
NumberRangeFormatter
createback to summary
pack-priv abstract T create(int key, Object value)
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
ICU Status
Stable since ICU 63.
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
ICU Status
Stable since ICU 63.
identityFallbackback to summary
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:NumberRangeFormatter.RangeIdentityFallback

The strategy to use when formatting two numbers that end up being the same.

Returns:T

The fluent chain.

ICU Status
Stable since ICU 63.
See Also
NumberRangeFormatter
numberFormatterBothback to summary
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:UnlocalizedNumberFormatter

The formatter to use for both numbers in the range.

Returns:T

The fluent chain.

Annotations
@SuppressWarnings:unchecked
ICU Status
Stable since ICU 63.
See Also
NumberFormatter, NumberRangeFormatter
numberFormatterFirstback to summary
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:UnlocalizedNumberFormatter

The formatter to use for the first number in the range.

Returns:T

The fluent chain.

Annotations
@SuppressWarnings:unchecked
ICU Status
Stable since ICU 63.
See Also
NumberFormatter, NumberRangeFormatter
numberFormatterSecondback to summary
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:UnlocalizedNumberFormatter

The formatter to use for the second number in the range.

Returns:T

The fluent chain.

Annotations
@SuppressWarnings:unchecked
ICU Status
Stable since ICU 63.
See Also
NumberFormatter, NumberRangeFormatter
resolveback to summary
pack-priv RangeMacroProps resolve()