APIdia Launch Partner
Top Description Fields Constructors Methods
sun.util.locale.provider

public Class LocaleNameProviderImpl

extends LocaleNameProvider
implements AvailableLanguageTags
Class Inheritance
All Implemented Interfaces
sun.util.locale.provider.AvailableLanguageTags
Imports
java.util.Locale, .Set, java.util.spi.LocaleNameProvider

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

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
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 String

Returns:

the name of the given country code for the specified locale, or null if it's not available.
getDisplayCountry
(String
the ISO 3166 country code string in the form of two upper-case letters between 'A' (U+0041) and 'Z' (U+005A)
ctry
,
Locale
the desired locale
locale
)

Implements abstract java.util.spi.LocaleNameProvider.getDisplayCountry.

Returns a localized name for the given ISO 3166 country code and the given locale that is appropriate for display to the user.

public String

Returns:

the name of the given language code for the specified locale, or null if it's not available.
getDisplayLanguage
(String
the ISO 639 language code string in the form of two lower-case letters between 'a' (U+0061) and 'z' (U+007A)
lang
,
Locale
the desired locale
locale
)

Implements abstract java.util.spi.LocaleNameProvider.getDisplayLanguage.

Returns a localized name for the given ISO 639 language code and the given locale that is appropriate for display to the user.

public String

Returns:

the name of the given script code for the specified locale, or null if it's not available.
getDisplayScript
(String
the four letter script code string in the form of title-case letters (the first letter is upper-case character between 'A' (U+0041) and 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061) and 'z' (U+007A)).
scriptCode
,
Locale
the desired locale
locale
)

Overrides java.util.spi.LocaleNameProvider.getDisplayScript.

Returns a localized name for the given IETF BCP47 script code and the given locale that is appropriate for display to the user.

private String
public String
getDisplayUnicodeExtensionKey(String key, Locale locale)

Overrides java.util.spi.LocaleNameProvider.getDisplayUnicodeExtensionKey.

Returns a localized name for the given Unicode extension key, and the given locale that is appropriate for display to the user.

public String
getDisplayUnicodeExtensionType(String extType, String key, Locale locale)

Overrides java.util.spi.LocaleNameProvider.getDisplayUnicodeExtensionType.

Returns a localized name for the given Unicode extension type, and the given locale that is appropriate for display to the user.

public String

Returns:

the name of the given variant string for the specified locale, or null if it's not available.
getDisplayVariant
(String
the variant string
vrnt
,
Locale
the desired locale
locale
)

Implements abstract java.util.spi.LocaleNameProvider.getDisplayVariant.

Returns a localized name for the given variant code and the given locale that is appropriate for display to the user.

public boolean
isSupportedLocale(Locale locale)

Overrides java.util.spi.LocaleServiceProvider.isSupportedLocale.

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

Field Detail

langtagsback to summary
private final Set<String> langtags
typeback to summary
private final LocaleProviderAdapter.Type type

Constructor Detail

LocaleNameProviderImplback to summary
public LocaleNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags)

Method Detail

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.

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
getDisplayCountryback to summary
public String getDisplayCountry(String ctry, Locale locale)

Implements abstract java.util.spi.LocaleNameProvider.getDisplayCountry.

Returns a localized name for the given ISO 3166 country code and the given locale that is appropriate for display to the user. For example, if countryCode is "FR" and locale is en_US, getDisplayCountry() will return "France"; if countryCode is "US" and locale is fr_FR, getDisplayCountry() will return "Etats-Unis". If the name returned cannot be localized according to locale, (say, the provider does not have a Japanese name for Croatia), this method returns null.

Parameters
ctry:String

the ISO 3166 country code string in the form of two upper-case letters between 'A' (U+0041) and 'Z' (U+005A)

locale:Locale

the desired locale

Returns:String

the name of the given country code for the specified locale, or null if it's not available.

Annotations
@Override
Exceptions
NullPointerException:
if countryCode or locale is null
IllegalArgumentException:
if countryCode is not in the form of two upper-case letters, or locale isn't one of the locales returned from getAvailableLocales().
See Also
java.util.Locale#getDisplayCountry(java.util.Locale)
getDisplayLanguageback to summary
public String getDisplayLanguage(String lang, Locale locale)

