< prev index next >

make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java

Print this page
rev 47480 : [mq]: 8176841

@@ -74,16 +74,20 @@
         //
         case "identity":
             // ignore this element - it has language and territory elements that aren't locale data
             pushIgnoredContainer(qName);
             break;
-        case "type":
-            if ("calendar".equals(attributes.getValue("key"))) {
-                pushStringEntry(qName, attributes, CLDRConverter.CALENDAR_NAME_PREFIX + attributes.getValue("type"));
-            } else {
-                pushIgnoredContainer(qName);
-            }
+
+        // for LocaleNames
+        // copy string
+        case "localeSeparator":
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_SEPARATOR);
+            break;
+        case "localeKeyTypePattern":
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_KEYTYPE);
             break;
 
         case "language":
         case "script":
         case "territory":

@@ -94,10 +98,28 @@
                 CLDRConverter.LOCALE_NAME_PREFIX +
                 (qName.equals("variant") ? "%%" : "") +
                 attributes.getValue("type"));
             break;
 
+        case "key":
+            // for LocaleNames
+            // copy string
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_KEY_PREFIX +
+                convertOldKeyName(attributes.getValue("type")));
+            break;
+
+        case "type":
+            // for LocaleNames/CalendarNames
+            // copy string
+            pushStringEntry(qName, attributes,
+                CLDRConverter.LOCALE_TYPE_PREFIX +
+                convertOldKeyName(attributes.getValue("key")) + "." +
+                attributes.getValue("type"));
+
+            break;
+
         //
         // Currency information
         //
         case "currency":
             // for CurrencyNames

@@ -513,30 +535,14 @@
 
                 // Use keys as <script>."NumberElements/<symbol>"
                 currentNumberingSystem = script + ".";
                 String digits = CLDRConverter.handlerNumbering.get(script);
                 if (digits == null) {
-                    throw new InternalError("null digits for " + script);
-                }
-                if (Character.isSurrogate(digits.charAt(0))) {
-                    // DecimalFormatSymbols doesn't support supplementary characters as digit zero.
                     pushIgnoredContainer(qName);
                     break;
                 }
-                // in case digits are in the reversed order, reverse back the order.
-                if (digits.charAt(0) > digits.charAt(digits.length() - 1)) {
-                    StringBuilder sb = new StringBuilder(digits);
-                    digits = sb.reverse().toString();
-                }
-                // Check if the order is sequential.
-                char c0 = digits.charAt(0);
-                for (int i = 1; i < digits.length(); i++) {
-                    if (digits.charAt(i) != c0 + i) {
-                        pushIgnoredContainer(qName);
-                        break symbols;
-                    }
-                }
+
                 @SuppressWarnings("unchecked")
                 List<String> numberingScripts = (List<String>) get("numberingScripts");
                 if (numberingScripts == null) {
                     numberingScripts = new ArrayList<>();
                     put("numberingScripts", numberingScripts);

@@ -935,6 +941,25 @@
                     }
                     put(entry.getKey(), value);
                 }
             }
         }
+
+    public String convertOldKeyName(String key) {
+        // TODO: This should not be hard coded. Instead, obtained from "alias"
+        // attribute in each "key" element. 
+        switch (key) {
+            case "calendar":
+                return "ca";
+            case "currency":
+                return "cu";
+            case "collation":
+                return "co";
+            case "numbers":
+                return "nu";
+            case "timezone":
+                return "tz";
+            default:
+                return key;
+        }
     }
+}
< prev index next >