Java Code Examples for java.text.spi.DecimalFormatSymbolsProvider

The following examples show how to use java.text.spi.DecimalFormatSymbolsProvider. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: jdk-1.7-annotated   Source File: DecimalFormatSymbols.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source Project: Bytecoder   Source File: JRELocaleProviderAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 3
@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;
}
 
Example 4
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 5
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 6
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 7
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 8
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 9
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 10
/**
 * 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;
}
 
Example 11
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 12
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 13
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    if (decimalFormatSymbolsProvider == null) {
        DecimalFormatSymbolsProvider provider = new DecimalFormatSymbolsProviderImpl(getAdapterType(), getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (decimalFormatSymbolsProvider == null) {
                decimalFormatSymbolsProvider = provider;
            }
        }
    }
    return decimalFormatSymbolsProvider;
}
 
Example 14
@Override
public DecimalFormatSymbolsProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example 15
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 16
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example 17
@Override
public DecimalFormatSymbolsProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example 18
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 19
@Override
public DecimalFormatSymbolsProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example 20
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 21
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example 22
@Override
public DecimalFormatSymbolsProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example 23
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 24
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 25
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example 26
@Override
public DecimalFormatSymbolsProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example 27
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 28
Source Project: Bytecoder   Source File: DecimalFormatSymbols.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Initializes the symbols from the FormatData resource bundle.
 */
private void initialize( Locale locale ) {
    this.locale = locale;

    // check for region override
    Locale override = locale.getUnicodeLocaleType("nu") == null ?
        CalendarDataUtility.findRegionOverride(locale) :
        locale;

    // get resource bundle data
    LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, override);
    // Avoid potential recursions
    if (!(adapter instanceof ResourceBundleBasedAdapter)) {
        adapter = LocaleProviderAdapter.getResourceBundleBased();
    }
    Object[] data = adapter.getLocaleResources(override).getDecimalFormatSymbolsData();
    String[] numberElements = (String[]) data[0];

    decimalSeparator = numberElements[0].charAt(0);
    groupingSeparator = numberElements[1].charAt(0);
    patternSeparator = numberElements[2].charAt(0);
    percentText = numberElements[3];
    percent = findNonFormatChar(percentText, '%');
    zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
    digit = numberElements[5].charAt(0);
    minusSignText = numberElements[6];
    minusSign = findNonFormatChar(minusSignText, '-');
    exponential = numberElements[7].charAt(0);
    exponentialSeparator = numberElements[7]; //string representation new since 1.6
    perMillText = numberElements[8];
    perMill = findNonFormatChar(perMillText, '\u2030');
    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;
}
 
Example 29
Source Project: Bytecoder   Source File: AuxLocaleProviderAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 30
Source Project: Bytecoder   Source File: SPILocaleProviderAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Map<Locale, DecimalFormatSymbolsProvider> getDelegateMap() {
    return map;
}
 
Example 31
Source Project: Bytecoder   Source File: SPILocaleProviderAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DecimalFormatSymbols getInstance(Locale locale) {
    locale = CalendarDataUtility.findRegionOverride(locale);
    DecimalFormatSymbolsProvider dfsp = getImpl(locale);
    return dfsp.getInstance(locale);
}
 
Example 32
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example 33
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 34
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example 35
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 36
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 37
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example 38
@Override
public DecimalFormatSymbolsProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example 39
@Override
public DecimalFormatSymbolsProvider getDecimalFormatSymbolsProvider() {
    return getLocaleServiceProvider(DecimalFormatSymbolsProvider.class);
}
 
Example 40
@Override
public void addImpl(DecimalFormatSymbolsProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}