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 Project: Bytecoder   Author: mirkosertic   File: JRELocaleProviderAdapter.java    License: 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: Collator.java    License: 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 #3
Source Project: dragonwell8_jdk   Author: alibaba   File: Collator.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: Collator.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: JRELocaleProviderAdapter.java    License: 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 Project: jdk8u-dev-jdk   Author: frohoff   File: Collator.java    License: 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 #7
Source Project: jdk8u-dev-jdk   Author: frohoff   File: JRELocaleProviderAdapter.java    License: 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 #8
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: Collator.java    License: 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 #9
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Collator.java    License: 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 #10
Source Project: openjdk-8   Author: bpupadhyaya   File: Collator.java    License: 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 #11
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: JRELocaleProviderAdapter.java    License: 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 #12
Source Project: openjdk-8   Author: bpupadhyaya   File: JRELocaleProviderAdapter.java    License: 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 Project: Bytecoder   Author: mirkosertic   File: Collator.java    License: 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 #14
Source Project: openjdk-8-source   Author: keerath   File: JRELocaleProviderAdapter.java    License: 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 Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Collator.java    License: 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 #16
Source Project: Java8CN   Author: Java8-CNAPI-Team   File: Collator.java    License: 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 #17
Source Project: hottub   Author: dsrg-uoft   File: JRELocaleProviderAdapter.java    License: 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 #18
Source Project: openjdk-8-source   Author: keerath   File: AuxLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #19
Source Project: dragonwell8_jdk   Author: alibaba   File: SPILocaleProviderAdapter.java    License: 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 #20
Source Project: dragonwell8_jdk   Author: alibaba   File: SPILocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example #21
Source Project: dragonwell8_jdk   Author: alibaba   File: CLDRLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #22
Source Project: jdk8u_jdk   Author: JetBrains   File: CLDRLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #23
Source Project: TencentKona-8   Author: Tencent   File: AuxLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #24
Source Project: TencentKona-8   Author: Tencent   File: SPILocaleProviderAdapter.java    License: 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 #25
Source Project: TencentKona-8   Author: Tencent   File: SPILocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example #26
Source Project: openjdk-8   Author: bpupadhyaya   File: CLDRLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #27
Source Project: jdk8u60   Author: chenghanpeng   File: AuxLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return getLocaleServiceProvider(CollatorProvider.class);
}
 
Example #28
Source Project: jdk8u60   Author: chenghanpeng   File: CLDRLocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getCollatorProvider() {
    return null;
}
 
Example #29
Source Project: openjdk-8-source   Author: keerath   File: SPILocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}
 
Example #30
Source Project: openjdk-8   Author: bpupadhyaya   File: SPILocaleProviderAdapter.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public CollatorProvider getImpl(Locale locale) {
    return SPILocaleProviderAdapter.getImpl(map, locale);
}