本文整理汇总了Java中java.util.Locale.LanguageRange方法的典型用法代码示例。如果您正苦于以下问题:Java Locale.LanguageRange方法的具体用法?Java Locale.LanguageRange怎么用?Java Locale.LanguageRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Locale
的用法示例。
在下文中一共展示了Locale.LanguageRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseForLocale
import java.util.Locale; //导入方法依赖的package包/类
private static IProperty chooseForLocale(
final @NotNull List<Locale.LanguageRange> priorityList,
final @NotNull List<IProperty> properties
) {
if (properties.isEmpty()) {
return null;
}
IProperty first = properties.get(0);
if (properties.size() == 1) {
return first;
}
final Map<Locale, IProperty> map = new HashMap<>();
final List<Locale> locales = new LinkedList<>();
for (IProperty nextProperty : properties) {
Locale nextLocale = safeGetLocale(nextProperty);
if (nextLocale != null) {
map.put(nextLocale, nextProperty);
locales.add(nextLocale);
}
}
Locale best = Locale.lookup(priorityList, locales);
//System.err.println("found locales: " + locales + ", best: " + best + ", result: " + map.get(best));
return Optional.ofNullable(best).map(map::get).orElse(first);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:JspPropertyFoldingBuilder.java
示例2: checkLookup
import java.util.Locale; //导入方法依赖的package包/类
private static void checkLookup(String ranges, String tags,
String expectedLocale) {
List<Locale.LanguageRange> priorityList = Locale.LanguageRange
.parse(ranges);
List<Locale> localeList = generateLocales(tags);
Locale loc = Locale.lookup(priorityList, localeList);
String actualLocale
= loc.toLanguageTag();
if (!actualLocale.equals(expectedLocale)) {
System.err.println("Locale.lookup failed with ranges: " + ranges
+ " Expected: " + expectedLocale
+ " Actual: " + actualLocale);
err = true;
}
}
示例3: checkFilter
import java.util.Locale; //导入方法依赖的package包/类
private static void checkFilter(String ranges, String tags,
String expectedLocales) {
List<Locale.LanguageRange> priorityList = Locale.LanguageRange
.parse(ranges);
List<Locale> localeList = generateLocales(tags);
String actualLocales = getLocalesAsString(
Locale.filter(priorityList, localeList));
if (!actualLocales.equals(expectedLocales)) {
System.err.println("Locale.filter failed with ranges: " + ranges
+ " Expected: " + expectedLocales
+ " Actual: " + actualLocales);
err = true;
}
}