本文整理汇总了Java中java.util.spi.LocaleServiceProvider.getAvailableLocales方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleServiceProvider.getAvailableLocales方法的具体用法?Java LocaleServiceProvider.getAvailableLocales怎么用?Java LocaleServiceProvider.getAvailableLocales使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.spi.LocaleServiceProvider
的用法示例。
在下文中一共展示了LocaleServiceProvider.getAvailableLocales方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableLocaleSet
import java.util.spi.LocaleServiceProvider; //导入方法依赖的package包/类
/**
* Returns the union of locale sets that are available from
* each service provider. This method does NOT return the
* defensive copy.
*
* @return a set of available locales
*/
private synchronized Set<Locale> getAvailableLocaleSet() {
if (availableLocales == null) {
availableLocales = new HashSet<>();
for (LocaleProviderAdapter.Type type : LocaleProviderAdapter.getAdapterPreference()) {
LocaleProviderAdapter lda = LocaleProviderAdapter.forType(type);
if (lda != null) {
LocaleServiceProvider lsp = lda.getLocaleServiceProvider(providerClass);
if (lsp != null) {
Locale[] locales = lsp.getAvailableLocales();
for (Locale locale: locales) {
availableLocales.add(getLookupLocale(locale));
}
}
}
}
}
return availableLocales;
}
示例2: getAvailableLocaleSet
import java.util.spi.LocaleServiceProvider; //导入方法依赖的package包/类
/**
* Returns the union of locale sets that are available from
* each service provider. This method does NOT return the
* defensive copy.
*
* @return a set of available locales
*/
private synchronized Set<Locale> getAvailableLocaleSet() {
if (availableLocales == null) {
availableLocales = new HashSet<>();
for (LocaleServiceProvider lsp : providers.values()) {
Locale[] locales = lsp.getAvailableLocales();
for (Locale locale: locales) {
availableLocales.add(getLookupLocale(locale));
}
}
}
return availableLocales;
}
示例3: getProviderLocales
import java.util.spi.LocaleServiceProvider; //导入方法依赖的package包/类
/**
* Returns an array of available locales (already normalized
* for service lookup) from providers.
* Note that this method does not return a defensive copy.
*
* @return list of the provider locales
*/
private synchronized Set<Locale> getProviderLocales() {
if (providerLocales == null) {
providerLocales = new HashSet<Locale>();
if (hasProviders()) {
for (LocaleServiceProvider lsp : providers) {
Locale[] locales = lsp.getAvailableLocales();
for (Locale locale: locales) {
providerLocales.add(getLookupLocale(locale));
}
}
}
}
return providerLocales;
}
示例4: findProvider
import java.util.spi.LocaleServiceProvider; //导入方法依赖的package包/类
/**
* Returns a locale service provider instance that supports
* the specified locale.
*
* @param locale the given locale
* @return the provider, or null if there is
* no provider available.
*/
private LocaleServiceProvider findProvider(Locale locale) {
if (!hasProviders()) {
return null;
}
if (providersCache.containsKey(locale)) {
LocaleServiceProvider provider = providersCache.get(locale);
if (provider != NullProvider.INSTANCE) {
return provider;
}
} else {
for (LocaleServiceProvider lsp : providers) {
Locale[] locales = lsp.getAvailableLocales();
for (Locale available: locales) {
// normalize
available = getLookupLocale(available);
if (locale.equals(available)) {
LocaleServiceProvider providerInCache =
providersCache.put(locale, lsp);
return (providerInCache != null ?
providerInCache :
lsp);
}
}
}
providersCache.put(locale, NullProvider.INSTANCE);
}
return null;
}