src/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java

Print this page
rev 6663 : imported patch 8008576

*** 32,54 **** --- 32,57 ---- import java.text.spi.CollatorProvider; import java.text.spi.DateFormatProvider; import java.text.spi.DateFormatSymbolsProvider; import java.text.spi.DecimalFormatSymbolsProvider; import java.text.spi.NumberFormatProvider; + import java.util.Calendar; import java.util.HashSet; import java.util.Locale; import java.util.Set; import java.util.StringTokenizer; + import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.spi.CalendarDataProvider; import java.util.spi.CalendarNameProvider; import java.util.spi.CurrencyNameProvider; import java.util.spi.LocaleNameProvider; import java.util.spi.LocaleServiceProvider; import java.util.spi.TimeZoneNameProvider; import sun.util.resources.LocaleData; + import sun.util.spi.CalendarProvider; /** * LocaleProviderAdapter implementation for the legacy JRE locale data. * * @author Naoto Sato
*** 102,111 **** --- 105,116 ---- 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"); } }
*** 120,129 **** --- 125,136 ---- private volatile LocaleNameProvider localeNameProvider = null; private volatile TimeZoneNameProvider timeZoneNameProvider = null; private volatile CalendarDataProvider calendarDataProvider = null; private volatile CalendarNameProvider calendarNameProvider = null; + private volatile CalendarProvider calendarProvider = null; + /* * Getter methods for java.text.spi.* providers */ @Override public BreakIteratorProvider getBreakIteratorProvider() {
*** 281,290 **** --- 288,331 ---- } } return calendarNameProvider; } + /** + * Getter methods for sun.util.spi.* providers + */ + @Override + public CalendarProvider getCalendarProvider() { + // Return a dummy here to pretend supporting this provider. + // Real instantiation happens in Calendar.createCalendar(). + if (calendarProvider == null) { + CalendarProvider provider; + provider = new CalendarProvider() { + @Override + public Locale[] getAvailableLocales() { + return null; + } + + @Override + public boolean isSupportedLocale(Locale l) { + return true; + } + + @Override + public Calendar getInstance(TimeZone tz, Locale l) { + return null; + } + }; + synchronized (this) { + if (calendarProvider == null) { + calendarProvider = provider; + } + } + } + return calendarProvider; + } + @Override public LocaleResources getLocaleResources(Locale locale) { LocaleResources lr = localeResourcesMap.get(locale); if (lr == null) { lr = new LocaleResources(this, locale);