Top Description Fields Constructors Methods
sun.util.locale.provider

public Class NumberFormatProviderImpl

extends NumberFormatProvider
implements AvailableLanguageTags
Class Inheritance
All Implemented Interfaces
sun.util.locale.provider.AvailableLanguageTags
Imports
java.text.CompactNumberFormat, .DecimalFormat, .DecimalFormatSymbols, .NumberFormat, java.text.spi.NumberFormatProvider, java.util.Currency, .Locale, .Objects, .Set

Concrete implementation of the NumberFormatProvider class for the JRE LocaleProviderAdapter.
Authors
Naoto Sato, Masayoshi Okutsu

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private final Set<String>
private static final int
private static final int
private final LocaleProviderAdapter.Type

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
adjustForCurrencyDefaultFractionDigits(DecimalFormat format, DecimalFormatSymbols symbols)

Adjusts the minimum and maximum fraction digits to values that are reasonable for the currency's default fraction digits.

public Set<String>
getAvailableLanguageTags()

Implements sun.util.locale.provider.AvailableLanguageTags.getAvailableLanguageTags.

Returns a set of available language tags of a LocaleServiceProvider.
public Locale[]

Returns:

An array of all locales for which this locale service provider can provide localized objects or names.
getAvailableLocales
()

Implements abstract java.util.spi.LocaleServiceProvider.getAvailableLocales.

Returns an array of all locales for which this locale service provider can provide localized objects or names.
public NumberFormat

Returns:

a compact number formatter
getCompactNumberInstance
(Locale
the desired locale
locale
,
NumberFormat.Style
the style for formatting a number
formatStyle
)

Overrides java.text.spi.NumberFormatProvider.getCompactNumberInstance.

Returns a new NumberFormat instance which formats a number in its compact form for the specified locale and formatStyle.
public NumberFormat

Returns:

a currency formatter
getCurrencyInstance
(Locale
the desired locale.
locale
)

Implements abstract java.text.spi.NumberFormatProvider.getCurrencyInstance.

Returns a new NumberFormat instance which formats monetary values for the specified locale.
private NumberFormat
getInstance(Locale locale, int choice)

public NumberFormat

Returns:

a number format for integer values
getIntegerInstance
(Locale
the desired locale
locale
)

Implements abstract java.text.spi.NumberFormatProvider.getIntegerInstance.

Returns a new NumberFormat instance which formats integer values for the specified locale.
public NumberFormat

Returns:

a general-purpose number formatter
getNumberInstance
(Locale
the desired locale
locale
)

Implements abstract java.text.spi.NumberFormatProvider.getNumberInstance.

Returns a new general-purpose NumberFormat instance for the specified locale.
public NumberFormat

Returns:

a percent formatter
getPercentInstance
(Locale
the desired locale
locale
)

Implements abstract java.text.spi.NumberFormatProvider.getPercentInstance.

Returns a new NumberFormat instance which formats percentage values for the specified locale.
public boolean
isSupportedLocale(Locale
a Locale to be tested
locale
)

Overrides java.util.spi.LocaleServiceProvider.isSupportedLocale.

Returns true if the given locale is supported by this locale service provider.

Field Detail

ACCOUNTINGSTYLEback to summary
private static final int ACCOUNTINGSTYLE
CURRENCYSTYLEback to summary
private static final int CURRENCYSTYLE
INTEGERSTYLEback to summary
private static final int INTEGERSTYLE
langtagsback to summary
private final Set<String> langtags
NUMBERSTYLEback to summary
private static final int NUMBERSTYLE
PERCENTSTYLEback to summary
private static final int PERCENTSTYLE
typeback to summary
private final LocaleProviderAdapter.Type type

Constructor Detail

NumberFormatProviderImplback to summary
public NumberFormatProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags)

Method Detail

adjustForCurrencyDefaultFractionDigitsback to summary
private static void adjustForCurrencyDefaultFractionDigits(DecimalFormat format, DecimalFormatSymbols symbols)

Adjusts the minimum and maximum fraction digits to values that are reasonable for the currency's default fraction digits.

getAvailableLanguageTagsback to summary
public Set<String> getAvailableLanguageTags()

Implements sun.util.locale.provider.AvailableLanguageTags.getAvailableLanguageTags.

