当前位置: 首页>>代码示例>>Java>>正文


Java LocaleServiceProvider.getAvailableLocales方法代码示例

本文整理汇总了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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:LocaleServiceProviderPool.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:LocaleServiceProviderPool.java

示例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;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:22,代码来源:LocaleServiceProviderPool.java

示例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;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:38,代码来源:LocaleServiceProviderPool.java


注:本文中的java.util.spi.LocaleServiceProvider.getAvailableLocales方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。