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

public final Class LocaleServiceProviderPool

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .HashSet, .IllformedLocaleException, .List, .Locale, .Locale.Builder, .ResourceBundle.Control, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.spi.LocaleServiceProvider, java.util.stream.Stream

An instance of this class holds a set of the third party implementations of a particular locale sensitive service, such as java.util.spi.LocaleNameProvider.
Authors
Naoto Sato, Masayoshi Okutsu

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
LocaleServiceProviderPool.AllAvailableLocales

Lazy loaded set of available locales.

public static interface
LocaleServiceProviderPool.LocalizedObjectGetter<P extends LocaleServiceProvider, S>

An interface to get a localized object for each locale sensitive service class.

Field Summary

Modifier and TypeField and Description
private Set<Locale>
availableLocales

Available locales for this locale sensitive service.

private static final List<LocaleServiceProvider>
NULL_LIST

A dummy locale service provider list that indicates there is no provider available

private static final ConcurrentMap<Class<? extends LocaleServiceProvider>, LocaleServiceProviderPool>
poolOfPools

A Map that holds singleton instances of this class.

private final Class<? extends LocaleServiceProvider>
providerClass

Provider class

private final ConcurrentMap<Locale, List<LocaleServiceProvider>>
providersCache

A Map that retains Locale->provider mapping

pack-priv static final Class<LocaleServiceProvider>[]
spiClasses

Array of all Locale Sensitive SPI classes.

Constructor Summary

AccessConstructor and Description
private
LocaleServiceProviderPool(final Class<? extends LocaleServiceProvider>
class of the locale sensitive service
c
)

The sole constructor.

Method Summary

Modifier and TypeMethod and Description
private List<LocaleServiceProvider>

Returns:

the list of locale data adapter types
findProviders
(Locale
the given locale
locale
,
boolean isObjectProvider)

Returns the list of locale service provider instances that support the specified locale.

public static Locale[]

Returns:

an array of the available locales for all the provider classes
getAllAvailableLocales
()

Returns an array of the available locales for all the provider classes.

public Locale[]

Returns:

an array of the available locales
getAvailableLocales
()

Returns an array of the available locales.

private synchronized Set<Locale>

Returns:

a set of available locales
getAvailableLocaleSet
()

Returns the union of locale sets that are available from each service provider.

public <P extends LocaleServiceProvider, S> S

Returns:

provider's instance, or null.
getLocalizedObject
(LocaleServiceProviderPool.LocalizedObjectGetter<P, S>
an object on which getObject() method is called to obtain the provider's instance.
getter
,
Locale
the given locale that is used as the starting one
locale
,
Object...
provider specific parameters
params
)

Returns the provider's localized object for the specified locale.

public <P extends LocaleServiceProvider, S> S

Returns:

provider's instance, or null.
getLocalizedObject
(LocaleServiceProviderPool.LocalizedObjectGetter<P, S>
an object on which getObject() method is called to obtain the provider's instance.
getter
,
Locale
the given locale that is used as the starting one
locale
,
String
the key string for name providers
key
,
Object...
provider specific parameters
params
)

Returns the provider's localized name for the specified locale.

public <P extends LocaleServiceProvider, S> S

Returns:

provider's instance, or null.
getLocalizedObject
(LocaleServiceProviderPool.LocalizedObjectGetter<P, S>
an object on which getObject() method is called to obtain the provider's instance.
getter
,
Locale
the given locale that is used as the starting one
locale
,
Boolean
flag designating object provider or not
isObjectProvider
,
String
the key string for name providers
key
,
Object...
provider specific parameters
params
)

Returns the provider's localized name for the specified locale.

private <P extends LocaleServiceProvider, S> S
getLocalizedObjectImpl(LocaleServiceProviderPool.LocalizedObjectGetter<P, S> getter, Locale locale, boolean isObjectProvider, String key, Object... params)

pack-priv static Locale

Returns:

the locale used for service look up
getLookupLocale
(Locale
the locale
locale
)

Returns an instance of Locale used for service look up.

