java.text.spi.NumberFormatProvider Java Examples

The following examples show how to use java.text.spi.NumberFormatProvider. 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 check out the related API usage on the sidebar.
Example #1
Source File: NumberFormat.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #2
Source File: NumberFormat.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #3
Source File: NumberFormat.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #4
Source File: NumberFormat.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #5
Source File: NumberFormat.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #6
Source File: NumberFormat.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #7
Source File: NumberFormat.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
public NumberFormat getObject(NumberFormatProvider numberFormatProvider,
                        Locale locale,
                        String key,
                        Object... params) {
    assert params.length == 1;
    int choice = (Integer)params[0];

    switch (choice) {
    case NUMBERSTYLE:
        return numberFormatProvider.getNumberInstance(locale);
    case PERCENTSTYLE:
        return numberFormatProvider.getPercentInstance(locale);
    case CURRENCYSTYLE:
        return numberFormatProvider.getCurrencyInstance(locale);
    case INTEGERSTYLE:
        return numberFormatProvider.getIntegerInstance(locale);
    default:
        assert false : choice;
    }

    return null;
}
 
Example #8
Source File: JRELocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<NumberFormatProvider>) () ->
                new NumberFormatProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("FormatData")));

        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example #9
Source File: NumberFormat.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, Style formatStyle,
                                        int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    case COMPACTSTYLE:
        numberFormat = provider.getCompactNumberInstance(locale, formatStyle);
        break;
    }
    return numberFormat;
}
 
Example #10
Source File: NumberFormat.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #11
Source File: NumberFormat.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #12
Source File: NumberFormat.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #13
Source File: NumberFormat.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static NumberFormat getInstance(LocaleProviderAdapter adapter,
                                        Locale locale, int choice) {
    NumberFormatProvider provider = adapter.getNumberFormatProvider();
    NumberFormat numberFormat = null;
    switch (choice) {
    case NUMBERSTYLE:
        numberFormat = provider.getNumberInstance(locale);
        break;
    case PERCENTSTYLE:
        numberFormat = provider.getPercentInstance(locale);
        break;
    case CURRENCYSTYLE:
        numberFormat = provider.getCurrencyInstance(locale);
        break;
    case INTEGERSTYLE:
        numberFormat = provider.getIntegerInstance(locale);
        break;
    }
    return numberFormat;
}
 
Example #14
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example #15
Source File: JRELocaleProviderAdapter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example #16
Source File: JSpinner.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}
 
Example #17
Source File: JSpinner.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}
 
Example #18
Source File: JRELocaleProviderAdapter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example #19
Source File: JRELocaleProviderAdapter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example #20
Source File: JSpinner.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}
 
Example #21
Source File: JSpinner.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}
 
Example #22
Source File: JSpinner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}
 
Example #23
Source File: NumberFormat.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static NumberFormat getInstance(Locale desiredLocale,
                                       int choice) {
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               desiredLocale);
    NumberFormat numberFormat = getInstance(adapter, desiredLocale, choice);
    if (numberFormat == null) {
        numberFormat = getInstance(LocaleProviderAdapter.forJRE(),
                                   desiredLocale, choice);
    }
    return numberFormat;
}
 
Example #24
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example #25
Source File: NumberFormat.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static NumberFormat getInstance(Locale desiredLocale,
                                       int choice) {
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               desiredLocale);
    NumberFormat numberFormat = getInstance(adapter, desiredLocale, choice);
    if (numberFormat == null) {
        numberFormat = getInstance(LocaleProviderAdapter.forJRE(),
                                   desiredLocale, choice);
    }
    return numberFormat;
}
 
Example #26
Source File: NumberFormat.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static NumberFormat getInstance(Locale desiredLocale,
                                        Style formatStyle, int choice) {
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
            desiredLocale);
    NumberFormat numberFormat = getInstance(adapter, desiredLocale,
            formatStyle, choice);
    if (numberFormat == null) {
        numberFormat = getInstance(LocaleProviderAdapter.forJRE(),
                desiredLocale, formatStyle, choice);
    }
    return numberFormat;
}
 
Example #27
Source File: SPILocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public NumberFormat getCompactNumberInstance(Locale locale,
                        NumberFormat.Style style) {
    locale = CalendarDataUtility.findRegionOverride(locale);
    NumberFormatProvider nfp = getImpl(locale);
    return nfp.getCompactNumberInstance(locale, style);
}
 
Example #28
Source File: NumberFormat.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static NumberFormat getInstance(Locale desiredLocale,
                                       int choice) {
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               desiredLocale);
    NumberFormat numberFormat = getInstance(adapter, desiredLocale, choice);
    if (numberFormat == null) {
        numberFormat = getInstance(LocaleProviderAdapter.forJRE(),
                                   desiredLocale, choice);
    }
    return numberFormat;
}
 
Example #29
Source File: JSpinner.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}
 
Example #30
Source File: JSpinner.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private static String getDefaultPattern(Locale locale) {
    // Get the pattern for the default locale.
    LocaleProviderAdapter adapter;
    adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
                                               locale);
    LocaleResources lr = adapter.getLocaleResources(locale);
    if (lr == null) {
        lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
    }
    String[] all = lr.getNumberPatterns();
    return all[0];
}