--- old/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java 2019-10-25 15:37:01.000000000 -0700 +++ new/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java 2019-10-25 15:37:00.000000000 -0700 @@ -29,6 +29,7 @@ import java.io.IOException; import java.text.DateFormatSymbols; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -532,9 +533,6 @@ } else { switch (currentStyle) { case "short": - pushStringListEntry(qName, attributes, - currentStyle+".CompactNumberPatterns"); - break; case "long": pushStringListEntry(qName, attributes, currentStyle+".CompactNumberPatterns"); @@ -545,46 +543,76 @@ } } break; + case "currencyFormat": + case "percentFormat": + pushKeyContainer(qName, attributes, attributes.getValue("type")); + break; + case "pattern": String containerName = currentContainer.getqName(); - if (containerName.equals("decimalFormat")) { - if (currentStyle == null) { - pushContainer(qName, attributes); - } else { - // The compact number patterns parsing assumes that the order - // of patterns are always in the increasing order of their - // type attribute i.e. type = 1000... - // Between the inflectional forms for a type (e.g. - // count = "one" and count = "other" for type = 1000), it is - // assumed that the count = "one" always appears before - // count = "other" - switch (currentStyle) { - case "short": - case "long": - String count = attributes.getValue("count"); - // first pattern of count = "one" or count = "other" - if ((count.equals("one") || count.equals("other")) - && compactCount.equals("")) { - compactCount = count; - pushStringListElement(qName, attributes, - (int) Math.log10(Double.parseDouble(attributes.getValue("type")))); - } else if ((count.equals("one") || count.equals("other")) - && compactCount.equals(count)) { - // extract patterns with similar "count" - // attribute value - pushStringListElement(qName, attributes, - (int) Math.log10(Double.parseDouble(attributes.getValue("type")))); - } else { - pushIgnoredContainer(qName); - } - break; - default: + switch (containerName) { + case "currencyFormat": + case "percentFormat": + { + // for FormatData + // copy string for later assembly into NumberPatterns + if (currentContainer instanceof KeyContainer) { + String fStyle = ((KeyContainer)currentContainer).getKey(); + if (fStyle.equals("standard")) { + pushStringEntry(qName, attributes, + currentNumberingSystem + "NumberPatterns/" + containerName.replaceFirst("Format", "")); + } else if (fStyle.equals("accounting") && containerName.equals("currencyFormat")) { + pushStringEntry(qName, attributes, + currentNumberingSystem + "NumberPatterns/accounting"); + } else { pushIgnoredContainer(qName); - break; + } + } else { + pushIgnoredContainer(qName); } } - } else { - pushContainer(qName, attributes); + break; + + case "decimalFormat": + if (currentStyle == null) { + pushContainer(qName, attributes); + } else { + // The compact number patterns parsing assumes that the order + // of patterns are always in the increasing order of their + // type attribute i.e. type = 1000... + // Between the inflectional forms for a type (e.g. + // count = "one" and count = "other" for type = 1000), it is + // assumed that the count = "one" always appears before + // count = "other" + switch (currentStyle) { + case "short": + case "long": + String count = attributes.getValue("count"); + // first pattern of count = "one" or count = "other" + if ((count.equals("one") || count.equals("other")) + && compactCount.equals("")) { + compactCount = count; + pushStringListElement(qName, attributes, + (int) Math.log10(Double.parseDouble(attributes.getValue("type")))); + } else if ((count.equals("one") || count.equals("other")) + && compactCount.equals(count)) { + // extract patterns with similar "count" + // attribute value + pushStringListElement(qName, attributes, + (int) Math.log10(Double.parseDouble(attributes.getValue("type")))); + } else { + pushIgnoredContainer(qName); + } + break; + default: + pushIgnoredContainer(qName); + break; + } + } + break; + default: + pushContainer(qName, attributes); + break; } break; case "currencyFormats": @@ -608,32 +636,6 @@ pushIgnoredContainer(qName); } break; - case "currencyFormat": - { - // for FormatData - // copy string for later assembly into NumberPatterns - String cfStyle = attributes.getValue("type"); - if (cfStyle.equals("standard")) { - pushStringEntry(qName, attributes, - currentNumberingSystem + "NumberPatterns/currency"); - } else if (cfStyle.equals("accounting")) { - pushStringEntry(qName, attributes, - currentNumberingSystem + "NumberPatterns/accounting"); - } else { - pushIgnoredContainer(qName); - } - } - break; - case "percentFormat": - // for FormatData - // copy string for later assembly into NumberPatterns - if (attributes.getValue("type").equals("standard")) { - pushStringEntry(qName, attributes, - currentNumberingSystem + "NumberPatterns/percent"); - } else { - pushIgnoredContainer(qName); - } - break; case "defaultNumberingSystem": // default numbering system if multiple numbering systems are used. pushStringEntry(qName, attributes, "DefaultNumberingSystem"); @@ -767,6 +769,8 @@ { if (id.equals("root") && !isIgnored(attributes) && ((currentContainer.getqName().equals("decimalFormatLength")) + || (currentContainer.getqName().equals("currencyFormat")) + || (currentContainer.getqName().equals("percentFormat")) || (currentCalendarType != null && !currentCalendarType.lname().startsWith("islamic-")))) { // ignore islamic variants pushAliasEntry(qName, attributes, attributes.getValue("path")); } else { @@ -922,6 +926,12 @@ case "decimalFormatLength": // used for compact number formatting patterns keyName = type + ".CompactNumberPatterns"; break; + case "currencyFormat": + case "percentFormat": + keyName = currentNumberingSystem + + "NumberPatterns/" + + (type.equals("standard") ? containerqName.replaceFirst("Format", "") : type); + break; default: keyName = ""; break; @@ -968,6 +978,22 @@ return toJDKKey(qName, "", style); } + // currencyFormat + typeKey = "currencyFormat[@type='"; + start = path.indexOf(typeKey); + if (start != -1) { + String style = path.substring(start + typeKey.length(), path.indexOf("']", start)); + return toJDKKey(qName, "", style); + } + + // percentFormat + typeKey = "percentFormat[@type='"; + start = path.indexOf(typeKey); + if (start != -1) { + String style = path.substring(start + typeKey.length(), path.indexOf("']", start)); + return toJDKKey(qName, "", style); + } + return calType + "." + toJDKKey(qName, context, width); } @@ -982,9 +1008,7 @@ case "defaultNumberingSystem": if (currentContainer instanceof StringEntry) { - defaultNumberingSystem = ((StringEntry) currentContainer).getValue(); - assert defaultNumberingSystem != null; - put(((StringEntry) currentContainer).getKey(), defaultNumberingSystem); + defaultNumberingSystem = (String) putIfEntry(); } else { defaultNumberingSystem = null; } @@ -1043,7 +1067,7 @@ currentContainer = currentContainer.getParent(); } - private void putIfEntry() { + private Object putIfEntry() { if (currentContainer instanceof AliasEntry) { Entry entry = (Entry) currentContainer; String containerqName = entry.getParent().getqName(); @@ -1051,6 +1075,13 @@ String srcKey = toJDKKey(containerqName, "", currentStyle); String targetKey = getTarget(entry.getKey(), "", "", ""); CLDRConverter.aliases.put(srcKey, targetKey); + } else if (containerqName.equals("currencyFormat") || + containerqName.equals("percentFormat")) { + KeyContainer kc = (KeyContainer)entry.getParent(); + CLDRConverter.aliases.put( + toJDKKey(containerqName, "", kc.getKey()), + getTarget(entry.getKey(), "", "", "") + ); } else { Set keyNames = populateAliasKeys(containerqName, currentContext, currentWidth); if (!keyNames.isEmpty()) { @@ -1081,9 +1112,10 @@ if (id.equals("root") && key.startsWith("MonthNames")) { value = new DateFormatSymbols(Locale.US).getShortMonths(); } - put(entry.getKey(), value); + return put(entry.getKey(), value); } } + return null; } public String convertOldKeyName(String key) {