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


Java LocaleDataMetaInfo类代码示例

本文整理汇总了Java中sun.util.locale.provider.LocaleDataMetaInfo的典型用法代码示例。如果您正苦于以下问题:Java LocaleDataMetaInfo类的具体用法?Java LocaleDataMetaInfo怎么用?Java LocaleDataMetaInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LocaleDataMetaInfo类属于sun.util.locale.provider包,在下文中一共展示了LocaleDataMetaInfo类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CLDRLocaleProviderAdapter

import sun.util.locale.provider.LocaleDataMetaInfo; //导入依赖的package包/类
public CLDRLocaleProviderAdapter() {
    LocaleDataMetaInfo nbmi = null;

    try {
        nbmi = AccessController.doPrivileged(new PrivilegedExceptionAction<LocaleDataMetaInfo>() {
            @Override
            public LocaleDataMetaInfo run() {
                for (LocaleDataMetaInfo ldmi : ServiceLoader.loadInstalled(LocaleDataMetaInfo.class)) {
                    if (ldmi.getType() == LocaleProviderAdapter.Type.CLDR) {
                        return ldmi;
                    }
                }
                return null;
            }
        });
    }  catch (Exception e) {
        // Catch any exception, and continue as if only CLDR's base locales exist.
    }

    nonBaseMetaInfo = nbmi;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:CLDRLocaleProviderAdapter.java

示例2: getCandidateLocales

import sun.util.locale.provider.LocaleDataMetaInfo; //导入依赖的package包/类
@Override
 public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    List<Locale> candidates = super.getCandidateLocales(baseName, locale);
    /* Get the locale string list from LocaleDataMetaInfo class. */
    String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName);

    if (localeString != null && localeString.length() != 0) {
        for (Iterator<Locale> l = candidates.iterator(); l.hasNext();) {
            Locale loc = l.next();
            String lstr;
            if (loc.getScript().length() > 0) {
                lstr = loc.toLanguageTag().replace('-', '_');
            } else {
                lstr = loc.toString();
                int idx = lstr.indexOf("_#");
                if (idx >= 0) {
                    lstr = lstr.substring(0, idx);
                }
            }
            /* Every locale string in the locale string list returned from
             the above getSupportedLocaleString is enclosed
             within two white spaces so that we could check some locale
             such as "en".
             */
            if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) {
                l.remove();
            }
        }
    }
    // Force fallback to Locale.ENGLISH for CLDR time zone names support
    if (locale.getLanguage() != "en"
            && baseName.contains(CLDR) && baseName.endsWith("TimeZoneNames")) {
        candidates.add(candidates.size() - 1, Locale.ENGLISH);
    }
    return candidates;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:LocaleData.java


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