src/java.base/share/classes/sun/util/locale/provider/CalendarProviderImpl.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) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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

@@ -24,11 +24,10 @@
  */
 
 package sun.util.locale.provider;
 
 import java.util.Calendar;
-import java.util.Calendar.Builder;
 import java.util.Locale;
 import java.util.Set;
 import java.util.TimeZone;
 import sun.util.spi.CalendarProvider;
 

@@ -38,15 +37,14 @@
  *
  * @author Naoto Sato
  */
 public class CalendarProviderImpl extends CalendarProvider implements AvailableLanguageTags {
     private final LocaleProviderAdapter.Type type;
-    private final Set<String> langtags;
+    private Set<String> langtags;
 
-    public CalendarProviderImpl(LocaleProviderAdapter.Type type, Set<String> langtags) {
+    public CalendarProviderImpl(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,11 +52,11 @@
      * @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) {
         // Support any locales.

@@ -88,8 +86,15 @@
                      .build();
     }
 
     @Override
     public Set<String> getAvailableLanguageTags() {
+        return getLangTags();
+    }
+
+    private Set<String> getLangTags() {
+        if (langtags == null) {
+            langtags = ((JRELocaleProviderAdapter)LocaleProviderAdapter.forType(type)).getLanguageTagSet("CalendarData");
+        }
         return langtags;
     }
 }