pack-priv static List<Locale>

Returns:

the list of candidate locales for the given locale
getLookupLocales
(Locale
the input locale
locale
)

Returns a list of candidate locales for service look up.

public static LocaleServiceProviderPool
getPool(Class<? extends LocaleServiceProvider> providerClass)

A factory method that returns a singleton instance

public static Stream<Locale>

Returns:

a stream of the available locales for all the provider classes
streamAllAvailableLocales
()

Returns a stream of the available locales for all the provider classes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

availableLocalesback to summary
private Set<Locale> availableLocales

Available locales for this locale sensitive service. This also contains JRE's available locales

NULL_LISTback to summary
private static final List<LocaleServiceProvider> NULL_LIST

A dummy locale service provider list that indicates there is no provider available

poolOfPoolsback to summary
private static final ConcurrentMap<Class<? extends LocaleServiceProvider>, LocaleServiceProviderPool> poolOfPools

A Map that holds singleton instances of this class. Each instance holds a set of provider implementations of a particular locale sensitive service.

providerClassback to summary
private final Class<? extends LocaleServiceProvider> providerClass

Provider class

providersCacheback to summary
private final ConcurrentMap<Locale, List<LocaleServiceProvider>> providersCache

A Map that retains Locale->provider mapping

spiClassesback to summary
pack-priv static final Class<LocaleServiceProvider>[] spiClasses

Array of all Locale Sensitive SPI classes. We know "spiClasses" contains classes that extends LocaleServiceProvider, but generic array creation is not allowed, thus the "unchecked" warning is suppressed here.

Annotations
@SuppressWarnings:unchecked

Constructor Detail

LocaleServiceProviderPoolback to summary
private LocaleServiceProviderPool(final Class<? extends LocaleServiceProvider> c)

The sole constructor.

Parameters
c:Class<? extends LocaleServiceProvider>

class of the locale sensitive service

Method Detail

findProvidersback to summary
private List<LocaleServiceProvider> findProviders(Locale locale, boolean isObjectProvider)

Returns the list of locale service provider instances that support the specified locale.

Parameters
locale:Locale

the given locale

Returns:List<LocaleServiceProvider>

the list of locale data adapter types

getAllAvailableLocalesback to summary
public static Locale[] getAllAvailableLocales()

Returns an array of the available locales for all the provider classes. This array is a merged array of all the locales that are provided by each provider, including the JRE.

Returns:Locale[]

an array of the available locales for all the provider classes

getAvailableLocalesback to summary
public Locale[] getAvailableLocales()

Returns an array of the available locales. This array is a merged array of all the locales that are provided by each provider, including the JRE.

Returns:Locale[]

an array of the available locales

getAvailableLocaleSetback to summary
private synchronized Set<Locale> getAvailableLocaleSet()

Returns the union of locale sets that are available from each service provider. This method does NOT return the defensive copy.

Returns:Set<Locale>

a set of available locales

getLocalizedObjectback to summary
public <P extends LocaleServiceProvider, S> S getLocalizedObject(LocaleServiceProviderPool.LocalizedObjectGetter<P, S> getter, Locale locale, Object... params)

Returns the provider's localized object for the specified locale.

Parameters
getter:LocaleServiceProviderPool.LocalizedObjectGetter<P, S>

an object on which getObject() method is called to obtain the provider's instance.

locale:Locale

the given locale that is used as the starting one

params:Object[]

provider specific parameters

Returns:S

provider's instance, or null.

getLocalizedObjectback to summary
public <P extends LocaleServiceProvider, S> S getLocalizedObject(LocaleServiceProviderPool.LocalizedObjectGetter<P, S> getter, Locale locale, String key, Object... params)

Returns the provider's localized name for the specified locale.

Parameters
getter:LocaleServiceProviderPool.LocalizedObjectGetter<P, S>

an object on which getObject() method is called to obtain the provider's instance.

locale:Locale

the given locale that is used as the starting one

key:String

the key string for name providers

params:Object[]

provider specific parameters

Returns:S

