src/share/classes/java/text/DecimalFormat.java

Print this page
rev 6352 : imported patch 7162007

*** 52,61 **** --- 52,62 ---- import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import sun.util.locale.provider.LocaleProviderAdapter; + import sun.util.locale.provider.ResourceBundleBasedAdapter; /** * <code>DecimalFormat</code> is a concrete subclass of * <code>NumberFormat</code> that formats decimal numbers. It has a variety of * features designed to make it possible to parse and format numbers in any
*** 392,423 **** * @see java.text.NumberFormat#getNumberInstance * @see java.text.NumberFormat#getCurrencyInstance * @see java.text.NumberFormat#getPercentInstance */ public DecimalFormat() { - Locale def = Locale.getDefault(Locale.Category.FORMAT); - // try to get the pattern from the cache - String pattern = cachedLocaleData.get(def); - if (pattern == null) { /* cache miss */ // Get the pattern for the default locale. LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, def); ! switch (adapter.getAdapterType()) { ! case HOST: ! case SPI: adapter = LocaleProviderAdapter.getResourceBundleBased(); - break; } ! ResourceBundle rb = adapter.getLocaleData().getNumberFormatData(def); ! String[] all = rb.getStringArray("NumberPatterns"); ! pattern = all[0]; ! /* update cache */ ! cachedLocaleData.putIfAbsent(def, pattern); ! } // Always applyPattern after the symbols are set this.symbols = DecimalFormatSymbols.getInstance(def); ! applyPattern(pattern, false); } /** * Creates a DecimalFormat using the given pattern and the symbols --- 393,413 ---- * @see java.text.NumberFormat#getNumberInstance * @see java.text.NumberFormat#getCurrencyInstance * @see java.text.NumberFormat#getPercentInstance */ public DecimalFormat() { // Get the pattern for the default locale. + Locale def = Locale.getDefault(Locale.Category.FORMAT); LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class, def); ! if (!(adapter instanceof ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.getResourceBundleBased(); } ! String[] all = adapter.getLocaleResources(def).getNumberPatterns(); // Always applyPattern after the symbols are set this.symbols = DecimalFormatSymbols.getInstance(def); ! applyPattern(all[0], false); } /** * Creates a DecimalFormat using the given pattern and the symbols
*** 4152,4163 **** static final int MAXIMUM_INTEGER_DIGITS = Integer.MAX_VALUE; static final int MAXIMUM_FRACTION_DIGITS = Integer.MAX_VALUE; // Proclaim JDK 1.1 serial compatibility. static final long serialVersionUID = 864413376551465018L; - - /** - * Cache to hold the NumberPattern of a Locale. - */ - private static final ConcurrentMap<Locale, String> cachedLocaleData - = new ConcurrentHashMap<>(3); } --- 4142,4147 ----