src/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java
Print this page
rev 6352 : imported patch 7162007
@@ -23,18 +23,14 @@
* questions.
*/
package sun.util.locale.provider;
-import java.util.LinkedHashSet;
import java.util.Locale;
-import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.spi.TimeZoneNameProvider;
-import sun.util.calendar.ZoneInfo;
-import sun.util.resources.TimeZoneNamesBundle;
/**
* Concrete implementation of the
* {@link java.util.spi.TimeZoneNameProvider TimeZoneNameProvider} class
* for the JRE LocaleProviderAdapter.
@@ -121,13 +117,11 @@
private String[] getDisplayNameArray(String id, int n, Locale locale) {
if (id == null || locale == null) {
throw new NullPointerException();
}
- LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
- TimeZoneNamesBundle rb = adapter.getLocaleResources(locale).getTimeZoneNames();
- return rb.containsKey(id) ? rb.getStringArray(id, n) : null;
+ return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getTimeZoneNames(id, n);
}
/**
* Returns a String[][] as the DateFormatSymbols.getZoneStrings() value for
* the given locale. This method is package private.
@@ -134,32 +128,8 @@
*
* @param locale a Locale for time zone names
* @return an array of time zone names arrays
*/
String[][] getZoneStrings(Locale locale) {
- LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
- TimeZoneNamesBundle rb = adapter.getLocaleResources(locale).getTimeZoneNames();
- Set<String> keyset = rb.keySet();
- // Use a LinkedHashSet to preseve the order
- Set<String[]> value = new LinkedHashSet<>();
- for (String key : keyset) {
- value.add(rb.getStringArray(key));
+ return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getZoneStrings();
}
-
- // Add aliases data for CLDR
- if (type == LocaleProviderAdapter.Type.CLDR) {
- // Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
- Map<String, String> aliases = ZoneInfo.getAliasTable();
- for (String alias : aliases.keySet()) {
- if (!keyset.contains(alias)) {
- String tzid = aliases.get(alias);
- if (keyset.contains(tzid)) {
- String[] val = rb.getStringArray(tzid);
- val[0] = alias;
- value.add(val);
- }
- }
- }
- }
- return value.toArray(new String[0][]);
- }
}