< prev index next >

src/java.base/share/classes/sun/util/cldr/CLDRTimeZoneNameProviderImpl.java

Print this page
rev 53432 : [mq]: 8217366
   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 131         // Fill in for the empty names.
 132         // English names are prefilled for performance.
 133         if (!locale.equals(Locale.ENGLISH) &&
 134             !locale.equals(Locale.US)) {
 135             for (int zoneIndex = 0; zoneIndex < ret.length; zoneIndex++) {
 136                 deriveFallbackNames(ret[zoneIndex], locale);
 137             }
 138         }
 139         return ret;
 140     }
 141 
 142     // Derive fallback time zone name according to LDML's logic
 143     private void deriveFallbackNames(String[] names, Locale locale) {
 144         for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
 145             deriveFallbackName(names, i, locale, false);
 146         }
 147     }
 148 
 149     private void deriveFallbackName(String[] names, int index, Locale locale, boolean noDST) {
 150         if (exists(names, index)) {






 151             return;
 152         }
 153 
 154         // Check if COMPAT can substitute the name
 155         if (LocaleProviderAdapter.getAdapterPreference().contains(Type.JRE)) {
 156             String[] compatNames = (String[])LocaleProviderAdapter.forJRE()
 157                 .getLocaleResources(locale)
 158                 .getTimeZoneNames(names[INDEX_TZID]);
 159             if (compatNames != null) {
 160                 for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
 161                     // Assumes COMPAT has no empty slots
 162                     if (i == index || !exists(names, i)) {
 163                         names[i] = compatNames[i];
 164                     }
 165                 }
 166                 return;
 167             }
 168         }
 169 
 170         // Type Fallback


   1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 131         // Fill in for the empty names.
 132         // English names are prefilled for performance.
 133         if (!locale.equals(Locale.ENGLISH) &&
 134             !locale.equals(Locale.US)) {
 135             for (int zoneIndex = 0; zoneIndex < ret.length; zoneIndex++) {
 136                 deriveFallbackNames(ret[zoneIndex], locale);
 137             }
 138         }
 139         return ret;
 140     }
 141 
 142     // Derive fallback time zone name according to LDML's logic
 143     private void deriveFallbackNames(String[] names, Locale locale) {
 144         for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
 145             deriveFallbackName(names, i, locale, false);
 146         }
 147     }
 148 
 149     private void deriveFallbackName(String[] names, int index, Locale locale, boolean noDST) {
 150         if (exists(names, index)) {
 151             if (names[index].equals(NO_INHERITANCE_MARKER)) {
 152                 // CLDR's "no inheritance marker"
 153                 names[index] = toGMTFormat(names[INDEX_TZID],
 154                                     index == INDEX_DST_LONG || index == INDEX_DST_SHORT,
 155                                     index % 2 != 0, locale);
 156             }
 157             return;
 158         }
 159 
 160         // Check if COMPAT can substitute the name
 161         if (LocaleProviderAdapter.getAdapterPreference().contains(Type.JRE)) {
 162             String[] compatNames = (String[])LocaleProviderAdapter.forJRE()
 163                 .getLocaleResources(locale)
 164                 .getTimeZoneNames(names[INDEX_TZID]);
 165             if (compatNames != null) {
 166                 for (int i = INDEX_STD_LONG; i <= INDEX_GEN_SHORT; i++) {
 167                     // Assumes COMPAT has no empty slots
 168                     if (i == index || !exists(names, i)) {
 169                         names[i] = compatNames[i];
 170                     }
 171                 }
 172                 return;
 173             }
 174         }
 175 
 176         // Type Fallback


< prev index next >