provider's instance, or null.

getLocalizedObjectback to summary
public <P extends LocaleServiceProvider, S> S getLocalizedObject(LocaleServiceProviderPool.LocalizedObjectGetter<P, S> getter, Locale locale, Boolean isObjectProvider, String key, Object... params)

Returns the provider's localized name for the specified locale.

Parameters
getter:LocaleServiceProviderPool.LocalizedObjectGetter<P, S>

an object on which getObject() method is called to obtain the provider's instance.

locale:Locale

the given locale that is used as the starting one

isObjectProvider:Boolean

flag designating object provider or not

key:String

the key string for name providers

params:Object[]

provider specific parameters

Returns:S

provider's instance, or null.

getLocalizedObjectImplback to summary
private <P extends LocaleServiceProvider, S> S getLocalizedObjectImpl(LocaleServiceProviderPool.LocalizedObjectGetter<P, S> getter, Locale locale, boolean isObjectProvider, String key, Object... params)
Annotations
@SuppressWarnings:unchecked
getLookupLocaleback to summary
pack-priv static Locale getLookupLocale(Locale locale)

Returns an instance of Locale used for service look up. The result Locale has no extensions except for ja_JP_JP and th_TH_TH

Parameters
locale:Locale

the locale

Returns:Locale

the locale used for service look up

getLookupLocalesback to summary
pack-priv static List<Locale> getLookupLocales(Locale locale)

Returns a list of candidate locales for service look up.

Parameters
locale:Locale

the input locale

Returns:List<Locale>

the list of candidate locales for the given locale

getPoolback to summary
public static LocaleServiceProviderPool getPool(Class<? extends LocaleServiceProvider> providerClass)

A factory method that returns a singleton instance

streamAllAvailableLocalesback to summary
public static Stream<Locale> streamAllAvailableLocales()

Returns a stream of the available locales for all the provider classes. This stream is constructed from all the locales that are provided by each provider, including the JRE.

Returns:Stream<Locale>

a stream of the available locales for all the provider classes

sun.util.locale.provider back to summary

private Class LocaleServiceProviderPool.AllAvailableLocales

extends Object
Class Inheritance
  • java.lang.Object
  • sun.util.locale.provider.LocaleServiceProviderPool.AllAvailableLocales

Lazy loaded set of available locales. Loading all locales is a very long operation.

Field Summary

Modifier and TypeField and Description
pack-priv static final Locale[]
allAvailableLocales

Available locales for all locale sensitive services.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allAvailableLocalesback to summary
pack-priv static final Locale[] allAvailableLocales

Available locales for all locale sensitive services. This also contains JRE's available locales

Constructor Detail

AllAvailableLocalesback to summary
private AllAvailableLocales()
sun.util.locale.provider back to summary

public Interface LocaleServiceProviderPool.LocalizedObjectGetter<P extends LocaleServiceProvider, S>

Known Direct Implementers
sun.util.locale.provider.TimeZoneNameUtility.TimeZoneNameGetter, java.util.Currency.CurrencyNameGetter, java.util.Locale.LocaleNameGetter, sun.util.locale.provider.CalendarDataUtility.CalendarFieldValueNameGetter, sun.util.locale.provider.CalendarDataUtility.CalendarFieldValueNamesMapGetter, sun.util.locale.provider.CalendarDataUtility.CalendarWeekParameterGetter

An interface to get a localized object for each locale sensitive service class.

Method Summary

Modifier and TypeMethod and Description
public S

Returns:

localized object from the provider
getObject
(P
the provider
lsp
,
Locale
the locale
locale
,
String
key string to localize, or null if the provider is not a name provider
key
,
Object...
provider specific params
params
)

Returns an object from the provider

Method Detail

getObjectback to summary
public S getObject(P lsp, Locale locale, String key, Object... params)

Returns an object from the provider

Parameters
lsp:P

the provider

locale:Locale

the locale

key:String

key string to localize, or null if the provider is not a name provider

params:Object[]

provider specific params

Returns:S

localized object from the provider