本文整理汇总了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;
}
示例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;
}