Java Code Examples for java.text.spi.NumberFormatProvider

The following examples show how to use java.text.spi.NumberFormatProvider. 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: jdk1.8-source-analysis   Source File: NumberFormat.java    License: 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 Project: Java8CN   Source File: NumberFormat.java    License: 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 3
Source Project: hottub   Source File: NumberFormat.java    License: 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 Project: openjdk-8   Source File: NumberFormat.java    License: 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
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 Project: jdk8u60   Source File: NumberFormat.java    License: 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 7
Source Project: openjdk-jdk8u   Source File: NumberFormat.java    License: 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 8
Source Project: jdk8u-jdk   Source File: NumberFormat.java    License: 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 9
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 10
Source Project: Bytecoder   Source File: NumberFormat.java    License: 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 11
Source Project: Bytecoder   Source File: JRELocaleProviderAdapter.java    License: 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 12
Source Project: jdk-1.7-annotated   Source File: NumberFormat.java    License: 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 13
Source Project: jdk8u-dev-jdk   Source File: NumberFormat.java    License: 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 Project: jdk1.8-source-analysis   Source File: NumberFormat.java    License: Apache License 2.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 15
Source Project: jdk8u-jdk   Source File: NumberFormat.java    License: 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 16
Source Project: jdk8u-jdk   Source File: JSpinner.java    License: 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 17
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example 18
@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 Project: dragonwell8_jdk   Source File: JSpinner.java    License: 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 20
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example 21
Source Project: TencentKona-8   Source File: NumberFormat.java    License: 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 22
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example 23
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 Project: jdk8u60   Source File: NumberFormat.java    License: 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 25
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example 26
Source Project: jdk8u60   Source File: JSpinner.java    License: 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 27
Source Project: JDKSourceCode1.8   Source File: JSpinner.java    License: 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 28
Source Project: jdk8u-jdk   Source File: JSpinner.java    License: 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 29
@Override
public NumberFormatProvider getNumberFormatProvider() {
    if (numberFormatProvider == null) {
        NumberFormatProvider provider = new NumberFormatProviderImpl(getAdapterType(),
                                                    getLanguageTagSet("FormatData"));
        synchronized (this) {
            if (numberFormatProvider == null) {
                numberFormatProvider = provider;
            }
        }
    }
    return numberFormatProvider;
}
 
Example 30
Source Project: jdk8u_jdk   Source File: JSpinner.java    License: 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];
}