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


Java LocaleData.getLocaleNames方法代码示例

本文整理汇总了Java中sun.util.resources.LocaleData.getLocaleNames方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleData.getLocaleNames方法的具体用法?Java LocaleData.getLocaleNames怎么用?Java LocaleData.getLocaleNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.util.resources.LocaleData的用法示例。


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

示例1: getDisplayVariant

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
/**
 * Returns a name for the locale's variant code that is appropriate for display to the
 * user.  If possible, the name will be localized for inLocale.  If the locale
 * doesn't specify a variant code, this function returns the empty string.
 *
 * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
 */
public String getDisplayVariant(Locale inLocale) {
    if (variant.length() == 0)
        return "";

    OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);

    String names[] = getDisplayVariantArray(bundle, inLocale);

    // Get the localized patterns for formatting a list, and use
    // them to format the list.
    String listPattern = null;
    String listCompositionPattern = null;
    try {
        listPattern = bundle.getString("ListPattern");
        listCompositionPattern = bundle.getString("ListCompositionPattern");
    } catch (MissingResourceException e) {
    }
    return formatList(names, listPattern, listCompositionPattern);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:27,代码来源:Locale.java

示例2: getDisplayVariant

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
/**
 * Returns a name for the locale's variant code that is appropriate for display to the
 * user.  If possible, the name will be localized for inLocale.  If the locale
 * doesn't specify a variant code, this function returns the empty string.
 *
 * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
 */
public String getDisplayVariant(Locale inLocale) {
    if (baseLocale.getVariant().length() == 0)
        return "";

    OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);

    String names[] = getDisplayVariantArray(bundle, inLocale);

    // Get the localized patterns for formatting a list, and use
    // them to format the list.
    String listPattern = null;
    String listCompositionPattern = null;
    try {
        listPattern = bundle.getString("ListPattern");
        listCompositionPattern = bundle.getString("ListCompositionPattern");
    } catch (MissingResourceException e) {
    }
    return formatList(names, listPattern, listCompositionPattern);
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:27,代码来源:Locale.java

示例3: getDisplayString

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    try {
        OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);
        String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
        String result = null;

        // Check whether a provider can provide an implementation that's closer 
        // to the requested locale than what the Java runtime itself can provide.
        LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
        if (pool.hasProviders()) {
            result = pool.getLocalizedObject(
                                LocaleNameGetter.INSTANCE,
                                inLocale, bundle, key,
                                type, code);
        }

        if (result == null) {
            result = bundle.getString(key);
        }

        if (result != null) {
            return result;
        }
    }
    catch (Exception e) {
        // just fall through
    }
    return code;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:39,代码来源:Locale.java

示例4: getDisplayString

import sun.util.resources.LocaleData; //导入方法依赖的package包/类
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

    if (inLocale == null) {
        throw new NullPointerException();
    }

    try {
        OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale);
        String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
        String result = null;

        // Check whether a provider can provide an implementation that's closer
        // to the requested locale than what the Java runtime itself can provide.
        LocaleServiceProviderPool pool =
            LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
        if (pool.hasProviders()) {
            result = pool.getLocalizedObject(
                                LocaleNameGetter.INSTANCE,
                                inLocale, bundle, key,
                                type, code);
        }

        if (result == null) {
            result = bundle.getString(key);
        }

        if (result != null) {
            return result;
        }
    }
    catch (Exception e) {
        // just fall through
    }
    return code;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:39,代码来源:Locale.java


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