< prev index next >

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

Print this page




 161                     if (i == index || !exists(names, i)) {
 162                         names[i] = compatNames[i];
 163                     }
 164                 }
 165                 return;
 166             }
 167         }
 168 
 169         // Type Fallback
 170         if (noDST && typeFallback(names, index)) {
 171             return;
 172         }
 173 
 174         // Region Fallback
 175         if (regionFormatFallback(names, index, locale)) {
 176             return;
 177         }
 178 
 179         // last resort
 180         String id = names[INDEX_TZID].toUpperCase(Locale.ROOT);
 181         if (!id.startsWith("ETC/GMT") &&
 182                 !id.startsWith("GMT") &&
 183                 !id.startsWith("UT")) {
 184             names[index] = toGMTFormat(names[INDEX_TZID],
 185                                        index == INDEX_DST_LONG || index == INDEX_DST_SHORT,
 186                                        index % 2 != 0,
 187                                        locale);
















 188         }
 189     }
 190 
 191     private boolean exists(String[] names, int index) {
 192         return Objects.nonNull(names)
 193                 && Objects.nonNull(names[index])
 194                 && !names[index].isEmpty();
 195     }
 196 
 197     private boolean typeFallback(String[] names, int index) {
 198         // check generic
 199         int genIndex = INDEX_GEN_SHORT - index % 2;
 200         if (!exists(names, index) && exists(names, genIndex)) {
 201             names[index] = names[genIndex];
 202         } else {
 203             // check standard
 204             int stdIndex = INDEX_STD_SHORT - index % 2;
 205             if (!exists(names, index) && exists(names, stdIndex)) {
 206                 names[index] = names[stdIndex];
 207             }




 161                     if (i == index || !exists(names, i)) {
 162                         names[i] = compatNames[i];
 163                     }
 164                 }
 165                 return;
 166             }
 167         }
 168 
 169         // Type Fallback
 170         if (noDST && typeFallback(names, index)) {
 171             return;
 172         }
 173 
 174         // Region Fallback
 175         if (regionFormatFallback(names, index, locale)) {
 176             return;
 177         }
 178 
 179         // last resort
 180         String id = names[INDEX_TZID].toUpperCase(Locale.ROOT);
 181         if (!id.startsWith("UT")) {


 182             names[index] = toGMTFormat(names[INDEX_TZID],
 183                                        index == INDEX_DST_LONG || index == INDEX_DST_SHORT,
 184                                        index % 2 != 0,
 185                                        locale);
 186             // aliases of "GMT" timezone.
 187             if ((exists(names, INDEX_STD_LONG)) && (id.startsWith("Etc/")
 188                     || id.startsWith("GMT") || id.startsWith("Greenwich"))) {
 189                 switch (id) {
 190                 case "Etc/GMT":
 191                 case "Etc/GMT-0":
 192                 case "Etc/GMT+0":
 193                 case "Etc/GMT0":
 194                 case "GMT+0":
 195                 case "GMT-0":
 196                 case "GMT0":
 197                 case "Greenwich":                   
 198                     names[INDEX_DST_LONG] = names[INDEX_GEN_LONG] = names[INDEX_STD_LONG];
 199                     break;        
 200                 }
 201             }
 202         }
 203     }
 204 
 205     private boolean exists(String[] names, int index) {
 206         return Objects.nonNull(names)
 207                 && Objects.nonNull(names[index])
 208                 && !names[index].isEmpty();
 209     }
 210 
 211     private boolean typeFallback(String[] names, int index) {
 212         // check generic
 213         int genIndex = INDEX_GEN_SHORT - index % 2;
 214         if (!exists(names, index) && exists(names, genIndex)) {
 215             names[index] = names[genIndex];
 216         } else {
 217             // check standard
 218             int stdIndex = INDEX_STD_SHORT - index % 2;
 219             if (!exists(names, index) && exists(names, stdIndex)) {
 220                 names[index] = names[stdIndex];
 221             }


< prev index next >