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

项目:OpenJSharp    文件:Currency.java   
@Override
public String getObject(CurrencyNameProvider currencyNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 1;
    int type = (Integer)params[0];

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk-jdk10    文件:JRELocaleProviderAdapter.java   
/**
 * Getter methods for java.util.spi.* providers
 */
@Override
public CurrencyNameProvider getCurrencyNameProvider() {
    if (currencyNameProvider == null) {
        CurrencyNameProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<CurrencyNameProvider>) () ->
                new CurrencyNameProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("CurrencyNames")));

        synchronized (this) {
            if (currencyNameProvider == null) {
                currencyNameProvider = provider;
            }
        }
    }
    return currencyNameProvider;
}
项目:openjdk9    文件:Currency.java   
@Override
public String getObject(CurrencyNameProvider currencyNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 1;
    int type = (Integer)params[0];

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:openjdk9    文件:JRELocaleProviderAdapter.java   
/**
 * Getter methods for java.util.spi.* providers
 */
@Override
public CurrencyNameProvider getCurrencyNameProvider() {
    if (currencyNameProvider == null) {
        CurrencyNameProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<CurrencyNameProvider>) () ->
                new CurrencyNameProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("CurrencyNames")));

        synchronized (this) {
            if (currencyNameProvider == null) {
                currencyNameProvider = provider;
            }
        }
    }
    return currencyNameProvider;
}
项目:Java8CN    文件:Currency.java   
@Override
public String getObject(CurrencyNameProvider currencyNameProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 1;
    int type = (Integer)params[0];

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

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

    switch(type) {
    case SYMBOL:
        return currencyNameProvider.getSymbol(key, locale);
    case DISPLAYNAME:
        return currencyNameProvider.getDisplayName(key, locale);
    default:
        assert false; // shouldn't happen
    }

    return null;
}
项目:OpenJSharp    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:OpenJSharp    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:OpenJSharp    文件:JRELocaleProviderAdapter.java   
/**
 * Getter methods for java.util.spi.* providers
 */
@Override
public CurrencyNameProvider getCurrencyNameProvider() {
    if (currencyNameProvider == null) {
        CurrencyNameProvider provider = new CurrencyNameProviderImpl(getAdapterType(),
                                        getLanguageTagSet("CurrencyNames"));
        synchronized (this) {
            if (currencyNameProvider == null) {
                currencyNameProvider = provider;
            }
        }
    }
    return currencyNameProvider;
}
项目:jdk8u-jdk    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:jdk8u-jdk    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:jdk8u-jdk    文件:JRELocaleProviderAdapter.java   
/**
 * Getter methods for java.util.spi.* providers
 */
@Override
public CurrencyNameProvider getCurrencyNameProvider() {
    if (currencyNameProvider == null) {
        CurrencyNameProvider provider = new CurrencyNameProviderImpl(getAdapterType(),
                                        getLanguageTagSet("CurrencyNames"));
        synchronized (this) {
            if (currencyNameProvider == null) {
                currencyNameProvider = provider;
            }
        }
    }
    return currencyNameProvider;
}
项目:openjdk-jdk10    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:openjdk-jdk10    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:openjdk9    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:openjdk9    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:Java8CN    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:Java8CN    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:jdk8u_jdk    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:jdk8u_jdk    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:jdk8u_jdk    文件:JRELocaleProviderAdapter.java   
/**
 * Getter methods for java.util.spi.* providers
 */
