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


Java LocaleMatcher类代码示例

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


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

示例1: parse

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Parses the given {@code ranges} to generate a Language Priority List.
 *
 * <p>This method performs a syntactic check for each language range in
 * the given {@code ranges} but doesn't do validation using the IANA
 * Language Subtag Registry.
 *
 * <p>The {@code ranges} to be given can take one of the following
 * forms:
 *
 * <pre>
 *   "Accept-Language: ja,en;q=0.4"  (weighted list with Accept-Language prefix)
 *   "ja,en;q=0.4"                   (weighted list)
 *   "ja,en"                         (prioritized list)
 * </pre>
 *
 * In a weighted list, each language range is given a weight value.
 * The weight value is identical to the "quality value" in
 * <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a>, and it
 * expresses how much the user prefers  the language. A weight value is
 * specified after a corresponding language range followed by
 * {@code ";q="}, and the default weight value is {@code MAX_WEIGHT}
 * when it is omitted.
 *
 * <p>Unlike a weighted list, language ranges in a prioritized list
 * are sorted in the descending order based on its priority. The first
 * language range has the highest priority and meets the user's
 * preference most.
 *
 * <p>In either case, language ranges are sorted in descending order in
 * the Language Priority List based on priority or weight. If a
 * language range appears in the given {@code ranges} more than once,
 * only the first one is included on the Language Priority List.
 *
 * <p>The returned list consists of language ranges from the given
 * {@code ranges} and their equivalents found in the IANA Language
 * Subtag Registry. For example, if the given {@code ranges} is
 * {@code "Accept-Language: iw,en-us;q=0.7,en;q=0.3"}, the elements in
 * the list to be returned are:
 *
 * <pre>
 *  <b>Range</b>                                   <b>Weight</b>
 *    "iw" (older tag for Hebrew)             1.0
 *    "he" (new preferred code for Hebrew)    1.0
 *    "en-us" (English, United States)        0.7
 *    "en" (English)                          0.3
 * </pre>
 *
 * Two language ranges, {@code "iw"} and {@code "he"}, have the same
 * highest priority in the list. By adding {@code "he"} to the user's
 * Language Priority List, locale-matching method can find Hebrew as a
 * matching locale (or language tag) even if the application or system
 * offers only {@code "he"} as a supported locale (or language tag).
 *
 * @param ranges a list of comma-separated language ranges or a list of
 *     language ranges in the form of the "Accept-Language" header
 *     defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
 *     2616</a>
 * @return a Language Priority List consisting of language ranges
 *     included in the given {@code ranges} and their equivalent
 *     language ranges if available. The list is modifiable.
 * @throws NullPointerException if {@code ranges} is null
 * @throws IllegalArgumentException if a language range or a weight
 *     found in the given {@code ranges} is ill-formed
 */
