@Override public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() { if (decimalFormatSymbolsProvider == null) { DecimalFormatSymbolsProvider provider = AccessController.doPrivileged( (PrivilegedAction<DecimalFormatSymbolsProvider>) () -> new DecimalFormatSymbolsProviderImpl( getAdapterType(), getLanguageTagSet("FormatData"))); synchronized (this) { if (decimalFormatSymbolsProvider == null) { decimalFormatSymbolsProvider = provider; } } } return decimalFormatSymbolsProvider; }
/** * Gets the <code>DecimalFormatSymbols</code> instance for the specified * locale. This method provides access to <code>DecimalFormatSymbols</code> * instances for locales supported by the Java runtime itself as well * as for those supported by installed * {@link java.text.spi.DecimalFormatSymbolsProvider * DecimalFormatSymbolsProvider} implementations. * @param locale the desired locale. * @return a <code>DecimalFormatSymbols</code> instance. * @exception NullPointerException if <code>locale</code> is null * @since 1.6 */ public static final DecimalFormatSymbols getInstance(Locale locale) { // 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(DecimalFormatSymbolsProvider.class); if (pool.hasProviders()) { DecimalFormatSymbols providersInstance = pool.getLocalizedObject( DecimalFormatSymbolsGetter.INSTANCE, locale); if (providersInstance != null) { return providersInstance; } } return new DecimalFormatSymbols(locale); }
/** * Return the DecimalFormatSymbols for the specified locale. This method * return DecimalFormatSymbols instances for locales supported by the Java * runtime and installed DecimalFormatSymbolsProvider implementations. * * @param locale * locale for the returned DecimalFormatSymbols instance * * @return an instance of DecimalFormatSymbols * * @exception NullPointerException * if locale is null * * @since 1.6 */ public static final DecimalFormatSymbols getInstance(Locale locale) { if (null == locale) { throw new NullPointerException(); } if (buildinLocales == null) { initBuildInLocales(com.ibm.icu.text.DecimalFormatSymbols .getAvailableLocales()); } if (buildinLocales.contains(locale)) { return new DecimalFormatSymbols(locale); } DecimalFormatSymbolsProvider provider = (DecimalFormatSymbolsProvider) LocaleServiceProviderLoader .getProviderByLocale(providersCache, locale, PROVIDER_CONFIGURATION_FILE_NAME); if (provider != null) { return provider.getInstance(locale); } // return DecimalFormatSymbols using default locale return new DecimalFormatSymbols(); }
@Override public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() { if (decimalFormatSymbolsProvider == null) { DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData")); synchronized (this) { if (decimalFormatSymbolsProvider == null) { decimalFormatSymbolsProvider = provider; } } } return decimalFormatSymbolsProvider; }
/** * Initializes the symbols from the FormatData resource bundle. */ private void initialize( Locale locale ) { this.locale = locale; // get resource bundle data LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale); // Avoid potential recursions if (!(adapter instanceof ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.getResourceBundleBased(); } Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData(); String[] numberElements = (String[]) data[0]; decimalSeparator = numberElements[0].charAt(0); groupingSeparator = numberElements[1].charAt(0); patternSeparator = numberElements[2].charAt(0); percent = numberElements[3].charAt(0); zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc. digit = numberElements[5].charAt(0); minusSign = numberElements[6].charAt(0); exponential = numberElements[7].charAt(0); exponentialSeparator = numberElements[7]; //string representation new since 1.6 perMill = numberElements[8].charAt(0); infinity = numberElements[9]; NaN = numberElements[10]; // maybe filled with previously cached values, or null. intlCurrencySymbol = (String) data[1]; currencySymbol = (String) data[2]; // Currently the monetary decimal separator is the same as the // standard decimal separator for all locales that we support. // If that changes, add a new entry to NumberElements. monetarySeparator = decimalSeparator; }
/** * Returns a {@link DecimalFormatSymbols} instance for the * specified locale obtained from either the runtime itself * or one of the installed * {@link java.text.spi.DecimalFormatSymbolsProvider} instances. * * @param locale the locale for which an instance should be * returned. * @return a {@link DecimalFormatSymbols} instance for the specified * locale. * @throws NullPointerException if <code>locale</code> is * <code>null</code>. * @since 1.6 */ public static final DecimalFormatSymbols getInstance(Locale locale) { try { if (!locale.equals(Locale.ROOT)) ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale, ClassLoader.getSystemClassLoader()); return new DecimalFormatSymbols(locale); } catch (MissingResourceException x) { /* This means runtime support for the locale * is not available, so we check providers. */ } for (DecimalFormatSymbolsProvider p : ServiceLoader.load(DecimalFormatSymbolsProvider.class)) { for (Locale loc : p.getAvailableLocales()) { if (loc.equals(locale)) { DecimalFormatSymbols syms = p.getInstance(locale); if (syms != null) return syms; break; } } } return getInstance(LocaleHelper.getFallbackLocale(locale)); }
public DecimalFormatSymbols getObject( DecimalFormatSymbolsProvider decimalFormatSymbolsProvider, Locale locale, String key, Object... params) { assert params.length == 0; return decimalFormatSymbolsProvider.getInstance(locale); }
@Override public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() { return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class); }
@Override public void addImpl(DecimalFormatSymbolsProvider impl) { for (Locale l : impl.getAvailableLocales()) { map.putIfAbsent(l, impl); } }
@Override public DecimalFormatSymbolsProvider getImpl(Locale locale) { return SPILocaleProviderAdapter.getImpl(map, locale); }