Java 类java.util.spi.LocaleNameProvider 实例源码

项目:OpenJSharp    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:OpenJSharp    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:jdk8u-jdk    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:jdk8u-jdk    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk-jdk10    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:openjdk-jdk10    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk-jdk10    文件:JRELocaleProviderAdapter.java   
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<LocaleNameProvider>) () ->
                new LocaleNameProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("LocaleNames")));

        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
项目:openjdk9    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:openjdk9    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk9    文件:JRELocaleProviderAdapter.java   
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<LocaleNameProvider>) () ->
                new LocaleNameProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("LocaleNames")));

        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
项目:Java8CN    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:Java8CN    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:jdk8u_jdk    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:jdk8u_jdk    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:lookaside_java-1.8.0-openjdk    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:VarJ    文件:Locale.java   
public String getObject(LocaleNameProvider localeNameProvider,
                              Locale locale, 
                              String key,
                              Object... params) {
          assert params.length == 2;
          int type = (Integer)params[0];
          String code = (String)params[1];

          switch(type) {
          case DISPLAY_LANGUAGE:
return localeNameProvider.getDisplayLanguage(code, locale);
          case DISPLAY_COUNTRY:
return localeNameProvider.getDisplayCountry(code, locale);
          case DISPLAY_VARIANT:
return localeNameProvider.getDisplayVariant(code, locale);
          default:
              assert false; // shouldn't happen
          }

          return null;
      }