Implements abstract java.util.spi.LocaleNameProvider.getDisplayLanguage.

Returns a localized name for the given ISO 639 language code and the given locale that is appropriate for display to the user. For example, if languageCode is "fr" and locale is en_US, getDisplayLanguage() will return "French"; if languageCode is "en" and locale is fr_FR, getDisplayLanguage() will return "anglais". If the name returned cannot be localized according to locale, (say, the provider does not have a Japanese name for Croatian), this method returns null.

Parameters
lang:String

the ISO 639 language code string in the form of two lower-case letters between 'a' (U+0061) and 'z' (U+007A)

locale:Locale

the desired locale

Returns:String

the name of the given language code for the specified locale, or null if it's not available.

Annotations
@Override
Exceptions
NullPointerException:
if languageCode or locale is null
IllegalArgumentException:
if languageCode is not in the form of two lower-case letters, or locale isn't one of the locales returned from getAvailableLocales().
See Also
java.util.Locale#getDisplayLanguage(java.util.Locale)
getDisplayScriptback to summary
public String getDisplayScript(String scriptCode, Locale locale)

Overrides java.util.spi.LocaleNameProvider.getDisplayScript.

Returns a localized name for the given IETF BCP47 script code and the given locale that is appropriate for display to the user. For example, if scriptCode is "Latn" and locale is en_US, getDisplayScript() will return "Latin"; if scriptCode is "Cyrl" and locale is fr_FR, getDisplayScript() will return "cyrillique". If the name returned cannot be localized according to locale, (say, the provider does not have a Japanese name for Cyrillic), this method returns null. The default implementation returns null.

Parameters
scriptCode:String

the four letter script code string in the form of title-case letters (the first letter is upper-case character between 'A' (U+0041) and 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061) and 'z' (U+007A)).

locale:Locale

the desired locale

Returns:String

the name of the given script code for the specified locale, or null if it's not available.

Annotations
@Override
Exceptions
NullPointerException:
if scriptCode or locale is null
IllegalArgumentException:
if scriptCode is not in the form of four title case letters, or locale isn't one of the locales returned from getAvailableLocales().
See Also
java.util.Locale#getDisplayScript(java.util.Locale)
getDisplayStringback to summary
private String getDisplayString(String key, Locale locale)
getDisplayUnicodeExtensionKeyback to summary
public String getDisplayUnicodeExtensionKey(String key, Locale locale)

Overrides java.util.spi.LocaleNameProvider.getDisplayUnicodeExtensionKey.

Doc from java.util.spi.LocaleNameProvider.getDisplayUnicodeExtensionKey.

Returns a localized name for the given Unicode extension key, and the given locale that is appropriate for display to the user. If the name returned cannot be localized according to locale, this method returns null.

Annotations
@Override
getDisplayUnicodeExtensionTypeback to summary
public String getDisplayUnicodeExtensionType(String extType, String key, Locale locale)

Overrides java.util.spi.LocaleNameProvider.getDisplayUnicodeExtensionType.

Doc from java.util.spi.LocaleNameProvider.getDisplayUnicodeExtensionType.

Returns a localized name for the given Unicode extension type, and the given locale that is appropriate for display to the user. If the name returned cannot be localized according to locale, this method returns null.

Annotations
@Override
getDisplayVariantback to summary
public String getDisplayVariant(String vrnt, Locale locale)

Implements abstract java.util.spi.LocaleNameProvider.getDisplayVariant.

Returns a localized name for the given variant code and the given locale that is appropriate for display to the user. If the name returned cannot be localized according to locale, this method returns null.

Parameters
vrnt:String

the variant string

locale:Locale

the desired locale

Returns:String

the name of the given variant string for the specified locale, or null if it's not available.

Annotations
@Override
Exceptions
NullPointerException:
if variant or locale is null
IllegalArgumentException:
if locale isn't one of the locales returned from getAvailableLocales().
See Also
java.util.Locale#getDisplayVariant(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.

Annotations
@Override