本文整理汇总了Java中sun.util.locale.provider.JRELocaleProviderAdapter类的典型用法代码示例。如果您正苦于以下问题:Java JRELocaleProviderAdapter类的具体用法?Java JRELocaleProviderAdapter怎么用?Java JRELocaleProviderAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRELocaleProviderAdapter类属于sun.util.locale.provider包,在下文中一共展示了JRELocaleProviderAdapter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCandidateLocales
import sun.util.locale.provider.JRELocaleProviderAdapter; //导入依赖的package包/类
@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
List<Locale> candidates = super.getCandidateLocales(baseName, locale);
// Weed out Locales which are known to have no resource bundles
int lastDot = baseName.lastIndexOf('.');
String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
if (!langtags.isEmpty()) {
for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) {
itr.remove();
}
}
}
// Force fallback to Locale.ENGLISH for CLDR time zone names support
if (locale.getLanguage() != "en"
&& type == CLDR && category.equals("TimeZoneNames")) {
candidates.add(candidates.size() - 1, Locale.ENGLISH);
}
return candidates;
}
示例2: getCandidateLocales
import sun.util.locale.provider.JRELocaleProviderAdapter; //导入依赖的package包/类
@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
String key = baseName + '-' + locale.toLanguageTag();
List<Locale> candidates = CANDIDATES_MAP.get(key);
if (candidates == null) {
LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
candidates = adapter instanceof ResourceBundleBasedAdapter ?
((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) :
defaultControl.getCandidateLocales(baseName, locale);
// Weed out Locales which are known to have no resource bundles
int lastDot = baseName.lastIndexOf('.');
String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
if (!langtags.isEmpty()) {
for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) {
itr.remove();
}
}
}
// Force fallback to Locale.ENGLISH for CLDR time zone names support
if (locale.getLanguage() != "en"
&& type == CLDR && category.equals("TimeZoneNames")) {
candidates.add(candidates.size() - 1, Locale.ENGLISH);
}
CANDIDATES_MAP.putIfAbsent(key, candidates);
}
return candidates;
}