java.util.spi.LocaleServiceProvider Java Examples
The following examples show how to use
java.util.spi.LocaleServiceProvider.
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: LocaleServiceProviderPool.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns the list of locale service provider instances that support * the specified locale. * * @param locale the given locale * @return the list of locale data adapter types */ private List<LocaleProviderAdapter.Type> findProviders(Locale locale) { List<LocaleProviderAdapter.Type> providersList = providersCache.get(locale); if (providersList == null) { for (LocaleProviderAdapter.Type type : LocaleProviderAdapter.getAdapterPreference()) { LocaleServiceProvider lsp = providers.get(type); if (lsp != null) { if (lsp.isSupportedLocale(locale)) { if (providersList == null) { providersList = new ArrayList<>(2); } providersList.add(type); } } } if (providersList == null) { providersList = NULL_LIST; } List<LocaleProviderAdapter.Type> val = providersCache.putIfAbsent(locale, providersList); if (val != null) { providersList = val; } } return providersList; }
Example #2
Source File: AuxLocaleProviderAdapter.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public Locale[] getAvailableLocales() { if (availableLocales == null) { Set<Locale> avail = new HashSet<>(); for (Class<? extends LocaleServiceProvider> c : LocaleServiceProviderPool.spiClasses) { LocaleServiceProvider lsp = getLocaleServiceProvider(c); if (lsp != null) { avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. return availableLocales; }
Example #3
Source File: AuxLocaleProviderAdapter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public Locale[] getAvailableLocales() { if (availableLocales == null) { Set<Locale> avail = new HashSet<>(); for (Class<? extends LocaleServiceProvider> c : LocaleServiceProviderPool.spiClasses) { LocaleServiceProvider lsp = getLocaleServiceProvider(c); if (lsp != null) { avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. return availableLocales; }
Example #4
Source File: LocaleServiceProviderPool.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Returns the list of locale service provider instances that support * the specified locale. * * @param locale the given locale * @return the list of locale data adapter types */ private List<LocaleProviderAdapter.Type> findProviders(Locale locale) { List<LocaleProviderAdapter.Type> providersList = providersCache.get(locale); if (providersList == null) { for (LocaleProviderAdapter.Type type : LocaleProviderAdapter.getAdapterPreference()) { LocaleServiceProvider lsp = providers.get(type); if (lsp != null) { if (lsp.isSupportedLocale(locale)) { if (providersList == null) { providersList = new ArrayList<>(2); } providersList.add(type); } } } if (providersList == null) { providersList = NULL_LIST; } List<LocaleProviderAdapter.Type> val = providersCache.putIfAbsent(locale, providersList); if (val != null) { providersList = val; } } return providersList; }
Example #5
Source File: AuxLocaleProviderAdapter.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public Locale[] getAvailableLocales() { if (availableLocales == null) { Set<Locale> avail = new HashSet<>(); for (Class<? extends LocaleServiceProvider> c : LocaleServiceProviderPool.spiClasses) { LocaleServiceProvider lsp = getLocaleServiceProvider(c); if (lsp != null) { avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. return availableLocales; }
Example #6
Source File: LocaleServiceProviderPool.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns the list of locale service provider instances that support * the specified locale. * * @param locale the given locale * @return the list of locale data adapter types */ private List<LocaleProviderAdapter.Type> findProviders(Locale locale) { List<LocaleProviderAdapter.Type> providersList = providersCache.get(locale); if (providersList == null) { for (LocaleProviderAdapter.Type type : LocaleProviderAdapter.getAdapterPreference()) { LocaleServiceProvider lsp = providers.get(type); if (lsp != null) { if (lsp.isSupportedLocale(locale)) { if (providersList == null) { providersList = new ArrayList<>(2); } providersList.add(type); } } } if (providersList == null) { providersList = NULL_LIST; } List<LocaleProviderAdapter.Type> val = providersCache.putIfAbsent(locale, providersList); if (val != null) { providersList = val; } } return providersList; }
Example #7
Source File: AuxLocaleProviderAdapter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public Locale[] getAvailableLocales() { if (availableLocales == null) { Set<Locale> avail = new HashSet<>(); for (Class<? extends LocaleServiceProvider> c : LocaleServiceProviderPool.spiClasses) { LocaleServiceProvider lsp = getLocaleServiceProvider(c); if (lsp != null) { avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. return availableLocales; }
Example #8
Source File: AuxLocaleProviderAdapter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public Locale[] getAvailableLocales() { if (availableLocales == null) { Set<Locale> avail = new HashSet<>(); for (Class<? extends LocaleServiceProvider> c : LocaleServiceProviderPool.spiClasses) { LocaleServiceProvider lsp = getLocaleServiceProvider(c); if (lsp != null) { avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. return availableLocales; }
Example #9
Source File: AuxLocaleProviderAdapter.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public Locale[] getAvailableLocales() { if (availableLocales == null) { Set<Locale> avail = new HashSet<>(); for (Class<? extends LocaleServiceProvider> c : LocaleServiceProviderPool.spiClasses) { LocaleServiceProvider lsp = getLocaleServiceProvider(c); if (lsp != null) { avail.addAll(Arrays.asList(lsp.getAvailableLocales())); } } availableLocales = avail.toArray(new Locale[0]); } // assuming caller won't mutate the array. return availableLocales; }
Example #10
Source File: LocaleServiceProviderPool.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * A factory method that returns a singleton instance */ public static LocaleServiceProviderPool getPool(Class<? extends LocaleServiceProvider> providerClass) { LocaleServiceProviderPool pool = poolOfPools.get(providerClass); if (pool == null) { LocaleServiceProviderPool newPool = new LocaleServiceProviderPool(providerClass); pool = poolOfPools.putIfAbsent(providerClass, newPool); if (pool == null) { pool = newPool; } } return pool; }
Example #11
Source File: LocaleServiceProviderPool.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Returns the union of locale sets that are available from * each service provider. This method does NOT return the * defensive copy. * * @return a set of available locales */ private synchronized Set<Locale> getAvailableLocaleSet() { if (availableLocales == null) { availableLocales = new HashSet<>(); for (LocaleServiceProvider lsp : providers.values()) { Locale[] locales = lsp.getAvailableLocales(); for (Locale locale: locales) { availableLocales.add(getLookupLocale(locale)); } } } return availableLocales; }
Example #12
Source File: LocaleServiceProviderPool.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * The sole constructor. * * @param c class of the locale sensitive service */ private LocaleServiceProviderPool (final Class<? extends LocaleServiceProvider> c) { providerClass = c; for (LocaleProviderAdapter.Type type : LocaleProviderAdapter.getAdapterPreference()) { LocaleProviderAdapter lda = LocaleProviderAdapter.forType(type); if (lda != null) { LocaleServiceProvider provider = lda.getLocaleServiceProvider(c); if (provider != null) { providers.putIfAbsent(type, provider); } } } }
Example #13
Source File: AuxLocaleProviderAdapter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { @SuppressWarnings("unchecked") P lsp = (P) providersMap.get(c); if (lsp == null) { lsp = findInstalledProvider(c); providersMap.putIfAbsent(c, lsp == null ? NULL_PROVIDER : lsp); } return lsp; }
Example #14
Source File: AuxLocaleProviderAdapter.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { @SuppressWarnings("unchecked") P lsp = (P) providersMap.get(c); if (lsp == null) { lsp = findInstalledProvider(c); providersMap.putIfAbsent(c, lsp == null ? NULL_PROVIDER : lsp); } return lsp; }
Example #15
Source File: LocaleServiceProviderPool.java From Bytecoder with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <P extends LocaleServiceProvider, S> S getLocalizedObjectImpl(LocalizedObjectGetter<P, S> getter, Locale locale, boolean isObjectProvider, String key, Object... params) { if (locale == null) { throw new NullPointerException(); } List<Locale> lookupLocales = getLookupLocales(locale); for (Locale current : lookupLocales) { S providersObj; for (LocaleServiceProvider lsp: findProviders(current, isObjectProvider)) { providersObj = getter.getObject((P)lsp, locale, key, params); if (providersObj != null) { return providersObj; } else if (isObjectProvider) { config(LocaleServiceProviderPool.class, "A locale sensitive service object provider returned null, " + "which should not happen. Provider: " + lsp + " Locale: " + locale); } } } // not found. return null; }
Example #16
Source File: HostLocaleProviderAdapter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected <P extends LocaleServiceProvider> P findInstalledProvider(final Class<P> c) { try { Method getter = HostLocaleProviderAdapterImpl.class.getMethod( "get" + c.getSimpleName(), (Class<?>[]) null); return (P)getter.invoke(null, (Object[]) null); } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { LocaleServiceProviderPool.config(HostLocaleProviderAdapter.class, ex.toString()); } return null; }
Example #17
Source File: AuxLocaleProviderAdapter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { @SuppressWarnings("unchecked") P lsp = (P) providersMap.get(c); if (lsp == null) { lsp = findInstalledProvider(c); providersMap.putIfAbsent(c, lsp == null ? NULL_PROVIDER : lsp); } return lsp; }
Example #18
Source File: LocaleProviderAdapter.java From hottub with GNU General Public License v2.0 | 5 votes |
private static LocaleProviderAdapter findAdapter(Class<? extends LocaleServiceProvider> providerClass, Locale locale) { for (Type type : getAdapterPreference()) { LocaleProviderAdapter adapter = forType(type); LocaleServiceProvider provider = adapter.getLocaleServiceProvider(providerClass); if (provider != null) { if (provider.isSupportedLocale(locale)) { return adapter; } } } return null; }
Example #19
Source File: LocaleServiceProviderPool.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * A factory method that returns a singleton instance */ public static LocaleServiceProviderPool getPool(Class<? extends LocaleServiceProvider> providerClass) { LocaleServiceProviderPool pool = poolOfPools.get(providerClass); if (pool == null) { LocaleServiceProviderPool newPool = new LocaleServiceProviderPool(providerClass); pool = poolOfPools.putIfAbsent(providerClass, newPool); if (pool == null) { pool = newPool; } } return pool; }
Example #20
Source File: JRELocaleProviderAdapter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override @SuppressWarnings("unchecked") public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { switch (c.getSimpleName()) { case "BreakIteratorProvider": return (P) getBreakIteratorProvider(); case "CollatorProvider": return (P) getCollatorProvider(); case "DateFormatProvider": return (P) getDateFormatProvider(); case "DateFormatSymbolsProvider": return (P) getDateFormatSymbolsProvider(); case "DecimalFormatSymbolsProvider": return (P) getDecimalFormatSymbolsProvider(); case "NumberFormatProvider": return (P) getNumberFormatProvider(); case "CurrencyNameProvider": return (P) getCurrencyNameProvider(); case "LocaleNameProvider": return (P) getLocaleNameProvider(); case "TimeZoneNameProvider": return (P) getTimeZoneNameProvider(); case "CalendarDataProvider": return (P) getCalendarDataProvider(); case "CalendarNameProvider": return (P) getCalendarNameProvider(); case "CalendarProvider": return (P) getCalendarProvider(); default: throw new InternalError("should not come down here"); } }
Example #21
Source File: SPILocaleProviderAdapter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static <P extends LocaleServiceProvider> P getImpl(Map<Locale, P> map, Locale locale) { for (Locale l : LocaleServiceProviderPool.getLookupLocales(locale)) { P ret = map.get(l); if (ret != null) { return ret; } } return null; }
Example #22
Source File: SPILocaleProviderAdapter.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static <P extends LocaleServiceProvider> P getImpl(Map<Locale, P> map, Locale locale) { for (Locale l : LocaleServiceProviderPool.getLookupLocales(locale)) { P ret = map.get(l); if (ret != null) { return ret; } } return null; }
Example #23
Source File: AuxLocaleProviderAdapter.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { @SuppressWarnings("unchecked") P lsp = (P) providersMap.get(c); if (lsp == null) { lsp = findInstalledProvider(c); providersMap.putIfAbsent(c, lsp == null ? NULL_PROVIDER : lsp); } return lsp; }
Example #24
Source File: SPILocaleProviderAdapter.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static <P extends LocaleServiceProvider> P getImpl(Map<Locale, P> map, Locale locale) { for (Locale l : LocaleServiceProviderPool.getLookupLocales(locale)) { P ret = map.get(l); if (ret != null) { return ret; } } return null; }
Example #25
Source File: LocaleServiceProviderPool.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns the union of locale sets that are available from * each service provider. This method does NOT return the * defensive copy. * * @return a set of available locales */ private synchronized Set<Locale> getAvailableLocaleSet() { if (availableLocales == null) { availableLocales = new HashSet<>(); for (LocaleServiceProvider lsp : providers.values()) { Locale[] locales = lsp.getAvailableLocales(); for (Locale locale: locales) { availableLocales.add(getLookupLocale(locale)); } } } return availableLocales; }
Example #26
Source File: LocaleServiceProviderPool.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * The sole constructor. * * @param c class of the locale sensitive service */ private LocaleServiceProviderPool (final Class<? extends LocaleServiceProvider> c) { providerClass = c; for (LocaleProviderAdapter.Type type : LocaleProviderAdapter.getAdapterPreference()) { LocaleProviderAdapter lda = LocaleProviderAdapter.forType(type); if (lda != null) { LocaleServiceProvider provider = lda.getLocaleServiceProvider(c); if (provider != null) { providers.putIfAbsent(type, provider); } } } }
Example #27
Source File: HostLocaleProviderAdapter.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") protected <P extends LocaleServiceProvider> P findInstalledProvider(final Class<P> c) { try { Method getter = HostLocaleProviderAdapterImpl.class.getMethod( "get" + c.getSimpleName(), (Class<?>[]) null); return (P)getter.invoke(null, (Object[]) null); } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { LocaleServiceProviderPool.config(HostLocaleProviderAdapter.class, ex.toString()); } return null; }
Example #28
Source File: AuxLocaleProviderAdapter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { @SuppressWarnings("unchecked") P lsp = (P) providersMap.get(c); if (lsp == null) { lsp = findInstalledProvider(c); providersMap.putIfAbsent(c, lsp == null ? NULL_PROVIDER : lsp); } return lsp; }
Example #29
Source File: JRELocaleProviderAdapter.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override @SuppressWarnings("unchecked") public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { switch (c.getSimpleName()) { case "BreakIteratorProvider": return (P) getBreakIteratorProvider(); case "CollatorProvider": return (P) getCollatorProvider(); case "DateFormatProvider": return (P) getDateFormatProvider(); case "DateFormatSymbolsProvider": return (P) getDateFormatSymbolsProvider(); case "DecimalFormatSymbolsProvider": return (P) getDecimalFormatSymbolsProvider(); case "NumberFormatProvider": return (P) getNumberFormatProvider(); case "CurrencyNameProvider": return (P) getCurrencyNameProvider(); case "LocaleNameProvider": return (P) getLocaleNameProvider(); case "TimeZoneNameProvider": return (P) getTimeZoneNameProvider(); case "CalendarDataProvider": return (P) getCalendarDataProvider(); case "CalendarNameProvider": return (P) getCalendarNameProvider(); case "CalendarProvider": return (P) getCalendarProvider(); default: throw new InternalError("should not come down here"); } }
Example #30
Source File: AuxLocaleProviderAdapter.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Getter method for Locale Service Providers */ @Override public <P extends LocaleServiceProvider> P getLocaleServiceProvider(Class<P> c) { @SuppressWarnings("unchecked") P lsp = (P) providersMap.get(c); if (lsp == null) { lsp = findInstalledProvider(c); providersMap.putIfAbsent(c, lsp == null ? NULL_PROVIDER : lsp); } return lsp; }