@Override
public CurrencyNameProvider getCurrencyNameProvider() {
    if (currencyNameProvider == null) {
        CurrencyNameProvider provider = new CurrencyNameProviderImpl(getAdapterType(),
                                        getLanguageTagSet("CurrencyNames"));
        synchronized (this) {
            if (currencyNameProvider == null) {
                currencyNameProvider = provider;
            }
        }
    }
    return currencyNameProvider;
}
项目:lookaside_java-1.8.0-openjdk    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String symbol = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, SYMBOL);
    if (symbol != null) {
        return symbol;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:lookaside_java-1.8.0-openjdk    文件:Currency.java   
/**
 * Gets the name that is suitable for displaying this currency for
 * the specified locale.  If there is no suitable display name found
 * for the specified locale, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the display name of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 * @since 1.7
 */
public String getDisplayName(Locale locale) {
    LocaleServiceProviderPool pool =
        LocaleServiceProviderPool.getPool(CurrencyNameProvider.class);
    String result = pool.getLocalizedObject(
                            CurrencyNameGetter.INSTANCE,
                            locale, currencyCode, DISPLAYNAME);
    if (result != null) {
        return result;
    }

    // use currency code as symbol of last resort
    return currencyCode;
}
项目:lookaside_java-1.8.0-openjdk    文件:JRELocaleProviderAdapter.java   
/**
 * Getter methods for java.util.spi.* providers
 */
@Override
public CurrencyNameProvider getCurrencyNameProvider() {
    if (currencyNameProvider == null) {
        CurrencyNameProvider provider = new CurrencyNameProviderImpl(getAdapterType(),
                                        getLanguageTagSet("CurrencyNames"));
        synchronized (this) {
            if (currencyNameProvider == null) {
                currencyNameProvider = provider;
            }
        }
    }
    return currencyNameProvider;
}
项目:javify    文件:Currency.java   
/**
 * <p>
 * This method returns the symbol which precedes or follows a
 * value in this particular currency.  The returned value is
 * the symbol used to denote the currency in the specified locale.
 * </p>
 * <p>
 * For example, a supplied locale may specify a different symbol
 * for the currency, due to conflicts with its own currency.
 * This would be the case with the American currency, the dollar.
 * Locales that also use a dollar-based currency (e.g. Canada, Australia)
 * need to differentiate the American dollar using 'US$' rather than '$'.
 * So, supplying one of these locales to <code>getSymbol()</code> would
 * return this value, rather than the standard '$'.
 * </p>
 * <p>
 * In cases where there is no such symbol for a particular currency,
 * the ISO 4217 currency code is returned.
 * </p>
 *
 * @param locale the locale to express the symbol in.
 * @return the currency symbol, or the ISO 4217 currency code if
 *         one doesn't exist.
 * @throws NullPointerException if the locale is null.
 */
public String getSymbol(Locale locale)
{
  String property = "currenciesSymbol." + currencyCode;
  try
    {
      return ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                                      locale).getString(property);
    }
  catch (MissingResourceException exception)
    {
      /* This means runtime support for the locale
       * is not available, so we check providers. */
    }
  for (CurrencyNameProvider p :
         ServiceLoader.load(CurrencyNameProvider.class))
    {
      for (Locale loc : p.getAvailableLocales())
        {
          if (loc.equals(locale))
            {
              String localizedString = p.getSymbol(currencyCode,
                                                   locale);
              if (localizedString != null)
                return localizedString;
              break;
            }
        }
    }
  if (locale.equals(Locale.ROOT)) // Base case
    return currencyCode;
  return getSymbol(LocaleHelper.getFallbackLocale(locale));
}
项目:jvm-stm    文件:Currency.java   
/**
  * <p>
  * This method returns the symbol which precedes or follows a
  * value in this particular currency.  The returned value is
  * the symbol used to denote the currency in the specified locale.
  * </p>
  * <p>
  * For example, a supplied locale may specify a different symbol
  * for the currency, due to conflicts with its own currency.
  * This would be the case with the American currency, the dollar.
  * Locales that also use a dollar-based currency (e.g. Canada, Australia)
  * need to differentiate the American dollar using 'US$' rather than '$'.
  * So, supplying one of these locales to <code>getSymbol()</code> would
  * return this value, rather than the standard '$'.
  * </p>
  * <p>
  * In cases where there is no such symbol for a particular currency,
  * the ISO 4217 currency code is returned.
  * </p>
  *
  * @param locale the locale to express the symbol in.
  * @return the currency symbol, or the ISO 4217 currency code if
  *         one doesn't exist.
  * @throws NullPointerException if the locale is null.
  */
 public String getSymbol(Locale locale)
 {
   String property = "currenciesSymbol." + currencyCode;
   try
     {
       return ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
                locale).getString(property);
     }
   catch (MissingResourceException exception)
     {
/* This means runtime support for the locale
 * is not available, so we check providers. */
     }
   for (CurrencyNameProvider p :
   ServiceLoader.load(CurrencyNameProvider.class))
     {
for (Locale loc : p.getAvailableLocales())
  {
    if (loc.equals(locale))
      {
    String localizedString = p.getSymbol(currencyCode,
                         locale);
    if (localizedString != null)
      return localizedString;
    break;
      }
  }
     }
   if (locale.equals(Locale.ROOT)) // Base case
     return currencyCode;
   return getSymbol(LocaleHelper.getFallbackLocale(locale));
 }
项目:VarJ    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    try {
        // 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(CurrencyNameProvider.class);

        if (pool.hasProviders()) {
            // Assuming that all the country locales include necessary currency 
            // symbols in the Java runtime's resources,  so there is no need to
            // examine whether Java runtime's currency resource bundle is missing 
            // names.  Therefore, no resource bundle is provided for calling this 
            // method.
            String symbol = pool.getLocalizedObject(
                                CurrencyNameGetter.INSTANCE,
                                locale, null, currencyCode);
            if (symbol != null) {
                return symbol;
            }
        }

        ResourceBundle bundle = LocaleData.getCurrencyNames(locale);
        return bundle.getString(currencyCode);
    } catch (MissingResourceException e) {
        // use currency code as symbol of last resort
        return currencyCode;
    }
}
项目:VarJ    文件:Currency.java   
public String getObject(CurrencyNameProvider currencyNameProvider,
                           Locale locale, 
                           String key,
                           Object... params) {
       assert params.length == 0;
return currencyNameProvider.getSymbol(key, locale);
   }
项目:jdk-1.7-annotated    文件:Currency.java   
/**
 * Gets the symbol of this currency for the specified locale.
 * For example, for the US Dollar, the symbol is "$" if the specified
 * locale is the US, while for other locales it may be "US$". If no
 * symbol can be determined, the ISO 4217 currency code is returned.
 *
 * @param locale the locale for which a display name for this currency is
 * needed
 * @return the symbol of this currency for the specified locale
 * @exception NullPointerException if <code>locale</code> is null
 */
public String getSymbol(Locale locale) {
    try {
        // 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(CurrencyNameProvider.class);

        if (pool.hasProviders()) {
            // Assuming that all the country locales include necessary currency
            // symbols in the Java runtime's resources,  so there is no need to
            // examine whether Java runtime's currency resource bundle is missing
            // names.  Therefore, no resource bundle is provided for calling this
            // method.
            String symbol = pool.getLocalizedObject(
                                CurrencyNameGetter.INSTANCE,
                                locale, (OpenListResourceBundle)null,
                                currencyCode, SYMBOL);
            if (symbol != null) {
                return symbol;
            }
        }

        ResourceBundle bundle = LocaleData.getCurrencyNames(locale);
        return bundle.getString(currencyCode);
    } catch (MissingResourceException e) {
        // use currency code as symbol of last resort
        return currencyCode;
    }
}