本文整理汇总了Java中sun.util.locale.LocaleMatcher.mapEquivalents方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleMatcher.mapEquivalents方法的具体用法?Java LocaleMatcher.mapEquivalents怎么用?Java LocaleMatcher.mapEquivalents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.util.locale.LocaleMatcher
的用法示例。
在下文中一共展示了LocaleMatcher.mapEquivalents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapEquivalents
import sun.util.locale.LocaleMatcher; //导入方法依赖的package包/类
/**
* Generates a new customized Language Priority List using the given
* {@code priorityList} and {@code map}. If the given {@code map} is
* empty, this method returns a copy of the given {@code priorityList}.
*
* <p>In the map, a key represents a language range whereas a value is
* a list of equivalents of it. {@code '*'} cannot be used in the map.
* Each equivalent language range has the same weight value as its
* original language range.
*
* <pre>
* An example of map:
* <b>Key</b> <b>Value</b>
* "zh" (Chinese) "zh",
* "zh-Hans"(Simplified Chinese)
* "zh-HK" (Chinese, Hong Kong) "zh-HK"
* "zh-TW" (Chinese, Taiwan) "zh-TW"
* </pre>
*
* The customization is performed after modification using the IANA
* Language Subtag Registry.
*
* <p>For example, if a user's Language Priority List consists of five
* language ranges ({@code "zh"}, {@code "zh-CN"}, {@code "en"},
* {@code "zh-TW"}, and {@code "zh-HK"}), the newly generated Language
* Priority List which is customized using the above map example will
* consists of {@code "zh"}, {@code "zh-Hans"}, {@code "zh-CN"},
* {@code "zh-Hans-CN"}, {@code "en"}, {@code "zh-TW"}, and
* {@code "zh-HK"}.
*
* <p>{@code "zh-HK"} and {@code "zh-TW"} aren't converted to
* {@code "zh-Hans-HK"} nor {@code "zh-Hans-TW"} even if they are
* included in the Language Priority List. In this example, mapping
* is used to clearly distinguish Simplified Chinese and Traditional
* Chinese.
*
* <p>If the {@code "zh"}-to-{@code "zh"} mapping isn't included in the
* map, a simple replacement will be performed and the customized list
* won't include {@code "zh"} and {@code "zh-CN"}.
*
* @param priorityList user's Language Priority List
* @param map a map containing information to customize language ranges
* @return a new Language Priority List with customization. The list is
* modifiable.
* @throws NullPointerException if {@code priorityList} is {@code null}
* @see #parse(String, Map)
*/
public static List<LanguageRange> mapEquivalents(
List<LanguageRange>priorityList,
Map<String, List<String>> map) {
return LocaleMatcher.mapEquivalents(priorityList, map);
}