src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameProviderImpl.java

Print this page
rev 10528 : 8038436: Re-examine the mechanism to determine available localedata and cldrdata
Reviewed-by:

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -38,15 +38,14 @@
  * @author Naoto Sato
  * @author Masayoshi Okutsu
  */
 public class TimeZoneNameProviderImpl extends TimeZoneNameProvider {
     private final LocaleProviderAdapter.Type type;
-    private final Set<String> langtags;
+    private Set<String> langtags;
 
-    TimeZoneNameProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
+    TimeZoneNameProviderImpl(LocaleProviderAdapter.Type type) {
         this.type = type;
-        this.langtags = langtags;
     }
 
     /**
      * Returns an array of all locales for which this locale service provider
      * can provide localized objects or names.

@@ -54,16 +53,16 @@
      * @return An array of all locales for which this locale service provider
      * can provide localized objects or names.
      */
     @Override
     public Locale[] getAvailableLocales() {
-        return LocaleProviderAdapter.toLocaleArray(langtags);
+        return LocaleProviderAdapter.toLocaleArray(getLangTags());
     }
 
     @Override
     public boolean isSupportedLocale(Locale locale) {
-        return LocaleProviderAdapter.isSupportedLocale(locale, type, langtags);
+        return LocaleProviderAdapter.isSupportedLocale(locale, type, getLangTags());
     }
 
     /**
      * Returns a name for the given time zone ID that's suitable for
      * presentation to the user in the specified locale. The given time

@@ -76,11 +75,11 @@
      * <p>
      * If <code>daylight</code> is true, the method should return a name
      * appropriate for daylight saving time even if the specified time zone
      * has not observed daylight saving time in the past.
      *
-     * @param ID a time zone ID string
+     * @param id a time zone ID string
      * @param daylight if true, return the daylight saving name.
      * @param style either {@link java.util.TimeZone#LONG TimeZone.LONG} or
      *    {@link java.util.TimeZone#SHORT TimeZone.SHORT}
      * @param locale the desired locale
      * @return the human-readable name of the given time zone in the

@@ -120,10 +119,17 @@
             throw new NullPointerException();
         }
         return LocaleProviderAdapter.forType(type).getLocaleResources(locale).getTimeZoneNames(id, n);
     }
 
+    private Set<String> getLangTags() {
+        if (langtags == null) {
+            langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("TimeZoneNames");
+        }
+        return langtags;
+    }
+
     /**
      * Returns a String[][] as the DateFormatSymbols.getZoneStrings() value for
      * the given locale. This method is package private.
      *
      * @param locale a Locale for time zone names