make/src/classes/build/tools/cldrconverter/Bundle.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2012, 2013, 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
--- 1,7 ----
/*
! * Copyright (c) 2012, 2015, 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
*** 30,39 ****
--- 30,40 ----
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+ import java.util.Objects;
class Bundle {
static enum Type {
LOCALENAMES, CURRENCYNAMES, TIMEZONENAMES, CALENDARDATA, FORMATDATA;
*** 79,89 ****
"DateTimePatterns/medium-date",
"DateTimePatterns/short-date",
};
private final static String[] DATETIME_PATTERN_KEYS = {
! "DateTimePatterns/date-time"
};
private final static String[] ERA_KEYS = {
"long.Eras",
"Eras",
--- 80,93 ----
"DateTimePatterns/medium-date",
"DateTimePatterns/short-date",
};
private final static String[] DATETIME_PATTERN_KEYS = {
! "DateTimePatterns/full-dateTime",
! "DateTimePatterns/long-dateTime",
! "DateTimePatterns/medium-dateTime",
! "DateTimePatterns/short-dateTime",
};
private final static String[] ERA_KEYS = {
"long.Eras",
"Eras",
*** 168,190 ****
Map<String, Object> myMap = new HashMap<>();
int index;
for (index = 0; index < cldrBundles.length; index++) {
if (cldrBundles[index].equals(id)) {
myMap.putAll(CLDRConverter.getCLDRBundle(cldrBundles[index]));
break;
}
}
// parentsMap contains resources from id's parents.
Map<String, Object> parentsMap = new HashMap<>();
for (int i = cldrBundles.length - 1; i > index; i--) {
if (!("no".equals(cldrBundles[i]) || cldrBundles[i].startsWith("no_"))) {
parentsMap.putAll(CLDRConverter.getCLDRBundle(cldrBundles[i]));
}
}
// Duplicate myMap as parentsMap for "root" so that the
! // fallback works. This is a huck, though.
if ("root".equals(cldrBundles[0])) {
assert parentsMap.isEmpty();
parentsMap.putAll(myMap);
}
--- 172,196 ----
Map<String, Object> myMap = new HashMap<>();
int index;
for (index = 0; index < cldrBundles.length; index++) {
if (cldrBundles[index].equals(id)) {
myMap.putAll(CLDRConverter.getCLDRBundle(cldrBundles[index]));
+ CLDRConverter.handleAliases(myMap);
break;
}
}
// parentsMap contains resources from id's parents.
Map<String, Object> parentsMap = new HashMap<>();
for (int i = cldrBundles.length - 1; i > index; i--) {
if (!("no".equals(cldrBundles[i]) || cldrBundles[i].startsWith("no_"))) {
parentsMap.putAll(CLDRConverter.getCLDRBundle(cldrBundles[i]));
+ CLDRConverter.handleAliases(parentsMap);
}
}
// Duplicate myMap as parentsMap for "root" so that the
! // fallback works. This is a hack, though.
if ("root".equals(cldrBundles[0])) {
assert parentsMap.isEmpty();
parentsMap.putAll(myMap);
}
*** 368,377 ****
--- 374,394 ----
} else {
it.remove();
}
}
}
+
+ // Remove all duplicates
+ if (Objects.nonNull(parentsMap)) {
+ for (Iterator<String> it = myMap.keySet().iterator(); it.hasNext();) {
+ String key = it.next();
+ if (Objects.deepEquals(parentsMap.get(key), myMap.get(key))) {
+ it.remove();
+ }
+ }
+ }
+
return myMap;
}
private void handleMultipleInheritance(Map<String, Object> map, Map<String, Object> parents, String key) {
String formatKey = key + "/format";
*** 504,518 ****
}
// If patterns is empty or has any nulls, discard patterns.
if (patterns.isEmpty()) {
return;
}
- for (String p : patterns) {
- if (p == null) {
- return;
- }
- }
String key = calendarPrefix + name;
if (!rawPatterns.equals(patterns)) {
myMap.put("java.time." + key, rawPatterns.toArray(new String[len]));
}
myMap.put(key, patterns.toArray(new String[len]));
--- 521,530 ----
*** 628,638 ****
--- 640,652 ----
String name = map.get(TZ_STD_LONG_KEY);
if (name != null) {
if (name.contains("Standard Time")) {
name = name.replace("Standard Time", "Daylight Time");
} else if (name.endsWith("Mean Time")) {
+ if (!name.startsWith("Greenwich ")) {
name = name.replace("Mean Time", "Summer Time");
+ }
} else if (name.endsWith(" Time")) {
name = name.replace(" Time", " Summer Time");
}
map.put(TZ_DST_LONG_KEY, name);
fillInAbbrs(TZ_DST_LONG_KEY, TZ_DST_SHORT_KEY, map);
*** 642,653 ****
--- 656,669 ----
String name = map.get(TZ_STD_LONG_KEY);
if (name != null) {
if (name.endsWith("Standard Time")) {
name = name.replace("Standard Time", "Time");
} else if (name.endsWith("Mean Time")) {
+ if (!name.startsWith("Greenwich ")) {
name = name.replace("Mean Time", "Time");
}
+ }
map.put(TZ_GEN_LONG_KEY, name);
fillInAbbrs(TZ_GEN_LONG_KEY, TZ_GEN_SHORT_KEY, map);
}
}
}
*** 710,719 ****
--- 726,744 ----
appendN('E', 3, sb);
break;
}
break;
+ case 'l':
+ // 'l' is deprecated as a pattern character. Should be ignored.
+ break;
+
+ case 'u':
+ // Use 'y' for now.
+ appendN('y', count, sb);
+ break;
+
case 'v':
case 'V':
appendN('z', count, sb);
break;
*** 721,740 ****
if (count == 4 || count == 5) {
sb.append("XXX");
}
break;
- case 'u':
case 'U':
case 'q':
case 'Q':
- case 'l':
case 'g':
case 'j':
case 'A':
! throw new InternalError(String.format("Unsupported letter: '%c', count=%d%n",
! cldrLetter, count));
default:
appendN(cldrLetter, count, sb);
break;
}
}
--- 746,763 ----
if (count == 4 || count == 5) {
sb.append("XXX");
}
break;
case 'U':
case 'q':
case 'Q':
case 'g':
case 'j':
case 'A':
! throw new InternalError(String.format("Unsupported letter: '%c', count=%d, id=%s%n",
! cldrLetter, count, id));
default:
appendN(cldrLetter, count, sb);
break;
}
}