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

Print this page

        

*** 64,84 **** public static String retrieveFieldValueName(String id, int field, int value, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); return pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), ! field, value, style); } public static Map<String, Integer> retrieveFieldValueNames(String id, int field, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); return pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, ! normalizeCalendarType(id), field, style); } ! private static String normalizeCalendarType(String requestID) { String type; if (requestID.equals("gregorian") || requestID.equals("iso8601")) { type = "gregory"; } else if (requestID.startsWith("islamic")) { type = "islamic"; --- 64,110 ---- public static String retrieveFieldValueName(String id, int field, int value, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); return pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), ! field, value, style, false); ! } ! ! public static String retrieveCldrFieldValueName(String id, int field, int value, int style, Locale locale) { ! LocaleServiceProviderPool pool = ! LocaleServiceProviderPool.getPool(CalendarNameProvider.class); ! String name; ! name = pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), ! field, value, style, true); ! if (name == null) { ! name = pool.getLocalizedObject(CalendarFieldValueNameGetter.INSTANCE, locale, normalizeCalendarType(id), ! field, value, style, false); ! } ! return name; } public static Map<String, Integer> retrieveFieldValueNames(String id, int field, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); return pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, ! normalizeCalendarType(id), field, style, false); ! } ! ! public static Map<String, Integer> retrieveCldrFieldValueNames(String id, int field, int style, Locale locale) { ! LocaleServiceProviderPool pool = ! LocaleServiceProviderPool.getPool(CalendarNameProvider.class); ! Map<String, Integer> map; ! map = pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, ! normalizeCalendarType(id), field, style, true); ! if (map == null) { ! map = pool.getLocalizedObject(CalendarFieldValueNamesMapGetter.INSTANCE, locale, ! normalizeCalendarType(id), field, style, false); ! } ! return map; } ! static String normalizeCalendarType(String requestID) { String type; if (requestID.equals("gregorian") || requestID.equals("iso8601")) { type = "gregory"; } else if (requestID.startsWith("islamic")) { type = "islamic";
*** 101,114 **** @Override public String getObject(CalendarNameProvider calendarNameProvider, Locale locale, String requestID, // calendarType Object... params) { ! assert params.length == 3; int field = (int) params[0]; int value = (int) params[1]; int style = (int) params[2]; return calendarNameProvider.getDisplayName(requestID, field, value, style, locale); } } /** --- 127,150 ---- @Override public String getObject(CalendarNameProvider calendarNameProvider, Locale locale, String requestID, // calendarType Object... params) { ! assert params.length == 4; int field = (int) params[0]; int value = (int) params[1]; int style = (int) params[2]; + boolean cldr = (boolean) params[3]; + + // If cldr is true, resources from CLDR have precedence over JRE + // native resources. + if (cldr && calendarNameProvider instanceof CalendarNameProviderImpl) { + String name; + name = ((CalendarNameProviderImpl)calendarNameProvider) + .getCldrDisplayName(requestID, field, value, style, locale); + return name; + } return calendarNameProvider.getDisplayName(requestID, field, value, style, locale); } } /**
*** 124,136 **** @Override public Map<String, Integer> getObject(CalendarNameProvider calendarNameProvider, Locale locale, String requestID, // calendarType Object... params) { ! assert params.length == 2; int field = (int) params[0]; int style = (int) params[1]; return calendarNameProvider.getDisplayNames(requestID, field, style, locale); } } private static class CalendarWeekParameterGetter --- 160,182 ---- @Override public Map<String, Integer> getObject(CalendarNameProvider calendarNameProvider, Locale locale, String requestID, // calendarType Object... params) { ! assert params.length == 3; int field = (int) params[0]; int style = (int) params[1]; + boolean cldr = (boolean) params[2]; + + // If cldr is true, resources from CLDR have precedence over JRE + // native resources. + if (cldr && calendarNameProvider instanceof CalendarNameProviderImpl) { + Map<String, Integer> map; + map = ((CalendarNameProviderImpl)calendarNameProvider) + .getCldrDisplayNames(requestID, field, style, locale); + return map; + } return calendarNameProvider.getDisplayNames(requestID, field, style, locale); } } private static class CalendarWeekParameterGetter