< prev index next >

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

Print this page
rev 54380 : 8221701: Archive constant BaseLocales
Reviewed-by: naoto


  27  * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
  28  * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
  29  *
  30  * The original version of this source code and documentation
  31  * is copyrighted and owned by Taligent, Inc., a wholly-owned
  32  * subsidiary of IBM. These materials are provided under terms
  33  * of a License Agreement between Taligent and Sun. This technology
  34  * is protected by multiple US and International patents.
  35  *
  36  * This notice and attribution to Taligent may not be removed.
  37  * Taligent is a registered trademark of Taligent, Inc.
  38  *
  39  */
  40 
  41 package sun.util.locale.provider;
  42 
  43 import java.lang.ref.ReferenceQueue;
  44 import java.lang.ref.SoftReference;
  45 import java.text.MessageFormat;
  46 import java.text.NumberFormat;

  47 import java.util.Calendar;
  48 import java.util.HashSet;
  49 import java.util.LinkedHashSet;
  50 import java.util.Locale;
  51 import java.util.Map;
  52 import java.util.Objects;
  53 import java.util.ResourceBundle;
  54 import java.util.Set;
  55 import java.util.TimeZone;
  56 import java.util.concurrent.ConcurrentHashMap;
  57 import java.util.concurrent.ConcurrentMap;
  58 import sun.security.action.GetPropertyAction;
  59 import sun.util.resources.LocaleData;
  60 import sun.util.resources.OpenListResourceBundle;
  61 import sun.util.resources.ParallelListResourceBundle;
  62 import sun.util.resources.TimeZoneNamesBundle;
  63 
  64 /**
  65  * Central accessor to locale-dependent resources for JRE/CLDR provider adapters.
  66  *


 308         Set<String> zoneIDs = null;
 309 
 310         removeEmptyReferences();
 311         ResourceReference data = cache.get(ZONE_IDS_CACHEKEY);
 312         if (data == null || ((zoneIDs = (Set<String>) data.get()) == null)) {
 313             TimeZoneNamesBundle rb = localeData.getTimeZoneNames(locale);
 314             zoneIDs = rb.keySet();
 315             cache.put(ZONE_IDS_CACHEKEY,
 316                       new ResourceReference(ZONE_IDS_CACHEKEY, (Object) zoneIDs, referenceQueue));
 317         }
 318 
 319         return zoneIDs;
 320     }
 321 
 322     // zoneStrings are cached separately in TimeZoneNameUtility.
 323     String[][] getZoneStrings() {
 324         TimeZoneNamesBundle rb = localeData.getTimeZoneNames(locale);
 325         Set<String> keyset = getZoneIDs();
 326         // Use a LinkedHashSet to preseve the order
 327         Set<String[]> value = new LinkedHashSet<>();
 328         Set<String> tzIds = new HashSet<>(Set.of(TimeZone.getAvailableIDs()));
 329         for (String key : keyset) {
 330             if (!key.startsWith(TZNB_EXCITY_PREFIX)) {
 331                 value.add(rb.getStringArray(key));
 332                 tzIds.remove(key);
 333             }
 334         }
 335 
 336         if (type == LocaleProviderAdapter.Type.CLDR) {
 337             // Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
 338 
 339             // Add timezones which are not present in this keyset,
 340             // so that their fallback names will be generated at runtime.
 341             tzIds.stream().filter(i -> (!i.startsWith("Etc/GMT")
 342                     && !i.startsWith("GMT")
 343                     && !i.startsWith("SystemV")))
 344                     .forEach(tzid -> {
 345                         String[] val = new String[7];
 346                         if (keyset.contains(tzid)) {
 347                             val = rb.getStringArray(tzid);
 348                         } else {




  27  * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
  28  * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
  29  *
  30  * The original version of this source code and documentation
  31  * is copyrighted and owned by Taligent, Inc., a wholly-owned
  32  * subsidiary of IBM. These materials are provided under terms
  33  * of a License Agreement between Taligent and Sun. This technology
  34  * is protected by multiple US and International patents.
  35  *
  36  * This notice and attribution to Taligent may not be removed.
  37  * Taligent is a registered trademark of Taligent, Inc.
  38  *
  39  */
  40 
  41 package sun.util.locale.provider;
  42 
  43 import java.lang.ref.ReferenceQueue;
  44 import java.lang.ref.SoftReference;
  45 import java.text.MessageFormat;
  46 import java.text.NumberFormat;
  47 import java.util.Arrays;
  48 import java.util.Calendar;
  49 import java.util.HashSet;
  50 import java.util.LinkedHashSet;
  51 import java.util.Locale;
  52 import java.util.Map;
  53 import java.util.Objects;
  54 import java.util.ResourceBundle;
  55 import java.util.Set;
  56 import java.util.TimeZone;
  57 import java.util.concurrent.ConcurrentHashMap;
  58 import java.util.concurrent.ConcurrentMap;
  59 import sun.security.action.GetPropertyAction;
  60 import sun.util.resources.LocaleData;
  61 import sun.util.resources.OpenListResourceBundle;
  62 import sun.util.resources.ParallelListResourceBundle;
  63 import sun.util.resources.TimeZoneNamesBundle;
  64 
  65 /**
  66  * Central accessor to locale-dependent resources for JRE/CLDR provider adapters.
  67  *


 309         Set<String> zoneIDs = null;
 310 
 311         removeEmptyReferences();
 312         ResourceReference data = cache.get(ZONE_IDS_CACHEKEY);
 313         if (data == null || ((zoneIDs = (Set<String>) data.get()) == null)) {
 314             TimeZoneNamesBundle rb = localeData.getTimeZoneNames(locale);
 315             zoneIDs = rb.keySet();
 316             cache.put(ZONE_IDS_CACHEKEY,
 317                       new ResourceReference(ZONE_IDS_CACHEKEY, (Object) zoneIDs, referenceQueue));
 318         }
 319 
 320         return zoneIDs;
 321     }
 322 
 323     // zoneStrings are cached separately in TimeZoneNameUtility.
 324     String[][] getZoneStrings() {
 325         TimeZoneNamesBundle rb = localeData.getTimeZoneNames(locale);
 326         Set<String> keyset = getZoneIDs();
 327         // Use a LinkedHashSet to preseve the order
 328         Set<String[]> value = new LinkedHashSet<>();
 329         Set<String> tzIds = new HashSet<>(Arrays.asList(TimeZone.getAvailableIDs()));
 330         for (String key : keyset) {
 331             if (!key.startsWith(TZNB_EXCITY_PREFIX)) {
 332                 value.add(rb.getStringArray(key));
 333                 tzIds.remove(key);
 334             }
 335         }
 336 
 337         if (type == LocaleProviderAdapter.Type.CLDR) {
 338             // Note: TimeZoneNamesBundle creates a String[] on each getStringArray call.
 339 
 340             // Add timezones which are not present in this keyset,
 341             // so that their fallback names will be generated at runtime.
 342             tzIds.stream().filter(i -> (!i.startsWith("Etc/GMT")
 343                     && !i.startsWith("GMT")
 344                     && !i.startsWith("SystemV")))
 345                     .forEach(tzid -> {
 346                         String[] val = new String[7];
 347                         if (keyset.contains(tzid)) {
 348                             val = rb.getStringArray(tzid);
 349                         } else {


< prev index next >