106 // "parentLocales" map |
106 // "parentLocales" map |
107 private static final Map<String, SortedSet<String>> parentLocalesMap = new HashMap<>(); |
107 private static final Map<String, SortedSet<String>> parentLocalesMap = new HashMap<>(); |
108 private static final ResourceBundle.Control defCon = |
108 private static final ResourceBundle.Control defCon = |
109 ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT); |
109 ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT); |
110 |
110 |
111 private static final String[] AVAILABLE_TZIDS = TimeZone.getAvailableIDs(); |
111 private static Set<String> AVAILABLE_TZIDS; |
112 private static String zoneNameTempFile; |
112 private static String zoneNameTempFile; |
113 private static String tzDataDir; |
113 private static String tzDataDir; |
114 private static final Map<String, String> canonicalTZMap = new HashMap<>(); |
114 private static final Map<String, String> canonicalTZMap = new HashMap<>(); |
115 |
115 |
116 static enum DraftType { |
116 static enum DraftType { |
728 }); |
728 }); |
729 } |
729 } |
730 }); |
730 }); |
731 } |
731 } |
732 |
732 |
733 Arrays.stream(AVAILABLE_TZIDS).forEach(tzid -> { |
733 getAvailableZoneIds().stream().forEach(tzid -> { |
734 // If the tzid is deprecated, get the data for the replacement id |
734 // If the tzid is deprecated, get the data for the replacement id |
735 String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid)) |
735 String tzKey = Optional.ofNullable((String)handlerSupplMeta.get(tzid)) |
736 .orElse(tzid); |
736 .orElse(tzid); |
737 Object data = map.get(TIMEZONE_ID_PREFIX + tzKey); |
737 Object data = map.get(TIMEZONE_ID_PREFIX + tzKey); |
738 |
738 |
862 copyIfPresent(map, key, formatData); |
862 copyIfPresent(map, key, formatData); |
863 } |
863 } |
864 } |
864 } |
865 |
865 |
866 for (String key : map.keySet()) { |
866 for (String key : map.keySet()) { |
867 // Copy available calendar names |
867 // Copy available calendar names |
868 if (key.startsWith(CLDRConverter.LOCALE_TYPE_PREFIX_CA)) { |
868 if (key.startsWith(CLDRConverter.LOCALE_TYPE_PREFIX_CA)) { |
869 String type = key.substring(CLDRConverter.LOCALE_TYPE_PREFIX_CA.length()); |
869 String type = key.substring(CLDRConverter.LOCALE_TYPE_PREFIX_CA.length()); |
870 for (CalendarType calendarType : CalendarType.values()) { |
870 for (CalendarType calendarType : CalendarType.values()) { |
871 if (calendarType == CalendarType.GENERIC) { |
871 if (calendarType == CalendarType.GENERIC) { |
872 continue; |
872 continue; |
889 |
889 |
890 @SuppressWarnings("unchecked") |
890 @SuppressWarnings("unchecked") |
891 List<String> numberingScripts = (List<String>) map.remove("numberingScripts"); |
891 List<String> numberingScripts = (List<String>) map.remove("numberingScripts"); |
892 if (numberingScripts != null) { |
892 if (numberingScripts != null) { |
893 for (String script : numberingScripts) { |
893 for (String script : numberingScripts) { |
894 copyIfPresent(map, script + "." + "NumberElements", formatData); |
894 copyIfPresent(map, script + ".NumberElements", formatData); |
|
895 copyIfPresent(map, script + ".NumberPatterns", formatData); |
895 } |
896 } |
896 } else { |
897 } else { |
897 copyIfPresent(map, "NumberElements", formatData); |
898 copyIfPresent(map, "NumberElements", formatData); |
898 } |
899 copyIfPresent(map, "NumberPatterns", formatData); |
899 copyIfPresent(map, "NumberPatterns", formatData); |
900 } |
900 copyIfPresent(map, "short.CompactNumberPatterns", formatData); |
901 copyIfPresent(map, "short.CompactNumberPatterns", formatData); |
901 copyIfPresent(map, "long.CompactNumberPatterns", formatData); |
902 copyIfPresent(map, "long.CompactNumberPatterns", formatData); |
902 |
903 |
903 // put extra number elements for available scripts into formatData, if it is "root" |
904 // put extra number elements for available scripts into formatData, if it is "root" |
904 if (id.equals("root")) { |
905 if (id.equals("root")) { |
1072 }) |
1073 }) |
1073 .collect(Collectors.toList()), |
1074 .collect(Collectors.toList()), |
1074 StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); |
1075 StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); |
1075 } |
1076 } |
1076 |
1077 |
|
1078 // This method assumes handlerMetaZones is already initialized |
|
1079 private static Set<String> getAvailableZoneIds() { |
|
1080 assert handlerMetaZones != null; |
|
1081 if (AVAILABLE_TZIDS == null) { |
|
1082 AVAILABLE_TZIDS = new HashSet<>(ZoneId.getAvailableZoneIds()); |
|
1083 AVAILABLE_TZIDS.addAll(handlerMetaZones.keySet()); |
|
1084 AVAILABLE_TZIDS.remove(MetaZonesParseHandler.NO_METAZONE_KEY); |
|
1085 } |
|
1086 |
|
1087 return AVAILABLE_TZIDS; |
|
1088 } |
|
1089 |
1077 private static Stream<String> zidMapEntry() { |
1090 private static Stream<String> zidMapEntry() { |
1078 return ZoneId.getAvailableZoneIds().stream() |
1091 return getAvailableZoneIds().stream() |
1079 .map(id -> { |
1092 .map(id -> { |
1080 String canonId = canonicalTZMap.getOrDefault(id, id); |
1093 String canonId = canonicalTZMap.getOrDefault(id, id); |
1081 String meta = handlerMetaZones.get(canonId); |
1094 String meta = handlerMetaZones.get(canonId); |
1082 String zone001 = handlerMetaZones.zidMap().get(meta); |
1095 String zone001 = handlerMetaZones.zidMap().get(meta); |
1083 return zone001 == null ? "" : |
1096 return zone001 == null ? "" : |
1145 } |
1158 } |
1146 }) |
1159 }) |
1147 .collect(Collectors.toList()), |
1160 .collect(Collectors.toList()), |
1148 StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); |
1161 StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); |
1149 } |
1162 } |
|
1163 |
|
1164 // for debug |
|
1165 private static void dumpMap(Map<String, Object> map) { |
|
1166 map.entrySet().stream() |
|
1167 .sorted(Map.Entry.comparingByKey()) |
|
1168 .map(e -> { |
|
1169 Object val = e.getValue(); |
|
1170 String valStr = null; |
|
1171 |
|
1172 if (val instanceof String[]) { |
|
1173 valStr = Arrays.asList((String[])val).toString(); |
|
1174 } else if (val != null) { |
|
1175 valStr = val.toString(); |
|
1176 } |
|
1177 return e.getKey() + " = " + valStr; |
|
1178 }) |
|
1179 .forEach(System.out::println); |
|
1180 } |
1150 } |
1181 } |