1 /*
2 * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
86 case "localeKeyTypePattern":
87 pushStringEntry(qName, attributes,
88 CLDRConverter.LOCALE_KEYTYPE);
89 break;
90
91 case "language":
92 case "script":
93 case "territory":
94 case "variant":
95 // for LocaleNames
96 // copy string
97 pushStringEntry(qName, attributes,
98 CLDRConverter.LOCALE_NAME_PREFIX +
99 (qName.equals("variant") ? "%%" : "") +
100 attributes.getValue("type"));
101 break;
102
103 case "key":
104 // for LocaleNames
105 // copy string
106 pushStringEntry(qName, attributes,
107 CLDRConverter.LOCALE_KEY_PREFIX +
108 convertOldKeyName(attributes.getValue("type")));
109 break;
110
111 case "type":
112 // for LocaleNames/CalendarNames
113 // copy string
114 pushStringEntry(qName, attributes,
115 CLDRConverter.LOCALE_TYPE_PREFIX +
116 convertOldKeyName(attributes.getValue("key")) + "." +
117 attributes.getValue("type"));
118
119 break;
120
121 //
122 // Currency information
123 //
124 case "currency":
125 // for CurrencyNames
126 // stash away "type" value for nested <symbol>
127 pushKeyContainer(qName, attributes, attributes.getValue("type"));
128 break;
129 case "symbol":
130 // for CurrencyNames
131 // need to get the key from the containing <currency> element
132 pushStringEntry(qName, attributes, CLDRConverter.CURRENCY_SYMBOL_PREFIX
133 + getContainerKey());
134 break;
135
136 // Calendar or currency
137 case "displayName":
138 {
428 }
429 break;
430 case "quarter":
431 // for FormatData
432 // add to string array entry of quarterWidth element
433 pushStringArrayElement(qName, attributes, Integer.parseInt(attributes.getValue("type")) - 1);
434 break;
435
436 //
437 // Time zone names
438 //
439 case "timeZoneNames":
440 pushContainer(qName, attributes);
441 break;
442 case "hourFormat":
443 pushStringEntry(qName, attributes, "timezone.hourFormat");
444 break;
445 case "gmtFormat":
446 pushStringEntry(qName, attributes, "timezone.gmtFormat");
447 break;
448 case "zone":
449 {
450 String tzid = attributes.getValue("type"); // Olson tz id
451 zonePrefix = CLDRConverter.TIMEZONE_ID_PREFIX;
452 put(zonePrefix + tzid, new HashMap<String, String>());
453 pushKeyContainer(qName, attributes, tzid);
454 }
455 break;
456 case "metazone":
457 {
458 String zone = attributes.getValue("type"); // LDML meta zone id
459 zonePrefix = CLDRConverter.METAZONE_ID_PREFIX;
460 put(zonePrefix + zone, new HashMap<String, String>());
461 pushKeyContainer(qName, attributes, zone);
462 }
463 break;
464 case "long":
465 zoneNameStyle = "long";
466 pushContainer(qName, attributes);
467 break;
468 case "short":
469 zoneNameStyle = "short";
470 pushContainer(qName, attributes);
471 break;
472 case "generic": // generic name
473 case "standard": // standard time name
474 case "daylight": // daylight saving (summer) time name
475 pushStringEntry(qName, attributes, CLDRConverter.ZONE_NAME_PREFIX + qName + "." + zoneNameStyle);
476 break;
477 case "exemplarCity": // not used in JDK
478 pushIgnoredContainer(qName);
479 break;
480
481 //
482 // Number format information
483 //
484 case "decimalFormatLength":
485 if (attributes.getValue("type") == null) {
486 // skipping type="short" data
487 // for FormatData
488 // copy string for later assembly into NumberPatterns
489 pushStringEntry(qName, attributes, "NumberPatterns/decimal");
490 } else {
491 pushIgnoredContainer(qName);
492 }
493 break;
494 case "currencyFormatLength":
495 if (attributes.getValue("type") == null) {
496 // skipping type="short" data
497 // for FormatData
498 pushContainer(qName, attributes);
860 currentCalendarType = null;
861 break;
862
863 case "defaultNumberingSystem":
864 if (currentContainer instanceof StringEntry) {
865 defaultNumberingSystem = ((StringEntry) currentContainer).getValue();
866 assert defaultNumberingSystem != null;
867 put(((StringEntry) currentContainer).getKey(), defaultNumberingSystem);
868 } else {
869 defaultNumberingSystem = null;
870 }
871 break;
872
873 case "timeZoneNames":
874 zonePrefix = null;
875 break;
876
877 case "generic":
878 case "standard":
879 case "daylight":
880 if (zonePrefix != null && (currentContainer instanceof Entry)) {
881 @SuppressWarnings("unchecked")
882 Map<String, String> valmap = (Map<String, String>) get(zonePrefix + getContainerKey());
883 Entry<?> entry = (Entry<?>) currentContainer;
884 valmap.put(entry.getKey(), (String) entry.getValue());
885 }
886 break;
887
888 case "monthWidth":
889 case "dayWidth":
890 case "dayPeriodWidth":
891 case "quarterWidth":
892 currentWidth = "";
893 putIfEntry();
894 break;
895
896 case "monthContext":
897 case "dayContext":
898 case "dayPeriodContext":
899 case "quarterContext":
900 currentContext = "";
901 putIfEntry();
902 break;
903
904 default:
905 putIfEntry();
|
1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
86 case "localeKeyTypePattern":
87 pushStringEntry(qName, attributes,
88 CLDRConverter.LOCALE_KEYTYPE);
89 break;
90
91 case "language":
92 case "script":
93 case "territory":
94 case "variant":
95 // for LocaleNames
96 // copy string
97 pushStringEntry(qName, attributes,
98 CLDRConverter.LOCALE_NAME_PREFIX +
99 (qName.equals("variant") ? "%%" : "") +
100 attributes.getValue("type"));
101 break;
102
103 case "key":
104 // for LocaleNames
105 // copy string
106 {
107 String key = convertOldKeyName(attributes.getValue("type"));
108 if (key.length() == 2) {
109 pushStringEntry(qName, attributes,
110 CLDRConverter.LOCALE_KEY_PREFIX + key);
111 } else {
112 pushIgnoredContainer(qName);
113 }
114 }
115 break;
116
117 case "type":
118 // for LocaleNames/CalendarNames
119 // copy string
120 {
121 String key = convertOldKeyName(attributes.getValue("key"));
122 if (key.length() == 2) {
123 pushStringEntry(qName, attributes,
124 CLDRConverter.LOCALE_TYPE_PREFIX + key + "." +
125 attributes.getValue("type"));
126 } else {
127 pushIgnoredContainer(qName);
128 }
129 }
130 break;
131
132 //
133 // Currency information
134 //
135 case "currency":
136 // for CurrencyNames
137 // stash away "type" value for nested <symbol>
138 pushKeyContainer(qName, attributes, attributes.getValue("type"));
139 break;
140 case "symbol":
141 // for CurrencyNames
142 // need to get the key from the containing <currency> element
143 pushStringEntry(qName, attributes, CLDRConverter.CURRENCY_SYMBOL_PREFIX
144 + getContainerKey());
145 break;
146
147 // Calendar or currency
148 case "displayName":
149 {
439 }
440 break;
441 case "quarter":
442 // for FormatData
443 // add to string array entry of quarterWidth element
444 pushStringArrayElement(qName, attributes, Integer.parseInt(attributes.getValue("type")) - 1);
445 break;
446
447 //
448 // Time zone names
449 //
450 case "timeZoneNames":
451 pushContainer(qName, attributes);
452 break;
453 case "hourFormat":
454 pushStringEntry(qName, attributes, "timezone.hourFormat");
455 break;
456 case "gmtFormat":
457 pushStringEntry(qName, attributes, "timezone.gmtFormat");
458 break;
459 case "gmtZeroFormat":
460 pushStringEntry(qName, attributes, "timezone.gmtZeroFormat");
461 break;
462 case "regionFormat":
463 {
464 String type = attributes.getValue("type");
465 pushStringEntry(qName, attributes, "timezone.regionFormat" +
466 (type == null ? "" : "." + type));
467 }
468 break;
469 case "zone":
470 {
471 String tzid = attributes.getValue("type"); // Olson tz id
472 zonePrefix = CLDRConverter.TIMEZONE_ID_PREFIX;
473 put(zonePrefix + tzid, new HashMap<String, String>());
474 pushKeyContainer(qName, attributes, tzid);
475 }
476 break;
477 case "metazone":
478 {
479 String zone = attributes.getValue("type"); // LDML meta zone id
480 zonePrefix = CLDRConverter.METAZONE_ID_PREFIX;
481 put(zonePrefix + zone, new HashMap<String, String>());
482 pushKeyContainer(qName, attributes, zone);
483 }
484 break;
485 case "long":
486 zoneNameStyle = "long";
487 pushContainer(qName, attributes);
488 break;
489 case "short":
490 zoneNameStyle = "short";
491 pushContainer(qName, attributes);
492 break;
493 case "generic": // generic name
494 case "standard": // standard time name
495 case "daylight": // daylight saving (summer) time name
496 pushStringEntry(qName, attributes, CLDRConverter.ZONE_NAME_PREFIX + qName + "." + zoneNameStyle);
497 break;
498 case "exemplarCity":
499 pushStringEntry(qName, attributes, CLDRConverter.EXEMPLAR_CITY_PREFIX);
500 break;
501
502 //
503 // Number format information
504 //
505 case "decimalFormatLength":
506 if (attributes.getValue("type") == null) {
507 // skipping type="short" data
508 // for FormatData
509 // copy string for later assembly into NumberPatterns
510 pushStringEntry(qName, attributes, "NumberPatterns/decimal");
511 } else {
512 pushIgnoredContainer(qName);
513 }
514 break;
515 case "currencyFormatLength":
516 if (attributes.getValue("type") == null) {
517 // skipping type="short" data
518 // for FormatData
519 pushContainer(qName, attributes);
881 currentCalendarType = null;
882 break;
883
884 case "defaultNumberingSystem":
885 if (currentContainer instanceof StringEntry) {
886 defaultNumberingSystem = ((StringEntry) currentContainer).getValue();
887 assert defaultNumberingSystem != null;
888 put(((StringEntry) currentContainer).getKey(), defaultNumberingSystem);
889 } else {
890 defaultNumberingSystem = null;
891 }
892 break;
893
894 case "timeZoneNames":
895 zonePrefix = null;
896 break;
897
898 case "generic":
899 case "standard":
900 case "daylight":
901 case "exemplarCity":
902 if (zonePrefix != null && (currentContainer instanceof Entry)) {
903 @SuppressWarnings("unchecked")
904 Map<String, String> valmap = (Map<String, String>) get(zonePrefix + getContainerKey());
905 Entry<?> entry = (Entry<?>) currentContainer;
906 if (qName.equals("exemplarCity")) {
907 put(CLDRConverter.EXEMPLAR_CITY_PREFIX + getContainerKey(), (String) entry.getValue());
908 } else {
909 valmap.put(entry.getKey(), (String) entry.getValue());
910 }
911 }
912 break;
913
914 case "monthWidth":
915 case "dayWidth":
916 case "dayPeriodWidth":
917 case "quarterWidth":
918 currentWidth = "";
919 putIfEntry();
920 break;
921
922 case "monthContext":
923 case "dayContext":
924 case "dayPeriodContext":
925 case "quarterContext":
926 currentContext = "";
927 putIfEntry();
928 break;
929
930 default:
931 putIfEntry();
|