项目:jdk-1.7-annotated    文件:Locale.java   
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:infobip-open-jdk-8    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:infobip-open-jdk-8    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:jdk8u-dev-jdk    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:jdk8u-dev-jdk    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:jdk7-jdk    文件:Locale.java   
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk-source-code-learn    文件:Locale.java   
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:OLD-OpenJDK8    文件:Locale.java   
private String getDisplayString(String code, Locale inLocale, int type) {
    if (code.length() == 0) {
        return "";
    }

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

    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(LocaleNameProvider.class);
    String key = (type == DISPLAY_VARIANT ? "%%"+code : code);
    String result = pool.getLocalizedObject(
                            LocaleNameGetter.INSTANCE,
                            inLocale, key, type, code);
        if (result != null) {
            return result;
        }

    return code;
}
项目:OLD-OpenJDK8    文件:Locale.java   
@Override
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk-jdk7u-jdk    文件:Locale.java   
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk-icedtea7    文件:Locale.java   
public String getObject(LocaleNameProvider localeNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 2;
    int type = (Integer)params[0];
    String code = (String)params[1];

    switch(type) {
    case DISPLAY_LANGUAGE:
        return localeNameProvider.getDisplayLanguage(code, locale);
    case DISPLAY_COUNTRY:
        return localeNameProvider.getDisplayCountry(code, locale);
    case DISPLAY_VARIANT:
        return localeNameProvider.getDisplayVariant(code, locale);
    case DISPLAY_SCRIPT:
        return localeNameProvider.getDisplayScript(code, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:OpenJSharp    文件:JRELocaleProviderAdapter.java   
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
项目:jdk8u-jdk    文件:JRELocaleProviderAdapter.java   
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
项目:jdk8u-jdk    文件:Bug6989440.java   
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
项目:openjdk-jdk10    文件:Bug6989440.java   
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
项目:openjdk9    文件:Bug6989440.java   
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
项目:jdk8u_jdk    文件:JRELocaleProviderAdapter.java   
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
项目:jdk8u_jdk    文件:Bug6989440.java   
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:JRELocaleProviderAdapter.java   
@Override
public LocaleNameProvider getLocaleNameProvider() {
    if (localeNameProvider == null) {
        LocaleNameProvider provider = new LocaleNameProviderImpl(getAdapterType(),
                                                getLanguageTagSet("LocaleNames"));
        synchronized (this) {
            if (localeNameProvider == null) {
                localeNameProvider = provider;
            }
        }
    }
    return localeNameProvider;
}
项目:lookaside_java-1.8.0-openjdk    文件:Bug6989440.java   
public TestThread() {
    int which = count++ % 3;
    switch (which) {
        case 0 : cls = LocaleNameProvider.class; break;
        case 1 : cls = TimeZoneNameProvider.class; break;
        case 2 : cls = DateFormatProvider.class; break;
        default : throw new AssertionError("Should not reach here");
    }
}
项目:javify    文件:Locale.java   
/**
 * <p>
 * Gets the name of the language specified by this locale, in a form suitable
 * for display to the user.  If possible, the display name will be localized
 * to the specified locale.  For example, if the locale instance is
 * <code>Locale.GERMANY</code>, and the specified locale is <code>Locale.UK</code>,
 * the result would be 'German'.  Using the German locale would instead give
 * 'Deutsch'.  If the display name can not be localized to the supplied
 * locale, it will fall back on other output in the following order:
 * </p>
 * <ul>
 * <li>the display name in the default locale</li>
 * <li>the display name in English</li>
 * <li>the ISO code</li>
 * </ul>
 * <p>
 * If the language is unspecified by this locale, then the empty string is
 * returned.
 * </p>
 *
 * @param inLocale the locale to use for formatting the display string.
 * @return the language name of this locale localized to the given locale,
 *         with the default locale, English and the ISO code as backups.
 * @throws NullPointerException if the supplied locale is null.
 */
public String getDisplayLanguage(Locale inLocale)
{
  if (language.isEmpty())
    return "";
  try
    {
      ResourceBundle res =
        ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                 inLocale,
                                 ClassLoader.getSystemClassLoader());

      return res.getString("languages." + language);
    }
  catch (MissingResourceException e)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (LocaleNameProvider p :
         ServiceLoader.load(LocaleNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(inLocale))
            {
              String locLang = p.getDisplayLanguage(language,
                                                    inLocale);
              if (locLang != null)
                return locLang;
              break;
            }
        }
    }
  if (inLocale.equals(Locale.ROOT)) // Base case
    return language;
  return getDisplayLanguage(LocaleHelper.getFallbackLocale(inLocale));
}
项目:javify    文件:Locale.java   
/**
 * <p>
 * Gets the name of the country specified by this locale, in a form suitable
 * for display to the user.  If possible, the display name will be localized
 * to the specified locale.  For example, if the locale instance is
 * <code>Locale.GERMANY</code>, and the specified locale is <code>Locale.UK</code>,
 * the result would be 'Germany'.  Using the German locale would instead give
 * 'Deutschland'.  If the display name can not be localized to the supplied
 * locale, it will fall back on other output in the following order:
 * </p>
 * <ul>
 * <li>the display name in the default locale</li>
 * <li>the display name in English</li>
 * <li>the ISO code</li>
 * </ul>
 * <p>
 * If the country is unspecified by this locale, then the empty string is
 * returned.
 * </p>
 *
 * @param inLocale the locale to use for formatting the display string.
 * @return the country name of this locale localized to the given locale,
 *         with the default locale, English and the ISO code as backups.
 * @throws NullPointerException if the supplied locale is null.
 */
public String getDisplayCountry(Locale inLocale)
{
  if (country.isEmpty())
    return "";
  try
    {
      ResourceBundle res =
        ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                 inLocale,
                                 ClassLoader.getSystemClassLoader());

      return res.getString("territories." + country);
    }
  catch (MissingResourceException e)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (LocaleNameProvider p :
         ServiceLoader.load(LocaleNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(inLocale))
            {
              String locCountry = p.getDisplayCountry(country,
                                                      inLocale);
              if (locCountry != null)
                return locCountry;
              break;
            }
        }
    }
  if (inLocale.equals(Locale.ROOT)) // Base case
    return country;
  return getDisplayCountry(LocaleHelper.getFallbackLocale(inLocale));
}
项目:javify    文件:Locale.java   
/**
 * <p>
 * Gets the name of the variant specified by this locale, in a form suitable
 * for display to the user.  If possible, the display name will be localized
 * to the specified locale.  For example, if the locale instance is a revised
 * variant, and the specified locale is <code>Locale.UK</code>, the result
 * would be 'REVISED'.  Using the German locale would instead give
 * 'Revidiert'.  If the display name can not be localized to the supplied
 * locale, it will fall back on other output in the following order:
 * </p>
 * <ul>
 * <li>the display name in the default locale</li>
 * <li>the display name in English</li>
 * <li>the ISO code</li>
 * </ul>
 * <p>
 * If the variant is unspecified by this locale, then the empty string is
 * returned.
 * </p>
 *
 * @param inLocale the locale to use for formatting the display string.
 * @return the variant name of this locale localized to the given locale,
 *         with the default locale, English and the ISO code as backups.
 * @throws NullPointerException if the supplied locale is null.
 */
public String getDisplayVariant(Locale inLocale)
{
  if (variant.isEmpty())
    return "";
  try
    {
      ResourceBundle res =
        ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                 inLocale,
                                 ClassLoader.getSystemClassLoader());

      return res.getString("variants." + variant);
    }
  catch (MissingResourceException e)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (LocaleNameProvider p :
         ServiceLoader.load(LocaleNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(inLocale))
            {
              String locVar = p.getDisplayVariant(variant,
                                                  inLocale);
              if (locVar != null)
                return locVar;
              break;
            }
        }
    }
  if (inLocale.equals(Locale.ROOT)) // Base case
    return country;
  return getDisplayVariant(LocaleHelper.getFallbackLocale(inLocale));
}