src/java.base/share/classes/sun/util/locale/provider/CurrencyNameProviderImpl.java

Print this page
rev 10528 : 8038436: Re-examine the mechanism to determine available localedata and cldrdata
Reviewed-by:

*** 1,7 **** /* ! * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 38,57 **** * @author Masayoshi Okutsu */ public class CurrencyNameProviderImpl extends CurrencyNameProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; ! private final Set<String> langtags; ! public CurrencyNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) { this.type = type; - this.langtags = langtags; } @Override public Set<String> getAvailableLanguageTags() { ! return langtags; } /** * Returns an array of all locales for which this locale service provider * can provide localized objects or names. --- 38,56 ---- * @author Masayoshi Okutsu */ public class CurrencyNameProviderImpl extends CurrencyNameProvider implements AvailableLanguageTags { private final LocaleProviderAdapter.Type type; ! private Set<String> langtags; ! public CurrencyNameProviderImpl(LocaleProviderAdapter.Type type) { this.type = type; } @Override public Set<String> getAvailableLanguageTags() { ! return getLangTags(); } /** * Returns an array of all locales for which this locale service provider * can provide localized objects or names.
*** 59,69 **** * @return An array of all locales for which this locale service provider * can provide localized objects or names. */ @Override public Locale[] getAvailableLocales() { ! return LocaleProviderAdapter.toLocaleArray(langtags); } /** * Gets the symbol of the given currency code for the specified locale. * For example, for "USD" (US Dollar), the symbol is "$" if the specified --- 58,68 ---- * @return An array of all locales for which this locale service provider * can provide localized objects or names. */ @Override public Locale[] getAvailableLocales() { ! return LocaleProviderAdapter.toLocaleArray(getLangTags()); } /** * Gets the symbol of the given currency code for the specified locale. * For example, for "USD" (US Dollar), the symbol is "$" if the specified
*** 119,124 **** --- 118,130 ---- throw new NullPointerException(); } return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCurrencyName(key); } + + private Set<String> getLangTags() { + if (langtags == null) { + langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("CurrencyNames"); + } + return langtags; + } }