java.text.spi.CollatorProvider Java Examples

The following examples show how to use java.text.spi.CollatorProvider. 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: JRELocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = AccessController.doPrivileged(
            (PrivilegedAction<CollatorProvider>) () ->
                new CollatorProviderImpl(
                    getAdapterType(),
                    getLanguageTagSet("CollationData")));

        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #2
Source File: Collator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #3
Source File: Collator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #4
Source File: Collator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #5
Source File: JRELocaleProviderAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
                                            getLanguageTagSet("CollationData"));
        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #6
Source File: Collator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #7
Source File: Collator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #8
Source File: Collator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #9
Source File: JRELocaleProviderAdapter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
                                            getLanguageTagSet("CollationData"));
        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #10
Source File: JRELocaleProviderAdapter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
                                            getLanguageTagSet("CollationData"));
        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #11
Source File: Collator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #12
Source File: JRELocaleProviderAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
                                            getLanguageTagSet("CollationData"));
        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #13
Source File: Collator.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #14
Source File: JRELocaleProviderAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
                                            getLanguageTagSet("CollationData"));
        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #15
Source File: JRELocaleProviderAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    if (collatorProvider == null) {
        CollatorProvider provider = new CollatorProviderImpl(getAdapterType(),
                                            getLanguageTagSet("CollationData"));
        synchronized (this) {
            if (collatorProvider == null) {
                collatorProvider = provider;
            }
        }
    }
    return collatorProvider;
}
 
Example #16
Source File: Collator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #17
Source File: Collator.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the Collator for the desired locale.
 * @param desiredLocale the desired locale.
 * @return the Collator for the desired locale.
 * @see java.util.Locale
 * @see java.util.ResourceBundle
 */
public static Collator getInstance(Locale desiredLocale) {
    SoftReference<Collator> ref = cache.get(desiredLocale);
    Collator result = (ref != null) ? ref.get() : null;
    if (result == null) {
        LocaleProviderAdapter adapter;
        adapter = LocaleProviderAdapter.getAdapter(CollatorProvider.class,
                                                   desiredLocale);
        CollatorProvider provider = adapter.getCollatorProvider();
        result = provider.getInstance(desiredLocale);
        if (result == null) {
            result = LocaleProviderAdapter.forJRE()
                         .getCollatorProvider().getInstance(desiredLocale);
        }
        while (true) {
            if (ref != null) {
                // Remove the empty SoftReference if any
                cache.remove(desiredLocale, ref);
            }
            ref = cache.putIfAbsent(desiredLocale, new SoftReference<>(result));
            if (ref == null) {
                break;
            }
            Collator cachedColl = ref.get();
            if (cachedColl != null) {
                result = cachedColl;
                break;
            }
        }
    }
    return (Collator) result.clone(); // make the world safe
}
 
Example #18
Source File: AuxLocaleProviderAdapter.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #19
Source File: SPILocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public Collator getInstance(Locale locale) {
    locale = CalendarDataUtility.findRegionOverride(locale);
    CollatorProvider cp = getImpl(locale);
    return cp.getInstance(locale);
}
 
Example #20
Source File: CLDRLocaleProviderAdapter.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #21
Source File: SPILocaleProviderAdapter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addImpl(CollatorProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example #22
Source File: SPILocaleProviderAdapter.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example #23
Source File: AuxLocaleProviderAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #24
Source File: AuxLocaleProviderAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #25
Source File: SPILocaleProviderAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addImpl(CollatorProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}
 
Example #26
Source File: SPILocaleProviderAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example #27
Source File: CLDRLocaleProviderAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #28
Source File: AuxLocaleProviderAdapter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #29
Source File: CLDRLocaleProviderAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #30
Source File: SPILocaleProviderAdapter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addImpl(CollatorProvider impl) {
    for (Locale l : impl.getAvailableLocales()) {
        map.putIfAbsent(l, impl);
    }
}