< prev index next >

src/java.base/share/classes/java/text/DecimalFormatSymbols.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


 646         currencySymbol = (String) data[2];
 647 
 648         // Currently the monetary decimal separator is the same as the
 649         // standard decimal separator for all locales that we support.
 650         // If that changes, add a new entry to NumberElements.
 651         monetarySeparator = decimalSeparator;
 652     }
 653 
 654     /**
 655      * Lazy initialization for currency related fields
 656      */
 657     private void initializeCurrency(Locale locale) {
 658         if (currencyInitialized) {
 659             return;
 660         }
 661 
 662         // Try to obtain the currency used in the locale's country.
 663         // Check for empty country string separately because it's a valid
 664         // country ID for Locale (and used for the C locale), but not a valid
 665         // ISO 3166 country code, and exceptions are expensive.
 666         if (locale.getCountry().length() > 0) {
 667             try {
 668                 currency = Currency.getInstance(locale);
 669             } catch (IllegalArgumentException e) {
 670                 // use default values below for compatibility
 671             }
 672         }
 673 
 674         if (currency != null) {
 675             // get resource bundle data
 676             LocaleProviderAdapter adapter =
 677                 LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
 678             // Avoid potential recursions
 679             if (!(adapter instanceof ResourceBundleBasedAdapter)) {
 680                 adapter = LocaleProviderAdapter.getResourceBundleBased();
 681             }
 682             Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData();
 683             intlCurrencySymbol = currency.getCurrencyCode();
 684             if (data[1] != null && data[1] == intlCurrencySymbol) {
 685                 currencySymbol = (String) data[2];
 686             } else {




 646         currencySymbol = (String) data[2];
 647 
 648         // Currently the monetary decimal separator is the same as the
 649         // standard decimal separator for all locales that we support.
 650         // If that changes, add a new entry to NumberElements.
 651         monetarySeparator = decimalSeparator;
 652     }
 653 
 654     /**
 655      * Lazy initialization for currency related fields
 656      */
 657     private void initializeCurrency(Locale locale) {
 658         if (currencyInitialized) {
 659             return;
 660         }
 661 
 662         // Try to obtain the currency used in the locale's country.
 663         // Check for empty country string separately because it's a valid
 664         // country ID for Locale (and used for the C locale), but not a valid
 665         // ISO 3166 country code, and exceptions are expensive.
 666         if (!locale.getCountry().isEmpty()) {
 667             try {
 668                 currency = Currency.getInstance(locale);
 669             } catch (IllegalArgumentException e) {
 670                 // use default values below for compatibility
 671             }
 672         }
 673 
 674         if (currency != null) {
 675             // get resource bundle data
 676             LocaleProviderAdapter adapter =
 677                 LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale);
 678             // Avoid potential recursions
 679             if (!(adapter instanceof ResourceBundleBasedAdapter)) {
 680                 adapter = LocaleProviderAdapter.getResourceBundleBased();
 681             }
 682             Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData();
 683             intlCurrencySymbol = currency.getCurrencyCode();
 684             if (data[1] != null && data[1] == intlCurrencySymbol) {
 685                 currencySymbol = (String) data[2];
 686             } else {


< prev index next >