public static List<LanguageRange> parse(String ranges) {
    return LocaleMatcher.parse(ranges);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:69,代码来源:Locale.java

示例2: 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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:Locale.java

示例3: filter

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns a list of matching {@code Locale} instances using the filtering
 * mechanism defined in RFC 4647.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param locales {@code Locale} instances used for matching
 * @param mode filtering mode
 * @return a list of {@code Locale} instances for matching language tags
 *     sorted in descending order based on priority or weight, or an empty
 *     list if nothing matches. The list is modifiable.
 * @throws NullPointerException if {@code priorityList} or {@code locales}
 *     is {@code null}
 * @throws IllegalArgumentException if one or more extended language ranges
 *     are included in the given list when
 *     {@link FilteringMode#REJECT_EXTENDED_RANGES} is specified
 *
 * @since 1.8
 */
public static List<Locale> filter(List<LanguageRange> priorityList,
                                  Collection<Locale> locales,
                                  FilteringMode mode) {
    return LocaleMatcher.filter(priorityList, locales, mode);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Locale.java

示例4: filterTags

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns a list of matching languages tags using the basic filtering
 * mechanism defined in RFC 4647.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param tags language tags
 * @param mode filtering mode
 * @return a list of matching language tags sorted in descending order
 *     based on priority or weight, or an empty list if nothing matches.
 *     The list is modifiable.
 * @throws NullPointerException if {@code priorityList} or {@code tags} is
 *     {@code null}
 * @throws IllegalArgumentException if one or more extended language ranges
 *     are included in the given list when
 *     {@link FilteringMode#REJECT_EXTENDED_RANGES} is specified
 *
 * @since 1.8
 */
public static List<String> filterTags(List<LanguageRange> priorityList,
                                      Collection<String> tags,
                                      FilteringMode mode) {
    return LocaleMatcher.filterTags(priorityList, tags, mode);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Locale.java

示例5: lookup

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns a {@code Locale} instance for the best-matching language
 * tag using the lookup mechanism defined in RFC 4647.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param locales {@code Locale} instances used for matching
 * @return the best matching <code>Locale</code> instance chosen based on
 *     priority or weight, or {@code null} if nothing matches.
 * @throws NullPointerException if {@code priorityList} or {@code tags} is
 *     {@code null}
 *
 * @since 1.8
 */
public static Locale lookup(List<LanguageRange> priorityList,
                            Collection<Locale> locales) {
    return LocaleMatcher.lookup(priorityList, locales);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Locale.java

示例6: lookupTag

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns the best-matching language tag using the lookup mechanism
 * defined in RFC 4647.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param tags language tangs used for matching
 * @return the best matching language tag chosen based on priority or
 *     weight, or {@code null} if nothing matches.
 * @throws NullPointerException if {@code priorityList} or {@code tags} is
 *     {@code null}
 *
 * @since 1.8
 */
public static String lookupTag(List<LanguageRange> priorityList,
                               Collection<String> tags) {
    return LocaleMatcher.lookupTag(priorityList, tags);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Locale.java

示例7: filter

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns a list of matching {@code Locale} instances using the filtering
 * mechanism defined in RFC 4647.
 *
 * This filter operation on the given {@code locales} ensures that only
 * unique matching locale(s) are returned.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param locales {@code Locale} instances used for matching
 * @param mode filtering mode
 * @return a list of {@code Locale} instances for matching language tags
 *     sorted in descending order based on priority or weight, or an empty
 *     list if nothing matches. The list is modifiable.
 * @throws NullPointerException if {@code priorityList} or {@code locales}
 *     is {@code null}
 * @throws IllegalArgumentException if one or more extended language ranges
 *     are included in the given list when
 *     {@link FilteringMode#REJECT_EXTENDED_RANGES} is specified
 *
 * @since 1.8
 */
public static List<Locale> filter(List<LanguageRange> priorityList,
                                  Collection<Locale> locales,
                                  FilteringMode mode) {
    return LocaleMatcher.filter(priorityList, locales, mode);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Locale.java

示例8: filterTags

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns a list of matching languages tags using the basic filtering
 * mechanism defined in RFC 4647.
 *
 * This filter operation on the given {@code tags} ensures that only
 * unique matching tag(s) are returned with preserved case. In case of
 * duplicate matching tags with the case difference, the first matching
 * tag with preserved case is returned.
 * For example, "de-ch" is returned out of the duplicate matching tags
 * "de-ch" and "de-CH", if "de-ch" is checked first for matching in the
 * given {@code tags}. Note that if the given {@code tags} is an unordered
 * {@code Collection}, the returned matching tag out of duplicate tags is
 * subject to change, depending on the implementation of the
 * {@code Collection}.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param tags language tags
 * @param mode filtering mode
 * @return a list of matching language tags sorted in descending order
 *     based on priority or weight, or an empty list if nothing matches.
 *     The list is modifiable.
 * @throws NullPointerException if {@code priorityList} or {@code tags} is
 *     {@code null}
 * @throws IllegalArgumentException if one or more extended language ranges
 *     are included in the given list when
 *     {@link FilteringMode#REJECT_EXTENDED_RANGES} is specified
 *
 * @since 1.8
 */
public static List<String> filterTags(List<LanguageRange> priorityList,
                                      Collection<String> tags,
                                      FilteringMode mode) {
    return LocaleMatcher.filterTags(priorityList, tags, mode);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:Locale.java

示例9: lookupTag

import sun.util.locale.LocaleMatcher; //导入依赖的package包/类
/**
 * Returns the best-matching language tag using the lookup mechanism
 * defined in RFC 4647.
 *
 * This lookup operation on the given {@code tags} ensures that the
 * first matching tag with preserved case is returned.
 *
 * @param priorityList user's Language Priority List in which each language
 *     tag is sorted in descending order based on priority or weight
 * @param tags language tangs used for matching
 * @return the best matching language tag chosen based on priority or
 *     weight, or {@code null} if nothing matches.
 * @throws NullPointerException if {@code priorityList} or {@code tags} is
 *     {@code null}
 *
 * @since 1.8
 */
public static String lookupTag(List<LanguageRange> priorityList,
                               Collection<String> tags) {
    return LocaleMatcher.lookupTag(priorityList, tags);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Locale.java


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