Doc from sun.util.locale.provider.AvailableLanguageTags.getAvailableLanguageTags.

Returns a set of available language tags of a LocaleServiceProvider. Note that the returned set doesn't contain the language tag for Locale.Root.

Returns:Set<String>

a Set of available language tags.

Annotations
@Override
getAvailableLocalesback to summary
public Locale[] getAvailableLocales()

Implements abstract java.util.spi.LocaleServiceProvider.getAvailableLocales.

Returns an array of all locales for which this locale service provider can provide localized objects or names.

Returns:Locale[]

An array of all locales for which this locale service provider can provide localized objects or names.

Annotations
@Override
getCompactNumberInstanceback to summary
public NumberFormat getCompactNumberInstance(Locale locale, NumberFormat.Style formatStyle)

Overrides java.text.spi.NumberFormatProvider.getCompactNumberInstance.

Returns a new NumberFormat instance which formats a number in its compact form for the specified locale and formatStyle.

Parameters
locale:Locale

the desired locale

formatStyle:NumberFormat.Style

the style for formatting a number

Returns:NumberFormat

a compact number formatter

Annotations
@Override
Exceptions
NullPointerException:
if locale or formatStyle is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
Since
12
See Also
java.text.NumberFormat#getCompactNumberInstance(Locale, NumberFormat.Style)
getCurrencyInstanceback to summary
public NumberFormat getCurrencyInstance(Locale locale)

Implements abstract java.text.spi.NumberFormatProvider.getCurrencyInstance.

Returns a new NumberFormat instance which formats monetary values for the specified locale.

Parameters
locale:Locale

the desired locale.

Returns:NumberFormat

a currency formatter

Annotations
@Override
Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
getInstanceback to summary
private NumberFormat getInstance(Locale locale, int choice)
getIntegerInstanceback to summary
public NumberFormat getIntegerInstance(Locale locale)

Implements abstract java.text.spi.NumberFormatProvider.getIntegerInstance.

Returns a new NumberFormat instance which formats integer values for the specified locale. The returned number format is configured to round floating point numbers to the nearest integer using half-even rounding (see HALF_EVEN) for formatting, and to parse only the integer part of an input string (see isParseIntegerOnly).

Parameters
locale:Locale

the desired locale

Returns:NumberFormat

a number format for integer values

Annotations
@Override
Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getIntegerInstance(java.util.Locale)
getNumberInstanceback to summary
public NumberFormat getNumberInstance(Locale locale)

Implements abstract java.text.spi.NumberFormatProvider.getNumberInstance.

Returns a new general-purpose NumberFormat instance for the specified locale.

Parameters
locale:Locale

the desired locale

Returns:NumberFormat

a general-purpose number formatter

Annotations
@Override
Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getNumberInstance(java.util.Locale)
getPercentInstanceback to summary
public NumberFormat getPercentInstance(Locale locale)

Implements abstract java.text.spi.NumberFormatProvider.getPercentInstance.

Returns a new NumberFormat instance which formats percentage values for the specified locale.

Parameters
locale:Locale

the desired locale

Returns:NumberFormat

a percent formatter

Annotations
@Override
Exceptions
NullPointerException:
if locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.text.NumberFormat#getPercentInstance(java.util.Locale)
isSupportedLocaleback to summary
public boolean isSupportedLocale(Locale locale)

Overrides java.util.spi.LocaleServiceProvider.isSupportedLocale.

Doc from java.util.spi.LocaleServiceProvider.isSupportedLocale.

Returns true if the given locale is supported by this locale service provider. The given locale may contain extensions that should be taken into account for the support determination.

The default implementation returns true if the given locale is equal to any of the available Locales returned by getAvailableLocales() with ignoring any extensions in both the given locale and the available locales. Concrete locale service provider implementations should override this method if those implementations are Locale extensions-aware. For example, DecimalFormatSymbolsProvider implementations will need to check extensions in the given locale to see if any numbering system is specified and can be supported. However, CollatorProvider implementations may not be affected by any particular numbering systems, and in that case, extensions for numbering systems should be ignored.

Parameters
locale:Locale

a Locale to be tested

Returns:boolean

true if the given locale is supported by this provider; false otherwise.

Annotations
@Override