1
1
/*
2
- * Copyright (c) 2012, 2022 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2012, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
35
35
import java .util .List ;
36
36
import java .util .Locale ;
37
37
import java .util .Map ;
38
+ import java .util .Optional ;
38
39
import java .util .Set ;
39
40
import org .xml .sax .Attributes ;
40
41
import org .xml .sax .InputSource ;
@@ -812,6 +813,7 @@ public void startElement(String uri, String localName, String qName, Attributes
812
813
&& ((currentContainer .getqName ().equals ("decimalFormatLength" ))
813
814
|| (currentContainer .getqName ().equals ("currencyFormat" ))
814
815
|| (currentContainer .getqName ().equals ("percentFormat" ))
816
+ || (currentContainer .getqName ().equals ("listPattern" ))
815
817
|| (currentCalendarType != null && !currentCalendarType .lname ().startsWith ("islamic-" )))) { // ignore islamic variants
816
818
pushAliasEntry (qName , attributes , attributes .getValue ("path" ));
817
819
} else {
@@ -820,6 +822,28 @@ public void startElement(String uri, String localName, String qName, Attributes
820
822
}
821
823
break ;
822
824
825
+ // ListPatterns
826
+ case "listPattern" :
827
+ currentStyle = Optional .ofNullable (attributes .getValue ("type" )).orElse ("standard" );
828
+ pushStringArrayEntry (qName , attributes , "ListPatterns_" + currentStyle , 5 );
829
+ break ;
830
+ case "listPatternPart" :
831
+ type = attributes .getValue ("type" );
832
+ pushStringArrayElement (qName , attributes ,
833
+ switch (type ) {
834
+ case "start" -> 0 ;
835
+ case "middle" -> 1 ;
836
+ case "end" -> 2 ;
837
+ case "2" -> 3 ;
838
+ case "3" -> 4 ;
839
+ default -> throw new IllegalArgumentException (
840
+ """
841
+ The "type" attribute value for "listPatternPart" element is not recognized: %s
842
+ """ .formatted (type )
843
+ );
844
+ });
845
+ break ;
846
+
823
847
default :
824
848
// treat anything else as a container
825
849
pushContainer (qName , attributes );
@@ -973,6 +997,9 @@ private String toJDKKey(String containerqName, String context, String type) {
973
997
"NumberPatterns/" +
974
998
(type .equals ("standard" ) ? containerqName .replaceFirst ("Format" , "" ) : type );
975
999
break ;
1000
+ case "listPattern" :
1001
+ keyName = type ;
1002
+ break ;
976
1003
default :
977
1004
keyName = "" ;
978
1005
break ;
@@ -1035,6 +1062,19 @@ private String getTarget(String path, String calType, String context, String wid
1035
1062
return toJDKKey (qName , "" , style );
1036
1063
}
1037
1064
1065
+ // listPattern
1066
+ if (path .indexOf ("../listPattern" ) != -1 ) {
1067
+ typeKey = "[@type='" ;
1068
+ start = path .indexOf (typeKey );
1069
+ String style ;
1070
+ if (start != -1 ) {
1071
+ style = "ListPatterns_" + path .substring (start + typeKey .length (), path .indexOf ("']" , start ));
1072
+ } else {
1073
+ style = "ListPatterns_standard" ;
1074
+ }
1075
+ return toJDKKey (qName , "" , style );
1076
+ }
1077
+
1038
1078
return calType + "." + toJDKKey (qName , context , width );
1039
1079
}
1040
1080
@@ -1107,6 +1147,10 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
1107
1147
case "timeFormatLength" :
1108
1148
currentStyle = "" ;
1109
1149
break ;
1150
+ case "listPattern" :
1151
+ currentStyle = "" ;
1152
+ putIfEntry ();
1153
+ break ;
1110
1154
default :
1111
1155
putIfEntry ();
1112
1156
}
@@ -1128,6 +1172,12 @@ private Object putIfEntry() {
1128
1172
toJDKKey (containerqName , "" , kc .getKey ()),
1129
1173
getTarget (entry .getKey (), "" , "" , "" )
1130
1174
);
1175
+ } else if (containerqName .equals ("listPattern" )) {
1176
+ var sae = (StringArrayEntry )entry .getParent ();
1177
+ CLDRConverter .aliases .put (
1178
+ toJDKKey (containerqName , "" , sae .getKey ()),
1179
+ getTarget (entry .getKey (), "" , "" , "" )
1180
+ );
1131
1181
} else {
1132
1182
Set <String > keyNames = populateAliasKeys (containerqName , currentContext , currentWidth );
1133
1183
if (!keyNames .isEmpty ()) {
0 commit comments