Element.java
157 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa;
import com.adobe.xfa.*;
import com.adobe.xfa.data.DataModel;
import com.adobe.xfa.dom.DOM;
import com.adobe.xfa.dom.NamespaceContextImpl;
import com.adobe.xfa.service.canonicalize.Canonicalize;
import com.adobe.xfa.ut.*;
import com.adobe.xfa.ut.trace.Trace;
import com.adobe.xfa.ut.trace.TraceHandler;
import com.adobe.xfa.ut.trace.TraceTimer;
import org.w3c.dom.Attr;
import org.xml.sax.Attributes;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.*;
import java.util.*;
public class Element
extends Node {
protected static final int TEXT = 0;
protected static final int ATTRIBUTE = 1;
protected static final int ELEMENT = 2;
protected static final int ONEOF = 3;
protected static final int CHILD = 4;
protected static final int INVALID = 5;
public static final int AttrIsDefault = 1;
public static final int AttrIsFragment = 2;
public static final int AttrIsTransient = 4;
private static final GenericAttribute gsEmptyStringAttr = new GenericAttribute("", "");
public static final int CREATEACTION = 1;
private static final int APPENDACTION = 2;
static final Trace oScriptTrace = new Trace("script", ResId.ScriptTraceHelp);
protected String maName;
private byte[] mAttrProperties;
private Attribute[] mAttrs;
private int nAttrs;
private boolean mbInhibitPrettyPrint;
private boolean mbIsFragment;
private boolean mbIsHidden;
private boolean mbIsIndexed;
private boolean mbSaveXMLSaveTransient;
private boolean mbTransparent;
private EventManager.EventTable mEventTable;
protected Node mFirstXMLChild;
private String mLocalName;
private Model mModel;
private int mnLineNumber;
private NodeSchema mNodeSchema;
private String mQName;
private boolean mbIsDataWindowRoot;
protected String mURI;
private static XPathFactory mXPathFactory;
private static void removeNamespaceDef(Element element, String aPrefix) {
SaveNameSpaceChecker checker = element.getOwnerDocument().getSaveChecker();
if (checker != null) {
checker.removePrefix(element, aPrefix);
}
}
private static void addNamespaceDef(OutputStream outStream, DOMSaveOptions options, Element element, String aPrefix, String aNamespaceURI) {
String string = aNamespaceURI = aNamespaceURI == null ? "" : aNamespaceURI;
if (!Element.findNamespace(element, aPrefix, aNamespaceURI, options, true) && !Element.elementHasNamespacePrefixDeclared(element, aPrefix)) {
element.getOwnerDocument().getSaveChecker().addPrefix(element, aPrefix, aNamespaceURI);
try {
outStream.write(Document.MarkupSpace);
outStream.write(Document.MarkupXMLns);
if (aPrefix != "") {
outStream.write(Document.MarkupColon);
outStream.write(aPrefix.getBytes("UTF-8"));
}
outStream.write(Document.MarkupAttrMiddle);
outStream.write(aNamespaceURI.getBytes("UTF-8"));
outStream.write(Document.MarkupDQuoteString);
}
catch (IOException e) {
throw new ExFull(e);
}
}
}
private static boolean elementHasNamespacePrefixDeclared(Element element, String aPrefix) {
if (element == null) {
return false;
}
String aFixedPrefix = aPrefix;
if (aFixedPrefix == "") {
aFixedPrefix = "xmlns";
}
int nSize = element.getNumAttrs();
for (int nIndex = 0; nIndex < nSize; ++nIndex) {
Attribute oAttr = element.getAttr(nIndex);
if (!oAttr.isNameSpaceAttr() || oAttr.getLocalName() != aFixedPrefix) continue;
return true;
}
return false;
}
private static boolean findNamespace(Element element, String aPrefix, String aNamespaceURI, DOMSaveOptions options, boolean bSuppressEmptyNSCheck) {
SaveNameSpaceChecker checker;
Node stopNode;
if (aPrefix == "xml") {
return true;
}
if (aNamespaceURI == null) {
aNamespaceURI = "";
}
if ((checker = element.getOwnerDocument().getSaveChecker()) != null && checker.missingPrefix(element, aPrefix, aNamespaceURI, bSuppressEmptyNSCheck)) {
return true;
}
String aFixedPrefix = aPrefix == "" ? "xmlns" : aPrefix;
boolean bFindXsi = Element.isXsiNamespace(aNamespaceURI);
Node node = stopNode = checker != null ? checker.stopNode() : null;
while (element != null && element != stopNode) {
if (element instanceof Document) {
return false;
}
int nSize = element.getNumAttrs();
for (int nIndex = 0; nIndex < nSize; ++nIndex) {
Attribute attr = element.getAttr(nIndex);
if (!attr.isNameSpaceAttr() || attr.getLocalName() != aFixedPrefix) continue;
return bFindXsi ? Element.isXsiNamespace(attr.getAttrValue()) : aNamespaceURI == attr.getAttrValue();
}
element = Element.getXMLParent(element);
}
return false;
}
private static boolean isXsiNamespace(String aNamespaceURI) {
return aNamespaceURI == "http://www.w3.org/2001/XMLSchema-instance" || aNamespaceURI.startsWith("http://www.w3.org/") && aNamespaceURI.endsWith("/XMLSchema-instance");
}
static Element getXMLParent(Node node) {
if (node instanceof DualDomNode) {
node = ((DualDomNode)((Object)node)).getXmlPeer();
}
if (node == null) {
return null;
}
Element element = node.getXMLParent();
if (element instanceof DualDomNode) {
element = (Element)((DualDomNode)((Object)element)).getXmlPeer();
}
return element;
}
private static boolean displayNamespace(Attribute a, Element parent, DOMSaveOptions options, boolean bSuppressEmptyNSCheck) {
String aPrefix = a.getLocalName();
if (aPrefix == "xmlns") {
aPrefix = "";
}
if ((parent = Element.getXMLParent(parent)) == null) {
return true;
}
return !Element.findNamespace(parent, aPrefix, a.getAttrValue(), options, bSuppressEmptyNSCheck);
}
static boolean validateNodeSchema(Node node, NodeSchema nodeSchema, int nTargetVersion, int nTargetAvailability, List<NodeValidationInfo> validationInfos) {
int eTag = node.getClassTag();
ChildRelnInfo childRelnInfo = nodeSchema.getChildRelnInfo(eTag);
if (childRelnInfo != null) {
boolean bInvalid = false;
int nVerIntro = childRelnInfo.getVersionIntroduced();
int nAvail = childRelnInfo.getAvailability();
Model model = node.getModel();
if (model == null) {
model = node.getXFAParent().getModel();
}
assert (model != null);
if (!model.isVersionCompatible(nVerIntro, nTargetVersion)) {
bInvalid = true;
} else if ((nTargetAvailability & nAvail) == 0) {
bInvalid = true;
}
if (bInvalid) {
if (validationInfos != null) {
NodeValidationInfo nodeValidationInfo = new NodeValidationInfo(nVerIntro, nAvail, node);
validationInfos.add(nodeValidationInfo);
}
return false;
}
}
return true;
}
protected Element() {
super(null, null);
}
protected Element(Element parent, Node prevSibling) {
super(parent, prevSibling);
if (parent != null) {
this.setModel(parent.getModel());
this.setDocument(parent.getOwnerDocument());
}
}
protected Element(Element parent, Node prevSibling, String uri, String name) {
this(parent, prevSibling);
if (uri == null && parent != null) {
uri = parent.mURI;
}
String localName = null;
if (name != null) {
int nsSplit = (name = name.intern()).indexOf(58);
if (nsSplit < 0) {
localName = name;
} else {
localName = name.substring(nsSplit + 1);
localName = localName.intern();
}
}
uri = uri != null ? uri.intern() : null;
this.setClass(name, XFA.INVALID_ELEMENT);
this.mURI = uri;
this.mQName = name;
this.mLocalName = localName;
}
public Element(Element parent, Node prevSibling, String uri, String localName, String qName, Attributes attributes, int classTag, String className) {
this(parent, prevSibling);
if (uri == null && parent != null) {
uri = parent.mURI;
}
if (uri != null) {
uri = uri.intern();
}
this.mURI = uri;
this.mLocalName = localName;
this.mQName = qName;
this.setClass(className, classTag);
if (attributes != null) {
this.assignAttrs(attributes);
}
}
public void appendChild(Node child) {
Node lastChild;
if (child.getXMLParent() != null) {
child.remove();
}
Node currentChild = lastChild = this.getFirstXMLChild();
while (currentChild != null) {
if ((currentChild = currentChild.getNextXMLSibling()) == null) continue;
lastChild = currentChild;
}
if (lastChild == null) {
this.setFirstChild(child);
} else {
lastChild.setNextXMLSibling(child);
}
child.setXMLParent(this);
this.setChildListModified(true);
if (child instanceof Element) {
((Element)child).setNS(this.getNS());
if (child.getModel() != this.getModel() || child.getOwnerDocument() != this.getOwnerDocument()) {
this.updateModelAndDocument(child);
}
}
if (this instanceof DualDomNode && child instanceof DualDomNode) {
Element dualDomParent = (Element)((DualDomNode)((Object)this)).getXmlPeer();
Node domPeer = ((DualDomNode)((Object)child)).getXmlPeer();
if (domPeer.getModel() != this.getModel() || domPeer.getOwnerDocument() != this.getOwnerDocument()) {
this.updateModelAndDocument(domPeer);
}
if (domPeer instanceof DataModel.AttributeWrapper) {
DataModel.AttributeWrapper wrapper = (DataModel.AttributeWrapper)domPeer;
Attribute attr = dualDomParent.setAttribute(wrapper.getNS(), wrapper.getXMLName(), wrapper.getLocalName(), wrapper.getValue(), false);
DataModel.AttributeWrapper xmlPeer = new DataModel.AttributeWrapper(attr, dualDomParent);
xmlPeer.setXfaPeer((Element)child);
((DualDomNode)((Object)child)).setXmlPeer(xmlPeer);
} else {
dualDomParent.appendChild(domPeer);
}
}
if (child instanceof Element && this.getOwnerDocument() != null) {
this.getOwnerDocument().indexSubtree((Element)child, false);
}
this.setDirty();
if (!child.isMute()) {
child.notifyPeers(3, this.getClassAtom(), this);
}
if (!this.isMute()) {
this.notifyPeers(4, child.getClassAtom(), child);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void appendChild(Node child, boolean bValidate) {
if (bValidate) {
this.isValidChild(child.getClassTag(), ResId.InvalidChildAppendException, true, false);
}
if (child == this) {
throw new ExFull(new MsgFormat(ResId.HierarchyRequestException, child.getName()));
}
boolean bIsDefault = child.isDefault(false);
if (bIsDefault) {
this.mute();
}
try {
if (!child.isDefault(true)) {
this.makeNonDefault(false);
}
if (child.getXMLParent() != null) {
child.remove();
}
this.appendChild(child);
}
finally {
if (bIsDefault) {
this.unMute();
}
}
}
public final void appendPI(String aPiName, String sData) {
assert (aPiName != null);
new ProcessingInstruction(this, null, aPiName, sData);
this.setDirty();
}
public final void appendPI(String aPiName, String sPropName, String sData) {
assert (aPiName != null);
String sTemp = sPropName + " " + sData;
new ProcessingInstruction(this, null, aPiName, sTemp);
this.setDirty();
}
final void applyXSL(InputStream xsl, OutputStream out) {
ByteArrayOutputStream tempStream = new ByteArrayOutputStream();
this.saveXML(tempStream, null);
ByteArrayInputStream oMemStream = new ByteArrayInputStream(tempStream.toByteArray());
XSLTranslator translator = new XSLTranslator(xsl);
translator.process(oMemStream, out);
}
private final void assignAttrs(Attributes attributes) {
int newAttributeCount = attributes.getLength();
if (newAttributeCount == 0) {
return;
}
Model m = this.getModel();
NodeSchema schema = this.getNodeSchema();
this.ensureAttributeCapacity(this.nAttrs + newAttributeCount);
int namespaceDeclarationCount = this.nAttrs;
for (int i = 0; i < newAttributeCount; ++i) {
Attribute attribute = this.createAttribute(attributes.getLocalName(i), attributes.getURI(i), attributes.getQName(i), attributes.getValue(i), schema);
if (m != null) {
m.saveProtoInformation(this, attribute.getLocalName(), i == 0);
}
int position = this.nAttrs;
if (attribute.isNameSpaceAttr()) {
if (i != 0) {
System.arraycopy(this.mAttrs, namespaceDeclarationCount, this.mAttrs, namespaceDeclarationCount + 1, this.nAttrs - namespaceDeclarationCount);
System.arraycopy(this.mAttrProperties, namespaceDeclarationCount, this.mAttrProperties, namespaceDeclarationCount + 1, this.nAttrs - namespaceDeclarationCount);
position = namespaceDeclarationCount;
}
++namespaceDeclarationCount;
}
this.mAttrs[position] = attribute;
this.mAttrProperties[position] = 0;
++this.nAttrs;
}
}
@Override
public final Node assignNode(String sSOMExpression, String sValue, int eMode) {
Node node = null;
switch (eMode) {
case 0: {
SOMParser.SomResultInfo result = this.resolveNodeCreate(sSOMExpression, 1, true, false, false);
node = (Node)result.object;
if (node == null) {
throw new ExFull(new MsgFormat(ResId.HierarchyRequestException, sSOMExpression));
}
Arg arg = new Arg();
arg.setString(sValue);
if (!StringUtils.isEmpty(result.propertyName)) {
node.setScriptProperty(result.propertyName, arg, false);
break;
}
node.setScriptProperty("value", arg, false);
break;
}
case 3: {
SOMParser.SomResultInfo result = this.resolveNodeCreate(sSOMExpression, 2, true, false, false);
node = (Node)result.object;
if (node == null) {
throw new ExFull(new MsgFormat(ResId.HierarchyRequestException, sSOMExpression));
}
Arg arg = new Arg();
arg.setString(sValue);
if (!StringUtils.isEmpty(result.propertyName)) {
node.setScriptProperty(result.propertyName, arg, false);
break;
}
node.setScriptProperty("value", arg, false);
break;
}
case 1:
case 2: {
ArrayList<SOMParser.SomResultInfo> result = new ArrayList<SOMParser.SomResultInfo>();
SOMParser oParser = new SOMParser(null);
oParser.setOptions(true, true, false);
oParser.resolve(this, sSOMExpression, result);
if (result.size() != 0) {
if (eMode != 1) break;
throw new ExFull(new MsgFormat(ResId.NodeAlreadyExistException, sSOMExpression));
}
node = this.assignNode(sSOMExpression, sValue, 0);
}
}
this.setDirty();
return null;
}
protected void childRemoved(Node child) {
if (!child.isDefault(true)) {
this.makeNonDefault(false);
}
}
@Override
public Node clone(Element parent) {
return this.clone(parent, true);
}
public Element clone(Element parent, boolean deep) {
return this.cloneHelper(parent, deep, null, null);
}
private Element cloneHelper(Element parent, boolean deep, NodeList ancestors, NodeList leafs) {
Element newNode;
Node newPeer;
Element srcPeer /* !! */ ;
if (ancestors != null && leafs != null) {
boolean bContinue = false;
int nLeafs = leafs.length();
int i = 0;
for (i = 0; i < nLeafs; ++i) {
Element leaf = (Element)leafs.item(i);
if (this != leaf) continue;
leafs.remove(this);
return this.clone(parent, true);
}
int nAncestors = ancestors.length();
for (i = 0; i < nAncestors; ++i) {
Element poAncestors = (Element)ancestors.item(i);
if (this != poAncestors) continue;
ancestors.remove(this);
bContinue = true;
break;
}
if (!bContinue) {
return null;
}
}
if (this.getModel() == null || this.getClassTag() == XFA.INVALID_ELEMENT) {
assert (!(this instanceof DualDomNode));
srcPeer /* !! */ = this;
newNode = new Element(parent, null, this.getNS(), this.getLocalName(), this.getXMLName(), null, this.getClassTag(), this.getClassName());
this.copyContent(newNode, false);
newPeer = newNode;
} else {
Model newModel;
Model model = parent != null ? parent.getModel() : this.getModel();
newNode = this.getModel().getSchema().getInstance(this.getClassTag(), model, parent, null, true);
if (newNode instanceof Model && (newModel = (Model)newNode).getAppModel() == null) {
newModel.setAppModel(model.getAppModel());
}
if (this instanceof DualDomNode) {
newPeer = ((DualDomNode)((Object)newNode)).getXmlPeer();
if (newPeer != null) {
newPeer.remove();
}
srcPeer /* !! */ = ((DualDomNode)((Object)this)).getXmlPeer();
newPeer = Element.importDomNode(parent, this, false);
newPeer.setXfaPeer(newNode);
((DualDomNode)((Object)newNode)).setXmlPeer(newPeer);
} else {
newNode.setDOMProperties(this.mURI, this.getLocalName(), this.getXMLName(), null);
srcPeer /* !! */ = this;
this.copyContent(newNode, false);
newPeer = newNode;
}
}
if (deep) {
for (Node srcDomChild = srcPeer /* !! */ .getFirstXMLChild(); srcDomChild != null; srcDomChild = srcDomChild.getNextXMLSibling()) {
if (!(srcDomChild instanceof ProcessingInstruction) && !(srcDomChild instanceof Comment)) continue;
Node newDomChild = newNode.getOwnerDocument().importNode(srcDomChild, true);
((Element)newPeer).appendChild(newDomChild);
}
for (Node srcChild = this.getFirstXMLChild(); srcChild != null; srcChild = srcChild.getNextXMLSibling()) {
if (srcChild instanceof ProcessingInstruction || srcChild instanceof Comment) continue;
if (srcChild instanceof Element && ancestors != null && leafs != null) {
((Element)srcChild).cloneHelper(newNode, true, ancestors, leafs);
continue;
}
srcChild.clone(newNode);
}
}
if (this.getLocked()) {
newNode.setLocked(true);
}
return newNode;
}
protected static Node importDomNode(Element parent, Node node, boolean bXMLDeep) {
Node retDomNode;
Node domPeer = ((DualDomNode)((Object)node)).getXmlPeer();
if (parent != null) {
Element parentPeer = (Element)((DualDomNode)((Object)parent)).getXmlPeer();
if (domPeer instanceof DataModel.AttributeWrapper) {
DataModel.AttributeWrapper wrapper = (DataModel.AttributeWrapper)domPeer;
Attribute attr = parentPeer.setAttribute(wrapper.getNS(), wrapper.getLocalName(), wrapper.getXMLName(), wrapper.getValue(), false);
retDomNode = new DataModel.AttributeWrapper(attr, parentPeer);
} else {
retDomNode = parentPeer.getOwnerDocument().importNode(domPeer, bXMLDeep);
parentPeer.appendChild(retDomNode);
}
} else if (domPeer instanceof DataModel.AttributeWrapper) {
DataModel.AttributeWrapper wrapper = (DataModel.AttributeWrapper)domPeer;
StringAttr attr = new StringAttr(wrapper.getNS(), wrapper.getLocalName(), wrapper.getXMLName(), wrapper.getValue(), false);
retDomNode = new DataModel.AttributeWrapper(attr, null);
} else {
retDomNode = domPeer.getOwnerDocument().importNode(domPeer, bXMLDeep);
}
return retDomNode;
}
public void copyContent(Element newNode, boolean deep) {
Node child;
newNode.isFragment(this.isFragment(), false);
if (this.nAttrs != 0) {
newNode.nAttrs = this.nAttrs;
newNode.mAttrs = (Attribute[])this.mAttrs.clone();
newNode.mAttrProperties = (byte[])this.mAttrProperties.clone();
int nAttrs = this.getNumAttrs();
int i = 0;
while (i < nAttrs) {
byte[] arrby = newNode.mAttrProperties;
int n = i++;
arrby[n] = (byte)(arrby[n] & 2);
}
}
if (deep && child != null) {
for (child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
if (child instanceof Element) {
((Element)child).clone(newNode, true);
continue;
}
child.clone(newNode);
}
}
newNode.maName = this.maName;
if (this.getLocked()) {
newNode.setLocked(true);
}
}
private final Attribute createAttribute(String localName, String NS, String qName, String value, NodeSchema schema) {
AttributeInfo info;
int eTag = XFA.INVALID_ELEMENT;
boolean bXFAAttr = localName == qName;
Model m = this.getModel();
if (!bXFAAttr) {
if (m != null && m.isCompatibleNS(NS)) {
bXFAAttr = true;
}
if (localName.equals("rid")) {
bXFAAttr = true;
}
}
Attribute defaultAttribute = null;
boolean bValidAttr = true;
if (bXFAAttr && (eTag = XFA.getAttributeTag(localName)) != XFA.INVALID_ELEMENT && (info = schema.getAttributeInfo(eTag)) != null) {
defaultAttribute = info.getDefault();
bValidAttr = this.isValidAttr(eTag, true, null);
}
if (defaultAttribute == null) {
defaultAttribute = gsEmptyStringAttr;
}
value = this.internAttributeValue(defaultAttribute, value);
Attribute a = null;
try {
a = defaultAttribute.newAttribute(NS, localName, qName, value, false);
}
catch (ExFull ex) {
if (ex.hasResId(ResId.InvalidPropertyValueException) || ex.hasResId(ResId.InvalidEnumeratedValue)) {
m.addXMLLoadErrorContext(this.getLineNumber(), this.getOwnerDocument().getParseFileName(), ex);
m.addErrorList(ex, 3, this);
a = defaultAttribute;
}
a = gsEmptyStringAttr.newAttribute(NS, localName, qName, value, false);
}
if (bXFAAttr && a.getLocalName() == "name") {
this.maName = a.getAttrValue();
}
if (eTag != XFA.INVALID_ELEMENT && bValidAttr) {
return a;
}
if (eTag == XFA.INVALID_ELEMENT) {
if (qName == "xmlns" || qName.startsWith("xmlns:")) {
return a;
}
if (qName == "urn:oasis:names:tc:xliff:document:1.1" || qName.startsWith("xliff:")) {
return a;
}
}
if (!(!bXFAAttr || this.getClassTag() == XFA.INVALID_ELEMENT || m == null || bValidAttr && this.isValidAttr(eTag, false, null))) {
String sLine = Integer.toString(this.getLineNumber());
MsgFormatPos message = new MsgFormatPos(ResId.InvalidAttributeLoadException);
message.format(localName);
message.format(this.getLocalName());
message.format(sLine);
m.addErrorList(new ExFull(message), 3, this);
}
return a;
}
private String internAttributeValue(Attribute defaultAttribute, String value) {
int maxLengthToIntern = 9;
if (value.length() <= 9 || defaultAttribute instanceof EnumValue) {
Model m = this.getModel();
value = m != null ? m.intern(value) : value.intern();
}
return value;
}
public Attribute defaultAttribute(int eTag) {
int thisTag = this.getElementClass();
if (thisTag == XFA.INVALID_ELEMENT || thisTag == XFA.DSIGDATATAG) {
return gsEmptyStringAttr;
}
return this.getModel().getSchema().defaultAttribute(eTag, thisTag);
}
public int defaultElement() {
if (this.isValidElement(XFA.TEXTNODETAG, false)) {
return XFA.TEXTNODETAG;
}
return XFA.SCHEMA_DEFAULTTAG;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public Node defaultElement(int eTag, int nOccurrence) {
boolean previousWillDirty = this.getWillDirty();
this.setWillDirty(false);
try {
Node ret = this.defaultElementImpl(eTag, nOccurrence, true);
if (ret != null) {
if (this.isTransient()) {
ret.isTransient(true, true);
} else if (ret.isTransient()) {
ret.isTransient(false, false);
}
if (this.isFragment()) {
if (ret instanceof Element) {
((Element)ret).isFragment(true, true);
} else if (ret instanceof TextNode) {
((TextNode)ret).isFragment(true);
}
}
ret.makeDefault();
}
Node node = ret;
return node;
}
finally {
this.setWillDirty(previousWillDirty);
}
}
Node createDefaultElement(int eTag, int nOccurrence) {
Node ret = this.defaultElementImpl(eTag, nOccurrence, false);
ret.makeDefault();
return ret;
}
protected Node defaultElementImpl(int eTag, int nOccurrence, boolean bAppend) {
if (eTag == XFA.SCHEMA_DEFAULTTAG) {
eTag = this.defaultElement();
}
if (eTag == XFA.SCHEMA_DEFAULTTAG) {
return null;
}
Element parent = bAppend ? this : null;
Node node = eTag == XFA.TEXTNODETAG ? this.getModel().createTextNode(parent, null, "") : this.getModel().createNode(eTag, parent, "", this.mURI, false);
node.isTransient(true, false);
return node;
}
public final String establishID() {
String aID;
String sID = this.getID();
if (!StringUtils.isEmpty(sID)) {
return sID;
}
sID = this.getName();
if (StringUtils.isEmpty(sID)) {
sID = this.getClassAtom();
}
sID = sID + "_ID";
Document doc = this.getOwnerDocument();
if (doc.idValueInUse(aID = sID)) {
sID = UuidFactory.getUuid();
}
this.setID(sID);
return sID;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public final Arg evaluate(String sEvalText, String sEvalTypeText, int executeReason, boolean bReportNonFatalErrors) {
Arg returnCode;
boolean bTrace = oScriptTrace.isEnabled(2);
returnCode = new Arg();
if (StringUtils.isEmpty(sEvalTypeText)) {
sEvalTypeText = "formcalc";
} else if (sEvalTypeText.startsWith("application/x-")) {
sEvalTypeText = sEvalTypeText.substring("application/x-".length());
}
Model model = this.getModel();
ScriptHandler handler = model.getScriptHandler(sEvalTypeText);
if (handler == null) {
MsgFormatPos msg = new MsgFormatPos(ResId.UnknownScriptLanguageException);
msg.format(sEvalTypeText);
msg.format(this.getSOMExpression());
ExFull err = new ExFull(msg);
this.getModel().addErrorList(err, 3, this);
} else {
AppModel appModel = this.getAppModel();
Node prevContext = appModel.getContext();
try {
appModel.setContext(this);
String sLocale = this.getInstalledLocale();
long before = 0;
if (bTrace || TraceHandler.scriptLoggingEnabled()) {
MsgFormatPos msg = new MsgFormatPos(ResId.ScriptTraceExecute);
msg.format(sEvalTypeText);
msg.format(sEvalText);
msg.format(this.getSOMExpression());
msg.format(ScriptHandler.executeReasonToString(executeReason));
TraceHandler.reportScriptInfo(msg.toString());
if (bTrace) {
oScriptTrace.trace(2, msg);
}
before = System.currentTimeMillis();
}
TraceTimer scriptOnlyTimer = new TraceTimer(TraceHandler.TimingType.XFA_SCRIPTS_ONLY_TIMING);
try {
handler.execute(sEvalText, sLocale, returnCode, executeReason);
}
finally {
scriptOnlyTimer.stopTiming();
}
if ((bTrace || TraceHandler.scriptLoggingEnabled()) && before != 0) {
long after = System.currentTimeMillis();
MsgFormatPos msg1 = new MsgFormatPos(ResId.ScriptTraceReturnValue);
msg1.format(returnCode.getAsString(false));
String sMSecs = Long.toString(after - before);
MsgFormatPos msg2 = new MsgFormatPos(ResId.ScriptTraceTime);
msg2.format(sMSecs);
TraceHandler.reportScriptInfo(msg1.toString());
TraceHandler.reportScriptInfo(msg2.toString());
TraceHandler.reportScriptInfo("\n");
if (bTrace) {
oScriptTrace.trace(2, msg1);
oScriptTrace.trace(2, msg2);
}
}
}
catch (ExFull ex) {
if (ex.getResId(0) == ResId.SOFTWARE_FAILURE) {
throw ex;
}
if (bReportNonFatalErrors || handler.wasFatalError()) {
MsgFormatPos msg = new MsgFormatPos(ResId.ScriptFailure);
msg.format(sEvalTypeText);
msg.format(this.getSOMExpression());
msg.format(sEvalText);
ExFull err = new ExFull(msg);
err.insert(ex, true);
model.addErrorList(err, 3, this);
}
returnCode.setException(ex);
}
catch (OutOfMemoryError ex) {
MsgFormatPos msg = new MsgFormatPos(ResId.ScriptFailure);
msg.format(sEvalTypeText);
msg.format(this.getSOMExpression());
msg.format(sEvalText);
msg.format(ex.toString());
ExFull err = new ExFull(msg);
throw err;
}
finally {
appModel.setContext(prevContext);
}
}
return returnCode;
}
private void extendAttributes(Attribute newAttr) {
this.ensureAttributeCapacity(this.nAttrs + 1);
this.mAttrs[this.nAttrs] = newAttr;
++this.nAttrs;
Element e = this.getXmlPeerElement();
if (this.getOwnerDocument() != null && this.getOwnerDocument().isId(e.getNSInternal(), e.getLocalName(), newAttr.getNS(), newAttr.getLocalName())) {
if (this.getOwnerDocument().idValueInUse(newAttr.getAttrValue())) {
throw new ExFull(ResId.DOM_DUPLICATE_ID_ERR);
}
this.getOwnerDocument().indexNode(this, false);
}
}
private void ensureAttributeCapacity(int capacity) {
if (capacity == 0) {
return;
}
if (this.mAttrs != null) {
if (capacity <= this.mAttrs.length) {
return;
}
capacity = capacity * 3 / 2 + 1;
}
Attribute[] replacementAttrs = new Attribute[capacity];
byte[] replacementProperties = new byte[capacity];
if (this.mAttrs != null && this.nAttrs > 0) {
System.arraycopy(this.mAttrs, 0, replacementAttrs, 0, this.nAttrs);
System.arraycopy(this.mAttrProperties, 0, replacementProperties, 0, this.nAttrs);
}
this.mAttrs = replacementAttrs;
this.mAttrProperties = replacementProperties;
}
public final int findAttr(String URI2, String name) {
int nAttrs = this.getNumAttrs();
for (int i = 0; i < nAttrs; ++i) {
boolean nsMatch;
Attribute attribute = this.getAttr(i);
if (URI2 == null) {
nsMatch = true;
} else {
String attributeNS = attribute.getNS();
if (URI2 == "") {
nsMatch = StringUtils.isEmpty(attributeNS);
} else {
boolean bl = nsMatch = attributeNS == URI2;
}
}
if (!nsMatch || name != attribute.getName() && name != attribute.getQName()) continue;
return i;
}
return -1;
}
protected final ProtoableNode findExternalProto(int eClassTag, int eAltClassTag, String urlRef, boolean bPeek) {
assert (this instanceof ProtoableNode);
if (StringUtils.isEmpty(urlRef)) {
return null;
}
AppModel appModel = this.getAppModel();
HrefHandler hrefHandler = appModel.getHrefHandler();
if (hrefHandler == null) {
return null;
}
Node target = null;
try {
AppModel fragAppModel = hrefHandler.loadFragment((ProtoableNode)this);
String sFragId = null;
int nSharp = urlRef.indexOf(35);
sFragId = nSharp >= 0 ? urlRef.substring(nSharp + 1) : "som($template.#subform.#subform)";
if (!sFragId.toLowerCase().startsWith("som")) {
Model doc = hrefHandler.getDocument(fragAppModel);
Element element = doc.getNode(sFragId);
if (element == null) {
return null;
}
target = element;
} else {
NodeList list;
int nParen = sFragId.indexOf(40);
if (nParen >= 0) {
sFragId = sFragId.substring(nParen + 1, sFragId.length() - 1);
}
if (!sFragId.startsWith("$")) {
sFragId = "$template.#subform.." + sFragId;
}
if ((list = fragAppModel.resolveNodes(sFragId, bPeek, false, false)) == null) {
return null;
}
if (list.length() != 1) {
return null;
}
target = (Node)list.item(0);
}
List<ExFull> errs = fragAppModel.getErrorList();
List<Element> contextErrs = fragAppModel.getErrorContextList();
if (errs.size() > 0) {
boolean bFatal = false;
for (int i = 0; i < errs.size(); ++i) {
this.getModel().addErrorList(errs.get(i), 0, contextErrs.get(i));
if (!errs.get(i).hasResId(ResId.CircularProtoException)) continue;
bFatal = true;
}
fragAppModel.clearErrorList();
if (bFatal) {
if (target instanceof ProtoableNode) {
ProtoableNode.releaseExternalProtos((ProtoableNode)target);
}
return null;
}
}
}
catch (ExFull ex) {
this.getModel().addErrorList(ex, 0, this);
}
if (target instanceof ProtoableNode) {
for (Element parentCheck = this.getXFAParent(); parentCheck != null; parentCheck = parentCheck.getXFAParent()) {
if (parentCheck != target) continue;
MsgFormatPos message = new MsgFormatPos(ResId.CircularProtoException, this.getSOMExpression());
throw new ExFull(message);
}
ProtoableNode protoableNode = (ProtoableNode)target;
if (protoableNode.isSameClass(eClassTag) || protoableNode.isSameClass(eAltClassTag)) {
return protoableNode;
}
}
return null;
}
protected final ProtoableNode findInternalProto(int eClassTag, int eAltClassTag, Node contextNode, String sReference, boolean bPeek) {
Node target = null;
if (StringUtils.isEmpty(sReference)) {
return null;
}
if (sReference.startsWith("#")) {
Element e;
String protoID = sReference.substring(1);
List<ProtoableNode> protos = this.getModel().getProtoList();
for (int i = 0; protos != null && i < protos.size(); ++i) {
ProtoableNode node = protos.get(i);
if (!node.getID().equals(protoID)) continue;
target = node;
break;
}
if (target == null && (e = this.getModel().getNode(protoID)) != null) {
target = e;
}
} else {
String sSOMExpression = sReference;
if (sSOMExpression.startsWith("som(") && sSOMExpression.endsWith(")")) {
sSOMExpression = sSOMExpression.substring(4, sSOMExpression.length() - 1);
}
target = contextNode.resolveNode(sSOMExpression, bPeek, false, false);
}
if (target instanceof ProtoableNode) {
for (Element parentCheck = this.getXFAParent(); parentCheck != null; parentCheck = parentCheck.getXFAParent()) {
if (parentCheck != target) continue;
MsgFormatPos message = new MsgFormatPos(ResId.CircularProtoException, this.getSOMExpression());
throw new ExFull(message);
}
ProtoableNode protoableNode = (ProtoableNode)target;
if (protoableNode.isSameClass(eClassTag) || protoableNode.isSameClass(eAltClassTag)) {
return protoableNode;
}
}
return null;
}
public final int findSchemaAttr(String name) {
int nAttrs = this.getNumAttrs();
for (int i = 0; i < nAttrs; ++i) {
Attribute attribute = this.getAttr(i);
if (name != attribute.getName() || !attribute.isSchemaAttr()) continue;
return i;
}
return -1;
}
final void forceID(String sID) {
Attribute idAttr = this.getAttribute(XFA.IDTAG, true, false);
if (idAttr != null) {
this.removeAttr(null, "id");
}
if (sID.length() > 0) {
this.setID(sID);
}
}
public final void foundBadAttribute(int eTag, String attrValue) {
String attrName = this.getAtom(eTag);
MsgFormatPos warning = new MsgFormatPos(ResId.FoundBadAttributeException);
warning.format(attrValue);
warning.format(attrName);
warning.format(this.getClassAtom());
warning.format(this.getName());
this.getModel().addErrorList(new ExFull(warning), 3, this);
}
public final void foundBadAttribute(String attrName, String attrValue) {
MsgFormatPos warning = new MsgFormatPos(ResId.FoundBadAttributeException);
warning.format(attrValue);
warning.format(attrName);
warning.format(this.getClassAtom());
warning.format(this.getName());
this.getModel().addErrorList(new ExFull(warning), 3, this);
}
@Override
public final NodeList getAll(boolean bByName) {
if (bByName && this.getName() == "") {
MsgFormatPos message = new MsgFormatPos(ResId.NoNameException);
message.format("index").format("classIndex");
throw new ExFull(message);
}
Element parent = this.getXFAParent();
if (parent != null) {
int eType = parent.getSchemaType(this.getClassTag());
if (eType == 0 || eType == 2) {
ArrayNodeList retList = new ArrayNodeList();
for (Node child = parent.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!this.isSameClass(child.getClassTag())) continue;
retList.append(child);
}
return retList;
}
if (eType == 3) {
ArrayNodeList retList = new ArrayNodeList();
retList.append(this);
return retList;
}
}
return super.getAll(bByName);
}
public AppModel getAppModel() {
Model model = this.getModel();
assert (model != null);
return model.getAppModel();
}
public String getAtom(int eTag) {
if (this.mModel == null) {
return XFA.getAtom(eTag);
}
return this.mModel.getSchema().getAtom(eTag);
}
public final Attribute getAttr(int n) {
return this.getXmlPeerElement().mAttrs[n];
}
public Attribute getAttribute(int eAttributeTag) {
return this.getAttribute(eAttributeTag, false, false);
}
public Attribute getAttribute(int eTag, boolean bPeek, boolean bValidate) {
String aPropertyName = this.getAtom(eTag);
int attr = this.findSchemaAttr(aPropertyName);
if (attr != -1) {
return this.getAttr(attr);
}
Attribute defaultAttribute = null;
boolean bNoSchema = false;
if (this.getElementClass() == XFA.INVALID_ELEMENT || this.getElementClass() == XFA.DSIGDATATAG) {
bNoSchema = true;
} else {
AttributeInfo info = this.getNodeSchema().getAttributeInfo(eTag);
if (info != null) {
defaultAttribute = info.getDefault();
}
}
if (defaultAttribute == null && !bNoSchema) {
if (bValidate) {
MsgFormatPos message = new MsgFormatPos(ResId.InvalidGetPropertyException);
message.format(this.getClassAtom());
message.format(aPropertyName);
throw new ExFull(message);
}
return null;
}
if (bPeek) {
return null;
}
if (bNoSchema) {
return gsEmptyStringAttr;
}
return defaultAttribute;
}
public Attribute getAttributeByName(String aAttrName, boolean bSearchProto) {
Attribute attr = null;
if (aAttrName != null) {
int n = this.getNumAttrs();
for (int i = 0; i < n; ++i) {
if (!this.getAttrName(i).equals(aAttrName)) continue;
attr = this.getAttr(i);
break;
}
}
return attr;
}
public final int getAttrIndex(Attribute attr) {
int n = this.getNumAttrs();
for (int i = 0; i < n; ++i) {
if (this.getAttr(i) != attr) continue;
return i;
}
assert (false);
return -1;
}
public final String getAttrName(int index) {
Attribute attribute = this.getAttr(index);
String name = attribute.getName();
if (StringUtils.isEmpty(name)) {
name = attribute.getQName();
}
return name;
}
public final String getAttrNS(int index) {
return this.getAttr(index).getNS();
}
public final boolean getAttrProp(int attrIndex, int eProp) {
return (this.getXmlPeerElement().mAttrProperties[attrIndex] & eProp) != 0;
}
public final String getAttrQName(int index) {
return this.getAttr(index).getQName();
}
public final String getAttrVal(int index) {
return this.getAttr(index).getAttrValue();
}
public final Node getXMLChild(int n) {
Node child = this.getFirstXMLChild();
for (int i = 0; i < n; ++i) {
child = child.getNextXMLSibling();
}
return child;
}
public final Node getXFAChild(int n) {
Node child = this.getFirstXFAChild();
for (int i = 0; i < n; ++i) {
child = child.getNextXFASibling();
}
return child;
}
public final ChildReln getChildReln(int eTag) {
ChildRelnInfo info = this.getNodeSchema().getChildRelnInfo(eTag);
if (info != null) {
return info.getRelationship();
}
return null;
}
public final NodeList getClassAll() {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "Element#getClassAll");
}
public final int getClassIndex() {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "Element#getClassIndex");
}
@Override
public final String getClassName() {
String name = super.getClassAtom();
if (name == null) {
return this.mLocalName;
}
return name;
}
int getDefaultOneOfTag() {
int eOneOfChild = XFA.SCHEMA_DEFAULTTAG;
NodeSchema nodeSchema = this.getNodeSchema();
SchemaPairs children = nodeSchema.getValidChildren();
if (children != null) {
int eOneOfChildDefault = this.defaultElement();
boolean bFound = false;
for (int i = 0; i < children.size(); ++i) {
ChildReln reln = (ChildReln)children.value(i);
int eTag = children.key(i);
if (reln.getOccurrence() != 4) continue;
if (eOneOfChildDefault == eTag) {
bFound = true;
eOneOfChild = eTag;
break;
}
if (bFound) continue;
bFound = true;
eOneOfChild = eTag;
}
if (!bFound) {
eOneOfChild = eOneOfChildDefault;
}
}
return eOneOfChild;
}
public void getDeltas(Element delta, XFAList list) {
if (delta != null && this.isSameClass(delta) && this.getName() == delta.getName()) {
SchemaPairs attrs = this.getNodeSchema().getValidAttributes();
if (attrs != null) {
Attribute localeDelta = null;
if (list != null) {
for (int i = 0; i < attrs.size(); ++i) {
int eTag = attrs.key(i);
if (eTag == XFA.NAMETAG) continue;
Attribute deltaAttr = delta.getAttribute(eTag, true, false);
if (eTag == XFA.LOCALETAG) {
localeDelta = deltaAttr;
continue;
}
if (deltaAttr == null) continue;
Attribute attr = this.getAttribute(eTag, false, false);
Delta newDelta = new Delta(this, delta, attr, deltaAttr, XFA.getString(eTag));
list.append(newDelta);
}
} else {
localeDelta = delta.getAttribute(XFA.LOCALETAG, true, false);
}
if (localeDelta != null) {
this.setAttribute(localeDelta, XFA.LOCALETAG);
}
}
ElementNodeList children = new ElementNodeList(this);
ElementNodeList deltaChildren = new ElementNodeList(delta);
for (Node deltaChild = delta.getFirstXFAChild(); deltaChild != null; deltaChild = deltaChild.getNextXFASibling()) {
Node targetChild = null;
boolean bIsContainerChild = deltaChild.isContainer();
int eClassTag = deltaChild.getClassTag();
ChildReln childReln = this.getChildReln(eClassTag);
if (childReln != null) {
Integer nOccurrence;
if (childReln.getOccurrence() == 4) {
targetChild = this.getOneOfChild(false, false);
if (targetChild == null || !targetChild.isSameClass(eClassTag)) {
if (list != null) {
Delta newDelta = new Delta(this, delta, targetChild, deltaChild, "");
list.append(newDelta);
}
targetChild = null;
}
} else if (childReln.getMax() != -1) {
if (eClassTag == XFA.TEXTNODETAG) {
targetChild = this.getText(false, false, false);
} else {
nOccurrence = deltaChildren.getOccurrence(deltaChild);
if (nOccurrence != null) {
targetChild = this.getElement(eClassTag, false, nOccurrence, false, false);
}
}
} else {
nOccurrence = deltaChildren.getOccurrence(deltaChild);
if (nOccurrence != null) {
targetChild = children.getNamedItem(deltaChild.getName(), deltaChild.getClassAtom(), nOccurrence);
}
if (list != null && targetChild == null && !bIsContainerChild) {
targetChild = null;
Delta newDelta = new Delta(this, delta, targetChild, deltaChild, "");
list.append(newDelta);
}
}
}
if (targetChild == null) continue;
if (targetChild instanceof TextNode) {
((TextNode)targetChild).getDeltas((TextNode)deltaChild, list);
continue;
}
if (!(targetChild instanceof Element) || !(deltaChild instanceof Element)) continue;
((Element)targetChild).getDeltas((Element)deltaChild, list);
}
}
}
private Element getXmlPeerElement() {
return this instanceof DualDomNode ? (Element)((DualDomNode)((Object)this)).getXmlPeer() : this;
}
/*
* Enabled force condition propagation
* Lifted jumps to return sites
*/
@Override
protected ScriptDynamicPropObj getDynamicScriptProp(String sPropertyName, boolean bPropertyOverride, boolean bPeek) {
ScriptDynamicPropObj desc;
if (StringUtils.isEmpty(sPropertyName)) {
return null;
}
int nAvail = 63;
int nVersion = 10;
int eType = 5;
int eTag = XFA.getTag(sPropertyName);
if (eTag != XFA.INVALID_ELEMENT) {
AttributeInfo attrInfo = this.getNodeSchema().getAttributeInfo(eTag);
if (attrInfo != null) {
nAvail = attrInfo.getAvailability();
nVersion = attrInfo.getVersionIntroduced();
eType = 1;
} else {
ChildRelnInfo childInfo = this.getNodeSchema().getChildRelnInfo(eTag);
if (childInfo != null) {
nAvail = childInfo.getAvailability();
nVersion = childInfo.getVersionIntroduced();
ChildReln reln = childInfo.getRelationship();
if (reln != null) {
eType = reln.getMax() == -1 ? 4 : (reln.getOccurrence() == 4 ? 3 : 2);
}
}
}
}
if ((desc = super.getDynamicScriptProp(sPropertyName, bPropertyOverride, bPeek, nVersion, nAvail)) != null) {
return desc;
}
if (bPeek && !this.isPropertySpecified(eTag, true, 0)) {
return null;
}
String sGetFunc = bPeek ? "locatePropPeek" : "locateProp";
return new ElementScriptDynamicPropObj(sGetFunc, eType == 1 ? "setProp" : null, nVersion, nAvail);
}
public Element getElement(int eTag, boolean bPeek, int nOccurrence, boolean bReturnDefault, boolean bValidate) {
return this.getElementLocal(eTag, bPeek, nOccurrence, bReturnDefault, bValidate);
}
public final Element getElement(int eElementTag, int nOccurrence) {
return this.getElement(eElementTag, false, nOccurrence, false, false);
}
public final Node getNode(int eTag, int nOccurrence) {
Node child = this.locateChildByClass(eTag, nOccurrence);
if (child != null) {
return child;
}
if (eTag == XFA.TEXTNODETAG) {
return this.getText(true, false, false);
}
return this.getElement(eTag, true, nOccurrence, false, false);
}
public final Element getElementLocal(int eTag, boolean bPeek, int nOccurrence, boolean bReturnDefault, boolean bValidate) {
Node child;
if (bValidate) {
ChildReln validChild = this.getChildReln(eTag);
if (validChild == null || validChild.getOccurrence() == 4 || validChild.getMax() == -1) {
String aPropertyName = this.getAtom(eTag);
MsgFormatPos message = new MsgFormatPos(ResId.InvalidGetPropertyException);
message.format(this.getClassAtom());
message.format(aPropertyName);
throw new ExFull(message);
}
if (validChild != null && validChild.getMax() <= nOccurrence) {
throw new ExFull(new IndexOutOfBoundsException(""));
}
} else assert (this.getModel() != null);
if ((child = this.locateChildByClass(eTag, nOccurrence)) instanceof Element) {
return (Element)child;
}
if ((!bPeek || bReturnDefault) && (child = this.defaultElement(eTag, nOccurrence)) instanceof Element) {
return (Element)child;
}
return null;
}
public final int getElementClass() {
return this.getClassTag();
}
public final int getEnum(int ePropertyTag) {
EnumValue eNum = (EnumValue)this.getAttribute(ePropertyTag);
return eNum.getInt();
}
public final EnumAttr getEnum(String sPropertyName) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "Element#getEnum(String)");
}
@Override
public EventManager.EventTable getEventTable(boolean bCreate) {
if (bCreate && this.mEventTable == null) {
this.mEventTable = new EventManager.EventTable();
}
return this.mEventTable;
}
protected final String getEventScript(Element element) {
if (element == null) {
Attribute attr = this.findEventAttribute(this, "script");
return attr == null ? "" : attr.getAttrValue();
}
Node firstChild = element.getFirstXMLChild();
return firstChild == null ? "" : firstChild.getData();
}
protected final String getEventContentType(Element element) {
Element node = element == null ? this : element;
Attribute attr = this.findEventAttribute(node, "contentType");
return attr == null ? "" : attr.getAttrValue();
}
protected final String getEvent() {
Attribute attr = this.findEventAttribute(this, "event");
return attr == null ? "" : attr.getAttrValue();
}
private Attribute findEventAttribute(Element element, String attrName) {
int len = element.getNumAttrs();
for (int i = 0; i < len; ++i) {
Attribute attr = element.getAttr(i);
if (!attr.getLocalName().equals(attrName) || !attr.getNS().startsWith("http://www.xfa.org/schema/xfa-events/")) continue;
return attr;
}
return null;
}
@Override
public Node getFirstXMLChild() {
return this.mFirstXMLChild;
}
@Override
public final Node getSibling(int index, boolean bByName, boolean bExceptionIfNotFound) {
if (bByName && !$assertionsDisabled && this.getName() == "") {
throw new AssertionError();
}
Element parent = this.getXMLParent();
if (parent != null) {
boolean bError = false;
ChildReln reln = parent.getChildReln(this.getClassTag());
if (reln != null) {
int nMaxOccur = reln.getMax();
if (nMaxOccur == -1) {
return super.getSibling(index, bByName, bExceptionIfNotFound);
}
if (nMaxOccur == 1) {
if (index == 0) {
return this;
}
bError = true;
} else if (nMaxOccur <= index) {
bError = true;
} else {
return parent.getElement(this.getClassTag(), index);
}
}
if (bError) {
if (bExceptionIfNotFound) {
throw new ExFull(new IndexOutOfBoundsException(""));
}
return null;
}
}
return super.getSibling(index, bByName, bExceptionIfNotFound);
}
@Override
public Node getFirstXFAChild() {
if (this.mFirstXMLChild != null && this.mFirstXMLChild.getClassTag() == XFA.INVALID_ELEMENT) {
return this.mFirstXMLChild.getNextXFASibling();
}
return this.mFirstXMLChild;
}
public final String getID() {
if (this.isValidAttr(XFA.IDTAG, false, null)) {
Attribute attr = this.getAttribute(XFA.IDTAG);
return attr == null ? "" : attr.getAttrValue();
}
return "";
}
@Override
public final int getIndex(boolean bByName) {
if (bByName && this.getName() == "") {
MsgFormatPos message = new MsgFormatPos(ResId.NoNameException);
message.format("all");
message.format("getIndex");
throw new ExFull(message);
}
Element parent = this.getXFAParent();
if (parent != null) {
int eType = parent.getSchemaType(this.getClassTag());
if (eType == 0 || eType == 2) {
int nFound = 0;
for (Node child = parent.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!this.isSameClass(child)) continue;
if (child == this) {
return nFound;
}
++nFound;
}
return nFound;
}
if (eType == 3) {
return 0;
}
}
return super.getIndex(bByName);
}
public final String getInheritedNS() {
String ns = this.getNS();
Element check = this;
while (ns == null) {
if (check.getXFAParent() == null) continue;
check = check.getXFAParent();
ns = check.getNS();
}
return ns;
}
public final String getInstalledLocale() {
Attribute attr;
if (this.isPropertySpecified(XFA.LOCALETAG, true, 0) && (attr = this.getAttribute(XFA.LOCALETAG, true, false)) != null && !attr.isEmpty()) {
String sLocale = attr.toString();
if (sLocale.equals("ambient")) {
sLocale = this.getModel().getCachedLocale();
}
return sLocale;
}
Element parent = this.getXFAParent();
if (parent != null) {
return parent.getInstalledLocale();
}
return this.getModel().getCachedLocale();
}
public final boolean isInstalledLocaleAmbient() {
Attribute attr;
if (this.isPropertySpecified(XFA.LOCALETAG, true, 0) && (attr = this.getAttribute(XFA.LOCALETAG, true, false)) != null && !attr.isEmpty()) {
return attr.toString().equals("ambient");
}
Element parent = this.getXFAParent();
if (parent != null) {
return parent.isInstalledLocaleAmbient();
}
return false;
}
boolean getIsDataWindowRoot() {
return this.mbIsDataWindowRoot;
}
public boolean getIsNull() {
return false;
}
@Override
public final Node getLastXMLChild() {
for (Node child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
if (child.getNextXMLSibling() != null) continue;
return child;
}
return null;
}
public final int getLineNumber() {
return this.mnLineNumber;
}
public String getLocalName() {
return this.mLocalName;
}
@Override
public final Model getModel() {
return this.mModel;
}
@Override
public String getName() {
ProtoableNode proto;
if (this.maName != null) {
return this.maName;
}
if (this instanceof ProtoableNode && (proto = ((ProtoableNode)this).getProto()) != null) {
return proto.getName();
}
if (this.getElementClass() == XFA.INVALID_ELEMENT) {
return this.getLocalName();
}
return "";
}
public void privateSetName(String name) {
if (!this.isValidAttr(XFA.NAMETAG, false, null)) {
return;
}
StringAttr a = new StringAttr("name", name);
this.updateAttribute(a);
this.maName = a.getAttrValue();
}
@Override
public NodeList getNodes() {
return new ElementNodeList(this);
}
public final NodeSchema getNodeSchema() {
if (this.mNodeSchema != null) {
return this.mNodeSchema;
}
return this.calcNodeSchema();
}
private final NodeSchema calcNodeSchema() {
if (this.mNodeSchema == null && this.mModel != null) {
if (this.getClassTag() == XFA.INVALID_ELEMENT) {
return Schema.nullSchema();
}
this.mNodeSchema = this.mModel.getSchema().getNodeSchema(this.getClassTag());
}
if (this.mNodeSchema != null) {
return this.mNodeSchema;
}
if (this.mModel instanceof AppModel && this instanceof Model) {
return ((Model)this).getSchema().getNodeSchema(this.getClassTag());
}
return Schema.nullSchema();
}
public String getNS() {
return this.mURI;
}
final String getNSInternal() {
return this.mURI;
}
public final int getNumAttrs() {
if (this instanceof DualDomNode) {
Node peerNode = ((DualDomNode)((Object)this)).getXmlPeer();
if (peerNode instanceof Element) {
return ((Element)peerNode).nAttrs;
}
return 0;
}
return this.nAttrs;
}
public final Node getOneOfChild() {
return this.getOneOfChild(false, false);
}
public Node getOneOfChild(boolean bPeek, boolean bReturnDefault) {
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
int eTag = child.getClassTag();
if (eTag == XFA.INVALID_ELEMENT) {
return null;
}
ChildReln childReln = this.getChildReln(eTag);
if (childReln == null || childReln.getOccurrence() != 4) continue;
return child;
}
if (!bPeek || bReturnDefault) {
int eOneOfChild = this.getDefaultOneOfTag();
if (eOneOfChild == XFA.SCHEMA_DEFAULTTAG) {
return null;
}
if (eOneOfChild == XFA.TEXTNODETAG) {
return this.getModel().createTextNode(this, this.getLastXMLChild(), "");
}
return this.defaultElement(eOneOfChild, 0);
}
return null;
}
void getPI(List<String> pis, boolean bCheckProtos) {
for (Node node = this.getFirstXMLChild(); node != null; node = node.getNextXMLSibling()) {
if (!(node instanceof ProcessingInstruction)) continue;
ProcessingInstruction pi = (ProcessingInstruction)node;
String sTemp = pi.getName() + ' ' + pi.getData();
pis.add(sTemp);
}
}
public void getPI(String aPiName, List<String> pis, boolean bCheckProtos) {
assert (aPiName != null);
for (Node child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
ProcessingInstruction pi;
if (!(child instanceof ProcessingInstruction) || (pi = (ProcessingInstruction)child).getName() != aPiName) continue;
pis.add(pi.getData());
}
}
public void optimizeNameSpace(int eAttributeTag, boolean bDeleteIfNotNeeded) {
if (eAttributeTag == XFA.RIDTAG) {
String sNSAlias = "xmlns:xliff";
boolean bNeeded = true;
if (bDeleteIfNotNeeded) {
bNeeded = this.pruneNameSpaceDefn(this, sNSAlias, "urn:oasis:names:tc:xliff:document:1.1");
}
if (bNeeded) {
this.setAttribute("", sNSAlias, "xliff", "urn:oasis:names:tc:xliff:document:1.1");
}
}
}
public void getPI(String aPiName, String sPropName, List<String> pis, boolean bCheckProtos) {
assert (aPiName != null);
for (Node child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
ProcessingInstruction pi;
String sNodeValue;
String[] sProp;
if (!(child instanceof ProcessingInstruction) || (pi = (ProcessingInstruction)child).getName() != aPiName || !(sProp = (sNodeValue = pi.getData()).split("[ \t]"))[0].equals(sPropName)) continue;
int skip = StringUtils.skipUntil(sNodeValue, " \t", 0);
String sReturn = sNodeValue.substring(skip, sNodeValue.length()).trim();
pis.add(sReturn);
}
}
public final String getPrefix() {
int colon;
String qName = this.getXMLName();
if (qName != null && (colon = qName.indexOf(58)) > 0) {
return qName.substring(0, colon).intern();
}
return "";
}
@Override
public final Object getProperty(int ePropTag, int nOccurrence) {
int ePropType = this.getSchemaType(ePropTag);
if (ePropType == 2) {
return this.getElement(ePropTag, false, nOccurrence, false, false);
}
if (ePropType == 0) {
return this.getText(false, false, false);
}
if (ePropType == 1) {
return this.getAttribute(ePropTag);
}
if (ePropType == 3) {
String aPropertyName = XFA.getString(ePropTag);
throw new ExFull(ResId.InvalidGetOneOfException, aPropertyName);
}
String aPropertyName = XFA.getString(ePropTag);
MsgFormatPos message = new MsgFormatPos(ResId.InvalidGetPropertyException);
message.format(this.getClassName());
message.format(aPropertyName);
throw new ExFull(message);
}
@Override
public final Object getProperty(String propertyName, int nOccurrence) {
int eTag = XFA.getTag(propertyName.intern());
if (eTag != XFA.INVALID_ELEMENT) {
return this.getProperty(eTag, nOccurrence);
}
MsgFormatPos message = new MsgFormatPos(ResId.InvalidGetPropertyException);
message.format(this.getClassName());
message.format(propertyName);
throw new ExFull(message);
}
public boolean getSaveXMLSaveTransient() {
return this.mbSaveXMLSaveTransient;
}
Schema getSchema() {
return this.getModel().getSchema();
}
public int getSchemaType(int eTag) {
if (this.getElementClass() == XFA.INVALID_ELEMENT) {
return 1;
}
if (this.getModel() == null) {
return 5;
}
ChildReln reln = this.getChildReln(eTag);
if (reln != null) {
if (reln.getMax() == -1) {
return 4;
}
if (reln.getOccurrence() == 4) {
return 3;
}
if (eTag == XFA.TEXTNODETAG) {
return 0;
}
return 2;
}
if (this.getNodeSchema().getAttributeInfo(eTag) != null) {
return 1;
}
return 5;
}
@Override
public ScriptFuncObj getScriptMethodInfo(String sFunctionName) {
ScriptFuncObj scriptFunc = null;
Model model = this.getModel();
if (model != null) {
scriptFunc = super.getScriptMethodInfo(sFunctionName);
}
return scriptFunc;
}
@Override
protected ScriptPropObj getScriptProp(String aPropertyName) {
ScriptPropObj scriptProp = null;
Model model = this.getModel();
if (model != null) {
scriptProp = super.getScriptProp(aPropertyName);
}
return scriptProp;
}
@Override
public ScriptTable getScriptTable() {
return ElementScript.getScriptTable();
}
public TextNode getText(boolean bPeek, boolean bReturnDefault, boolean bValidate) {
TextNode child;
if (bValidate) {
ChildReln validChild = this.getChildReln(XFA.TEXTNODETAG);
if (validChild == null) {
MsgFormatPos message = new MsgFormatPos(ResId.InvalidGetPropertyException);
message.format(this.getClassAtom());
message.format("#text");
throw new ExFull(message);
}
} else assert (this.getModel() != null);
if ((child = (TextNode)this.locateChildByClass(XFA.TEXTNODETAG, 0)) != null) {
return child;
}
if (!bPeek || bReturnDefault) {
return (TextNode)this.defaultElement(XFA.TEXTNODETAG, 0);
}
return null;
}
final int getValidOccurrence(int eTag) {
ChildReln validChild = this.getChildReln(eTag);
if (validChild != null) {
return validChild.getOccurrence();
}
return 2;
}
public String getXMLName() {
return this.mQName;
}
public void setXMLName(String name) {
this.mQName = name;
if (this instanceof DualDomNode) {
((Element)((DualDomNode)this).getXmlPeer()).mQName = this.mQName;
}
this.setDirty();
}
public String getXPath(Map<String, String> prefixList, Element contextNode) {
StringBuilder sPrefix = new StringBuilder();
Element common = null;
if (contextNode != null && (common = this.getCommonAncestor(contextNode)) != null) {
Element current = contextNode;
if (common != current) {
sPrefix.append("..");
current = current.getXFAParent();
}
while (common != current) {
sPrefix.append("/..");
current = current.getXFAParent();
}
}
StringBuilder sXPathExp = new StringBuilder();
String sCurrentPrefix = "a";
for (Element current = this; current != common && !(current instanceof Document); current = current.getXFAParent()) {
StringBuilder sPath = new StringBuilder("/");
if (current instanceof Element) {
Element element = current;
String sNodePrefix = element.getPrefix();
String sNodeNSURI = element.getNS();
if (sNodeNSURI != null && sNodeNSURI.length() != 0) {
String sUsedPrefix = prefixList.get(sNodeNSURI);
if (sUsedPrefix != null) {
if (sNodePrefix.length() != 0) {
while (prefixList.containsValue(sCurrentPrefix)) {
sCurrentPrefix = this.bumpString(sCurrentPrefix);
}
sUsedPrefix = sCurrentPrefix;
} else {
sUsedPrefix = sNodePrefix;
}
prefixList.put(sNodeNSURI, sUsedPrefix);
}
if (sUsedPrefix != null && sUsedPrefix.length() != 0) {
sPath.append(sUsedPrefix);
sPath.append(':');
}
}
sPath.append(current.getLocalName());
int index = current.getIndex(false);
sPath.append('[');
sPath.append(index + 1);
sPath.append(']');
}
sXPathExp.insert(0, sPath);
}
sXPathExp.insert(0, sPrefix);
return sXPathExp.toString();
}
private static XPathFactory getXPathFactory() {
if (mXPathFactory == null) {
mXPathFactory = XPathFactory.newInstance();
}
return mXPathFactory;
}
private Element getCommonAncestor(Element pOther) {
Element parent1;
Element parent2;
ArrayList<Element> list1 = new ArrayList<Element>();
ArrayList<Element> list2 = new ArrayList<Element>();
for (parent1 = this; parent1 != null; parent1 = parent1.getXFAParent()) {
list1.add(parent1);
}
for (parent2 = pOther; parent2 != null; parent2 = parent2.getXFAParent()) {
list2.add(parent2);
}
parent1 = (Element)list1.get(list1.size() - 1);
if (parent1 != (parent2 = (Element)list2.get(list2.size() - 1))) {
return null;
}
Element common = null;
while (parent1 == parent2) {
common = parent1;
list1.remove(list1.size() - 1);
list2.remove(list2.size() - 1);
if (list1.size() == 0 || list2.size() == 0) break;
parent1 = (Element)list1.get(list1.size() - 1);
parent2 = (Element)list2.get(list2.size() - 1);
}
return common;
}
String bumpString(String input) {
StringBuilder buffer = new StringBuilder(input);
for (int nPos = input.length() - 1; nPos >= 0; --nPos) {
if (buffer.charAt(nPos) == 'z') {
buffer.setCharAt(nPos, 'a');
continue;
}
buffer.setCharAt(nPos, (char)(buffer.charAt(nPos) + '\u0001'));
return input;
}
input = input + 'a';
return input;
}
public Attribute getXsiNilAttribute() {
Element e = this.getXmlPeerElement();
for (int i = 0; i < e.nAttrs; ++i) {
Attribute a = e.getAttr(i);
if (!a.isXSINilAttr()) continue;
return a;
}
return null;
}
public void removeXsiNilAttribute() {
Element e = this.getXmlPeerElement();
for (int i = 0; i < e.nAttrs; ++i) {
Attribute a = this.getAttr(i);
if (!a.isXSINilAttr()) continue;
e.removeAttr(i);
}
}
public final void setXsiNilAttribute(String aValue) {
Element e = this.getXmlPeerElement();
for (int i = 0; i < e.nAttrs; ++i) {
Attribute a = e.getAttr(i);
if (!a.isXSINilAttr()) continue;
e.mAttrs[i] = new GenericAttribute(a.getName(), a.getLocalName(), a.getQName(), aValue, false);
return;
}
e.extendAttributes(new GenericAttribute("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi:nil", aValue, false));
}
public final boolean inhibitPrettyPrint() {
return this.mbInhibitPrettyPrint;
}
public final void inhibitPrettyPrint(boolean bInhibit) {
this.mbInhibitPrettyPrint = bInhibit;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public void insertChild(Node newChild, Node refNode, boolean bValidate) {
if (refNode != null && !$assertionsDisabled && refNode.getOwnerDocument() != this.getOwnerDocument()) {
throw new AssertionError();
}
if (bValidate) {
this.isValidChild(newChild.getClassTag(), ResId.InvalidChildInsertException, true, false);
}
if (newChild == this || newChild == refNode) {
throw new ExFull(ResId.HierarchyRequestException, newChild.getName());
}
boolean bIsDefault = newChild.isDefault(false);
try {
if (bIsDefault) {
this.mute();
}
if (!newChild.isDefault(true)) {
this.makeNonDefault(false);
}
if (newChild.getXMLParent() != null) {
newChild.remove();
}
if (newChild.getModel() != this.getModel() || newChild.getOwnerDocument() != this.getOwnerDocument()) {
this.updateModelAndDocument(newChild);
}
boolean bAddedLocally = true;
if (refNode == null) {
this.appendChild(newChild);
bAddedLocally = false;
} else {
if (this instanceof DualDomNode && newChild instanceof DualDomNode) {
Element domParentNode = (Element)((DualDomNode)((Object)this)).getXmlPeer();
Node domNewNode = ((DualDomNode)((Object)newChild)).getXmlPeer();
Node domRefNode = ((DualDomNode)((Object)refNode)).getXmlPeer();
if (domNewNode.getModel() != this.getModel() || domNewNode.getOwnerDocument() != this.getOwnerDocument()) {
this.updateModelAndDocument(domNewNode);
}
if (domNewNode instanceof DataModel.AttributeWrapper) {
DataModel.AttributeWrapper wrapper = (DataModel.AttributeWrapper)domNewNode;
Attribute attr = domParentNode.setAttribute(wrapper.getNS(), wrapper.getXMLName(), wrapper.getLocalName(), wrapper.getValue(), false);
DataModel.AttributeWrapper xmlPeer = new DataModel.AttributeWrapper(attr, domParentNode);
xmlPeer.setXfaPeer((Element)newChild);
((DualDomNode)((Object)newChild)).setXmlPeer(xmlPeer);
} else {
domParentNode.insertChild(domNewNode, domRefNode, false);
}
}
if (refNode == this.mFirstXMLChild) {
this.mFirstXMLChild = newChild;
newChild.setNextXMLSibling(refNode);
newChild.setXMLParent(this);
} else {
Node nextChild;
Node child = this.mFirstXMLChild;
while (child != null && (nextChild = child.getNextXMLSibling()) != refNode) {
child = nextChild;
}
if (child != null) {
child.setNextXMLSibling(newChild);
newChild.setNextXMLSibling(refNode);
newChild.setXMLParent(this);
}
}
}
if (bAddedLocally) {
if (newChild.getModel() != this.getModel()) {
this.updateModelAndDocument(newChild);
}
if (!newChild.isMute()) {
newChild.notifyPeers(3, this.getClassAtom(), this);
}
if (!this.isMute()) {
this.notifyPeers(4, newChild.getClassAtom(), newChild);
}
}
}
finally {
if (bIsDefault) {
this.unMute();
}
}
if (newChild instanceof Element) {
this.getOwnerDocument().indexSubtree((Element)newChild, false);
}
this.setDirty();
}
void insertPI(String aPiName, String sPropName, String sData, Node refChild) {
this.isValidChild(refChild.getClassTag(), ResId.InvalidChildInsertException, false, false);
if (refChild == this) {
throw new ExFull(new MsgFormat(ResId.HierarchyRequestException, refChild.getName()));
}
if (refChild.getXFAParent() != this) {
throw new ExFull(ResId.InsertFailedException);
}
String sTemp = sPropName + " " + sData;
new ProcessingInstruction(this, refChild.getPreviousXMLSibling(), aPiName, sTemp);
}
@Override
public boolean isContainer() {
return false;
}
boolean isFragment() {
return this.mbIsFragment;
}
public void isFragment(boolean bFragment, boolean bSetChildren) {
Element parent;
this.mbIsFragment = bFragment;
if (!bFragment && (parent = this.getXMLParent()) != null && parent.isFragment()) {
parent.isFragment(false, false);
}
if (!bSetChildren) {
return;
}
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (child instanceof Element) {
((Element)child).isFragment(bFragment, true);
continue;
}
if (!(child instanceof TextNode)) continue;
((TextNode)child).isFragment(bFragment);
}
for (int i = 0; i < this.getNumAttrs(); ++i) {
this.setAttrProp(i, 2, bFragment);
}
}
public final boolean isHidden() {
return this.mbIsHidden;
}
public final void isHidden(boolean bHidden) {
if (!bHidden && this.isHidden()) {
this.mbIsHidden = bHidden;
}
if (bHidden && !this.isHidden()) {
this.mbIsHidden = bHidden;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Element)) continue;
((Element)child).isHidden(true);
}
}
}
protected boolean isIndexable() {
for (Element node = this; node != null; node = node.getXFAParent()) {
if (node.getClassTag() == XFA.INVALID_ELEMENT) continue;
return node.childrenAreIndexable();
}
return true;
}
protected boolean childrenAreIndexable() {
return true;
}
public final boolean isIndexed() {
return this.mbIsIndexed;
}
@Override
public final boolean isLeaf() {
return this.getFirstXFAChild() == null;
}
@Override
boolean isLikeNode(Node node, boolean bByName) {
if (this == node) {
return true;
}
if (!super.isLikeNode(node, bByName)) {
return false;
}
Element parent = this.getXFAParent();
if (parent != null && parent.getSchemaType(this.getClassTag()) != parent.getSchemaType(node.getClassTag())) {
return false;
}
return true;
}
public boolean isNameSpaceAttr() {
return this.getXMLName().startsWith("xmlns:");
}
@Override
public final boolean isPropertySpecified(int ePropTag, boolean bCheckProtos, int nOccurrence) {
int eType = this.getSchemaType(ePropTag);
if (eType == 1 || eType == 0 || eType == 2) {
return this.isSpecified(ePropTag, eType, bCheckProtos, nOccurrence);
}
return false;
}
@Override
public final boolean isPropertySpecified(String propertyName, boolean bCheckProtos, int nOccurrence) {
int ePropTag = XFA.getTag(propertyName.intern());
if (ePropTag == XFA.INVALID_ELEMENT) {
return false;
}
return this.isPropertySpecified(ePropTag, bCheckProtos, nOccurrence);
}
public final boolean isPropertyValid(int ePropTag) {
if (this.isValidAttr(ePropTag, false, null)) {
return true;
}
return this.isValidElement(ePropTag, false);
}
final boolean isPropertyValid(String propertyName) {
int ePropTag = XFA.getTag(propertyName);
if (ePropTag == XFA.INVALID_ELEMENT) {
return false;
}
return this.isPropertyValid(ePropTag);
}
@Override
public boolean isSpecified(int eTag, boolean bCheckProtos, int nOccurrence) {
int eType = this.getSchemaType(eTag);
return this.isSpecified(eTag, eType, bCheckProtos, nOccurrence);
}
public boolean isSpecified(int eTag, int eType, boolean bCheckProtos, int nOccurrence) {
ChildReln validChild;
if (eType == 5) {
return false;
}
if (eType == 1) {
String aPropName = this.getAtom(eTag);
return this.findSchemaAttr(aPropName) != -1;
}
if (this.getFirstXFAChild() == null) {
return false;
}
if (nOccurrence > 0 && (validChild = this.getChildReln(eTag)) != null && validChild.getMax() <= nOccurrence) {
return false;
}
if (eType == 3) {
if (nOccurrence > 0) {
return false;
}
Node oneOf = this.getOneOfChild(true, false);
if (oneOf != null && oneOf.getClassTag() == eTag) {
return true;
}
} else {
Node child = this.locateChildByClass(eTag, nOccurrence);
return child != null && !child.isDefault(true);
}
return false;
}
@Override
public final boolean isSpecified(String sPropertyName, boolean bCheckProtos, int nOccurrence) {
int ePropTag = XFA.getTag(sPropertyName);
if (ePropTag == XFA.INVALID_ELEMENT) {
return false;
}
return this.isSpecified(ePropTag, bCheckProtos, nOccurrence);
}
@Override
public final void isTransient(boolean bTransient, boolean bSetChildren) {
super.isTransient(bTransient, bSetChildren);
if (this instanceof DualDomNode) {
((DualDomNode)((Object)this)).getXmlPeer().isTransient(bTransient, bSetChildren);
}
for (int i = 0; i < this.getNumAttrs(); ++i) {
this.setAttrProp(i, 4, bTransient);
}
}
@Override
public boolean isTransparent() {
int eType;
Element parent = this.getXFAParent();
if (parent != null && ((eType = parent.getSchemaType(this.getClassTag())) == 0 || eType == 2 || eType == 3)) {
return false;
}
if (this.isContainer() && this.getName() == "") {
return true;
}
return this.mbTransparent;
}
public boolean isValidAttr(int eTag, boolean bReport, String value) {
if (this.getElementClass() == XFA.INVALID_ELEMENT) {
return false;
}
Model model = this.getModel();
if (model == null) {
assert (false);
return false;
}
AttributeInfo info = this.getNodeSchema().getAttributeInfo(eTag);
if (info == null) {
return false;
}
int nVersionIntroduced = info.getVersionIntroduced();
int nAvailability = info.getAvailability();
if (value != null) {
EnumValue eTest = null;
Attribute defaultAttribute = info.getDefault();
if (defaultAttribute instanceof EnumValue) {
try {
eTest = (EnumValue)defaultAttribute.newAttribute(value);
}
catch (ExFull ex) {
// empty catch block
}
}
if (eTest != null) {
nVersionIntroduced = eTest.getAttr().getVersionIntro();
nAvailability = eTest.getAttr().getAvailability();
}
}
if (!model.validateUsage(nVersionIntroduced, nAvailability, bReport)) {
if (bReport) {
MsgFormatPos reason = new MsgFormatPos(ResId.InvalidAttributeVersionException);
reason.format(this.getAtom(eTag));
reason.format(this.getClassAtom());
ExFull ex = new ExFull(reason);
if (model.validateUsageFailedIsFatal(nVersionIntroduced, nAvailability)) {
throw ex;
}
model.addErrorList(ex, 3, this);
} else if (model.validateUsageFailedIsFatal(nVersionIntroduced, nAvailability)) {
return false;
}
if (model.isLoading()) {
return false;
}
}
if (bReport && info.getVersionDeprecated() != 0) {
int nTargetVer = model.getCurrentVersion();
if (info.getVersionDeprecated() <= nTargetVer) {
MsgFormatPos reason = new MsgFormatPos(ResId.DeprecatedAttributeException, this.getAtom(eTag));
reason.format(this.getClassAtom());
ExFull ex = new ExFull(reason);
model.addXMLLoadErrorContext(this, ex);
}
}
return true;
}
public boolean isValidChild(int eTag, int nError, boolean bBeforeInsert, boolean bOccurrenceErrorOnly) {
ChildReln validChild;
if (this.getElementClass() == XFA.INVALID_ELEMENT) {
return true;
}
Model model = this.getModel();
if (model == null) {
assert (false);
return false;
}
ChildRelnInfo info = this.getNodeSchema().getChildRelnInfo(eTag);
if (info == null) {
if (nError != 0 && !bOccurrenceErrorOnly) {
MsgFormatPos message = new MsgFormatPos(nError, this.getClassAtom());
String name = null;
name = eTag == XFA.INVALID_ELEMENT ? this.getClassName() : this.getAtom(eTag);
message.format(name);
throw new ExFull(message);
}
return false;
}
if (!model.validateUsage(info.getVersionIntroduced(), info.getAvailability(), true)) {
MsgFormatPos reason = new MsgFormatPos(ResId.InvalidChildVersionException, this.getAtom(eTag));
reason.format(this.getClassAtom());
if (model.validateUsageFailedIsFatal(info.getVersionIntroduced(), info.getAvailability()) || model.isLoading()) {
if (nError != 0 && !bOccurrenceErrorOnly) {
MsgFormatPos message = new MsgFormatPos(nError, this.getClassAtom());
message.format(this.getAtom(eTag));
ExFull error = new ExFull(message);
error.insert(new ExFull(reason), true);
throw error;
}
return false;
}
model.addErrorList(new ExFull(reason), 3, this);
}
if (model.isLoading() && info.getVersionDeprecated() != 0) {
int nTargetVer = model.getCurrentVersion();
if (info.getVersionDeprecated() <= nTargetVer) {
MsgFormatPos reason = new MsgFormatPos(ResId.DeprecatedChildException, this.getAtom(eTag));
reason.format(this.getClassAtom());
ExFull ex = new ExFull(reason);
model.addXMLLoadErrorContext(this, ex);
}
}
if ((validChild = info.getRelationship()).getOccurrence() == 1) {
int index = 0;
if (!bBeforeInsert) {
++index;
}
if (this.locateChildByClass(eTag, index) == null) {
return true;
}
if (nError != 0) {
MsgFormatPos e1 = new MsgFormatPos(nError, this.getClassAtom());
e1.format(this.getAtom(eTag));
ExFull error = new ExFull(e1);
ExFull message2 = new ExFull(ResId.OccurrenceViolationException, this.getAtom(eTag));
error.insert(message2, true);
throw error;
}
return false;
}
if (this.getFirstXFAChild() != null && validChild.getOccurrence() == 4) {
boolean bOneOfAllowed = !bBeforeInsert;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
int childTag = child.getClassTag();
if (childTag == XFA.INVALID_ELEMENT || this.getValidOccurrence(childTag) != 4) continue;
if (bOneOfAllowed) {
bOneOfAllowed = false;
continue;
}
if (nError != 0) {
MsgFormatPos message = new MsgFormatPos(nError, this.getClassName());
message.format(this.getAtom(eTag));
ExFull error = new ExFull(message);
ExFull message2 = new ExFull(ResId.OccurrenceViolationException, XFA.getAtom(eTag));
error.insert(message2, true);
throw error;
}
return false;
}
return true;
}
return true;
}
public boolean isValidElement(int eTag, boolean bReport) {
Model model = this.getModel();
if (model == null) {
assert (false);
return false;
}
ChildRelnInfo info = this.getNodeSchema().getChildRelnInfo(eTag);
if (info != null) {
if (!model.validateUsage(info.getVersionIntroduced(), info.getAvailability(), bReport)) {
if (bReport) {
MsgFormatPos reason = new MsgFormatPos(ResId.InvalidChildVersionException, this.getAtom(eTag));
reason.format(this.getClassAtom());
if (model.validateUsageFailedIsFatal(info.getVersionIntroduced(), info.getAvailability())) {
throw new ExFull(reason);
}
model.addErrorList(new ExFull(reason), 3, this);
} else if (model.validateUsageFailedIsFatal(info.getVersionIntroduced(), info.getAvailability())) {
return false;
}
}
if (bReport && info.getVersionDeprecated() != 0) {
int nTargetVer = model.getCurrentVersion();
if (info.getVersionDeprecated() <= nTargetVer) {
MsgFormatPos reason = new MsgFormatPos(ResId.DeprecatedChildException, this.getAtom(eTag));
reason.format(this.getClassAtom());
ExFull ex = new ExFull(reason);
model.addXMLLoadErrorContext(this, ex);
}
}
return true;
}
if (this.getClassTag() == XFA.INVALID_ELEMENT) {
return true;
}
if (this.isSameClass(XFA.XFATAG)) {
if (eTag == XFA.DSIGDATATAG || eTag == XFA.PACKETTAG) {
return true;
}
return false;
}
return false;
}
public void loadXML(InputStream is, boolean bIgnoreAggregatingTag, boolean bReplaceContent) {
this.loadXML(is, bIgnoreAggregatingTag, bReplaceContent ? ReplaceContent.AllContent : ReplaceContent.None);
}
public void loadXML(InputStream is, boolean bIgnoreAggregatingTag, ReplaceContent eReplaceContent) {
Model model = this.getModel();
assert (model != null);
model.loadXMLImpl(this, is, bIgnoreAggregatingTag, eReplaceContent);
}
@Override
public void makeDefault() {
super.makeDefault();
int n = this.getNumAttrs();
for (int i = 0; i < n; ++i) {
this.setAttrProp(i, 1, true);
}
}
@Override
public void makeNonDefault(boolean bRecursive) {
super.makeNonDefault(bRecursive);
if (this.getModel() != null && !this.getModel().isLoading()) {
this.setDirty();
}
if (this.isFragment()) {
this.isFragment(false, false);
this.isTransient(false, false);
}
}
@Override
public void setDefaultFlag(boolean bDefaultNode, boolean bSetChildren) {
if (this.isDefault(false) != bDefaultNode || bSetChildren) {
super.setDefaultFlag(bDefaultNode, bSetChildren);
int n = this.getNumAttrs();
for (int i = 0; i < n; ++i) {
this.setAttrProp(i, 1, false);
}
}
}
public Attribute newAttribute(int eTag, String value) {
if (this.getClassTag() == XFA.INVALID_ELEMENT || this.isSameClass(XFA.DSIGDATATAG)) {
return new StringAttr("", value);
}
return this.getModel().getSchema().newAttribute(eTag, value, this.getClassTag());
}
public final Attribute peekAttribute(int eAttributeTag) {
return this.getAttribute(eAttributeTag, true, false);
}
public final Element peekElement(int eElementTag, boolean bReturnDefault, int nOccurrence) {
return this.getElement(eElementTag, true, nOccurrence, bReturnDefault, false);
}
@Override
public final Node peekOneOfChild(boolean bReturnDefault) {
return this.getOneOfChild(true, bReturnDefault);
}
@Override
public final Object peekProperty(int ePropTag, int nOccurrence) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "Element#peekProperty(int, int)");
}
@Override
public final Object peekProperty(String propertyName, int nOccurrence) {
throw new ExFull(ResId.UNSUPPORTED_OPERATION, "Element#peekProperty(String, int)");
}
@Override
public void postSave() {
}
@Override
public void preSave(boolean bSaveXMLScript) {
}
public final void removeAttr(int index) {
assert (index >= 0 || index < this.getNumAttrs());
Element e = this.getXmlPeerElement();
Attribute attr = e.getAttr(index);
if (this.getOwnerDocument() != null && this.getOwnerDocument().isId(this.getNSInternal(), this.getLocalName(), attr.getNS(), attr.getLocalName())) {
this.getOwnerDocument().deindexNode(this, false);
}
if (attr.getLocalName() == "name") {
this.maName = null;
}
if (index != e.nAttrs - 1) {
System.arraycopy(e.mAttrs, index + 1, e.mAttrs, index, e.nAttrs - index - 1);
System.arraycopy(e.mAttrProperties, index + 1, e.mAttrProperties, index, e.nAttrs - index - 1);
}
--e.nAttrs;
e.mAttrs[e.nAttrs] = null;
e.mAttrProperties[e.nAttrs] = 0;
this.notifyPeers(1, attr.getLocalName(), this);
this.setDirty();
}
public final void removeAttr(String URI2, String name) {
int attr = this.findAttr(URI2, name);
if (attr != -1) {
this.removeAttr(attr);
}
}
public final void removeChild(Node child) {
if (child == null) {
return;
}
Element parent = this.getXFAParent();
this.setDirty();
if (child instanceof Element && this.getOwnerDocument() != null) {
this.getOwnerDocument().deindexSubtree((Element)child, false);
}
EventManager.resetEventTable(child.getEventTable(false));
Node previous = null;
Node next = null;
Node iter = this.getFirstXMLChild();
while (iter != null) {
next = iter.getNextXMLSibling();
if (next == child) {
previous = iter;
break;
}
iter = next;
}
if (previous == null && this.getFirstXMLChild() != child) {
throw new ExFull(ResId.RemoveFailedException);
}
next = child.getNextXMLSibling();
if (previous != null) {
previous.setNextXMLSibling(next);
} else {
this.setFirstChild(next);
}
if (child instanceof DualDomNode) {
Element parent2;
DualDomNode dualDomChild = (DualDomNode)((Object)child);
Node peer = dualDomChild.getXmlPeer();
if (peer instanceof DataModel.AttributeWrapper) {
DataModel.AttributeWrapper attr = (DataModel.AttributeWrapper)peer;
Element elem = (Element)((DualDomNode)((Object)parent)).getXmlPeer();
elem.removeAttr(attr.getNS(), attr.getLocalName());
} else if (peer != null && (parent2 = peer.getXMLParent()) != null) {
parent2.removeChild(peer);
}
}
child.setNextXMLSibling(null);
child.setXMLParent(null);
this.setChildListModified(true);
}
public final void removePI(String aPiName) {
assert (aPiName != null);
Node node = this.getFirstXMLChild();
while (node != null) {
ProcessingInstruction pi;
if (node instanceof ProcessingInstruction && (pi = (ProcessingInstruction)node).getName() == aPiName) {
node = node.getNextXMLSibling();
pi.getXMLParent().removeChild(pi);
continue;
}
node = node.getNextXMLSibling();
}
}
public final void removePI(String aPiName, String sPropName) {
assert (aPiName != null);
Node node = this.getFirstXMLChild();
while (node != null) {
String[] vals;
ProcessingInstruction pi;
String sNodeValue;
if (node instanceof ProcessingInstruction && (pi = (ProcessingInstruction)node).getName() == aPiName && (vals = (sNodeValue = pi.getData()).split(" "))[0].equals(sPropName)) {
node = node.getNextXMLSibling();
pi.getXMLParent().removeChild(pi);
continue;
}
node = node.getNextXMLSibling();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public final void removeWhiteSpace() {
boolean bSetLoading = this.getWillDirty();
if (bSetLoading) {
this.setWillDirty(false);
}
try {
Node childNode = this.getFirstXMLChild();
while (childNode != null) {
Node nextSibling = childNode.getNextXMLSibling();
if (childNode instanceof Chars && ((Chars)childNode).isXMLSpace()) {
this.removeChild(childNode);
}
childNode = nextSibling;
}
}
finally {
if (bSetLoading) {
this.setWillDirty(true);
}
}
}
public Node replaceChild(Node newChild, Node oldChild) {
if (oldChild == null) {
return null;
}
Node nextChild = oldChild.getNextXMLSibling();
this.removeChild(oldChild);
this.insertChild(newChild, nextChild, false);
return oldChild;
}
public void resetPostLoadXML() {
}
protected void resolveAndEnumerateChildren(NodeList properties, NodeList children, boolean bAllProperties, boolean bFirstDefaultOnly) {
SchemaPairs validChildren = this.getNodeSchema().getValidChildren();
block0 : for (int i = 0; validChildren != null && i < validChildren.size(); ++i) {
int eTag = validChildren.key(i);
ChildReln childR = (ChildReln)validChildren.value(i);
int nMax = childR.getMax();
if (nMax == -1 || childR.getOccurrence() == 4) continue;
for (int nProtoIndex = 0; nProtoIndex < nMax; ++nProtoIndex) {
Node child = eTag == XFA.TEXTNODETAG ? this.getText(true, false, false) : this.getElement(eTag, true, nProtoIndex, false, false);
if (child == null && bAllProperties) {
if (bFirstDefaultOnly && nProtoIndex == 1) continue block0;
child = this.createDefaultElement(eTag, nProtoIndex);
}
if (child == null) continue block0;
properties.append(child);
}
}
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
int eType = this.getSchemaType(child.getClassTag());
if (eType != 4) continue;
children.append(child);
}
}
protected NodeList enumerateChildren() {
ListBase children = null;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
int eType = this.getSchemaType(child.getClassTag());
if (eType != 4) continue;
if (children == null) {
children = new ArrayNodeList();
}
children.append(child);
}
return children;
}
protected NodeList enumerateProperties() {
ListBase properties = null;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
int eType = this.getSchemaType(child.getClassTag());
if (eType != 0 && eType != 2) continue;
if (properties == null) {
properties = new ArrayNodeList();
}
properties.append(child);
}
return properties;
}
public NodeList resolveAndEnumerateChildren(boolean bAllProperties, boolean bFirstDefaultOnly) {
int eTag;
ArrayNodeList list = new ArrayNodeList();
Node oneOfChild = this.getOneOfChild(true, false);
this.resolveAndEnumerateChildren(list, list, bAllProperties, bFirstDefaultOnly);
if (oneOfChild != null) {
list.append(oneOfChild);
} else if (bAllProperties && (eTag = this.getDefaultOneOfTag()) != XFA.SCHEMA_DEFAULTTAG) {
Element defaultElement = this.getModel().createElement(eTag, null);
list.append(defaultElement);
}
return list;
}
public SOMParser.SomResultInfo resolveNodeCreate(String somNodesInput, int eAction, boolean bLeaf, boolean bDefault, boolean bNoProperties) {
boolean bHasStar;
String somNodes = somNodesInput.startsWith("!") ? "xfa.datasets." + somNodesInput.substring(1) : somNodesInput;
ArrayList<SOMParser.SomResultInfo> result = new ArrayList<SOMParser.SomResultInfo>();
SOMParser parser = new SOMParser(null);
parser.setOptions(true, true, bNoProperties);
parser.resolve(this, somNodes, null, result, null);
for (int i = result.size(); i > 0; --i) {
if (result.get((int)(i - 1)).object instanceof Node) continue;
result.remove(i - 1);
}
int nFoundAt = somNodes.indexOf(42);
boolean bl = bHasStar = nFoundAt >= 0;
if (bHasStar && result.size() == 1 && eAction == 1) {
eAction = 2;
}
if (eAction == 2 || result.size() == 0 && eAction == 1) {
String sNodesExist = null;
Element parent = this;
nFoundAt = 0;
int nNextFoundAt = 0;
if (somNodes.length() > 2 && somNodes.charAt(0) == '$' && somNodes.charAt(1) != '.') {
String sShortCutName;
nNextFoundAt = somNodes.indexOf(46, 1);
if (nNextFoundAt < 0) {
nNextFoundAt = somNodes.length();
}
if ((parent = (Element)this.resolveNode(sShortCutName = somNodes.substring(0, nNextFoundAt), false, false, false)) == null) {
String sModelAlias = sShortCutName.substring(1);
AppModel appModel = this.getAppModel();
List<ModelFactory> factories = appModel.factories();
for (int i2 = 0; i2 < factories.size(); ++i2) {
ModelFactory factory = factories.get(i2);
if (!factory.rootName().equals(sModelAlias)) continue;
factory.createDOM((Element)appModel.getXmlPeer());
parent = (Element)this.resolveNode(sShortCutName, false, false, false);
assert (parent != null);
break;
}
if (parent == null) {
MsgFormatPos message = new MsgFormatPos(ResId.CantCreateSOMExpression);
message.format(somNodes);
throw new ExFull(message);
}
}
if (parent.getModel() != this.getModel()) {
return parent.resolveNodeCreate(somNodes, eAction, bLeaf, false, false);
}
}
boolean bLookUp = true;
while ((nNextFoundAt = SOMParser.findDot(somNodes, nFoundAt + 1)) > 0) {
sNodesExist = somNodes.substring(0, nNextFoundAt);
if (bHasStar && eAction == 2 && somNodes.indexOf(42, nNextFoundAt) < 0 && somNodes.indexOf(42, nFoundAt) >= 0) {
sNodesExist = somNodes.substring(0, nFoundAt);
break;
}
Element tmpNode = parent;
parent = (Element)this.resolveNode(sNodesExist, true, true, false);
if (parent == null) {
sNodesExist = somNodes.substring(0, nFoundAt);
parent = tmpNode;
break;
}
bLookUp = false;
nFoundAt = nNextFoundAt;
}
int nStart = 0;
if (sNodesExist != null && sNodesExist.length() > 0) {
nStart = sNodesExist.length() + 1;
}
String sNodesCreate = somNodes.substring(nStart, somNodes.length());
boolean bIsLeaf = false;
while (sNodesCreate.length() > 0) {
int numToCreate;
int eTag;
String aNewNode = null;
nFoundAt = SOMParser.findDot(sNodesCreate, 0);
if (nFoundAt > 0) {
aNewNode = sNodesCreate.substring(0, nFoundAt).intern();
sNodesCreate = sNodesCreate.substring(aNewNode.length() + 1, sNodesCreate.length());
} else {
aNewNode = sNodesCreate.intern();
sNodesCreate = "";
if (bLeaf) {
bIsLeaf = true;
}
}
if (aNewNode == "$") continue;
int absNumToCreate = 0;
int nBraceStart = aNewNode.indexOf(91);
if (nBraceStart >= 0) {
nFoundAt = aNewNode.indexOf(93);
if (nFoundAt >= 0) {
String sNum = aNewNode.substring(nBraceStart + 1, nFoundAt);
try {
absNumToCreate = Integer.parseInt(sNum);
}
catch (NumberFormatException e) {
nFoundAt = 0;
}
} else {
MsgFormatPos message = new MsgFormatPos(ResId.CantCreateSOMExpression);
message.format(somNodes);
throw new ExFull(message);
}
aNewNode = aNewNode.substring(0, nBraceStart).intern();
}
if (aNewNode.indexOf("\\.") != -1) {
aNewNode = SOMParser.unescapeSomName(aNewNode).intern();
}
while (bLookUp && parent != null && !parent.canCreateChild(bIsLeaf, aNewNode)) {
parent = parent.getXFAParent();
}
bLookUp = false;
if (parent == null) {
MsgFormatPos message = new MsgFormatPos(ResId.CantCreateSOMExpression);
message.format(somNodes);
throw new ExFull(message);
}
boolean bFoundTransient = false;
for (Node child = parent.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
Element element;
if (!(child instanceof Element) || (element = (Element)child).getName() != aNewNode) continue;
if (element.isDefault(false)) {
element.makeNonDefault(false);
parent = element;
bFoundTransient = true;
break;
}
if (absNumToCreate <= 0) continue;
--absNumToCreate;
}
if (bFoundTransient) continue;
if (!parent.canCreateChild(bIsLeaf, aNewNode) && numToCreate == 1 && (eTag = XFA.getTag(aNewNode)) != XFA.INVALID_ELEMENT && parent.isValidAttr(eTag, false, null)) {
Arg initValue = new Arg();
return new SOMParser.SomResultInfo(parent, aNewNode, 0, initValue);
}
Element newNode = null;
for (numToCreate = 1 + absNumToCreate; numToCreate > 0 && parent.canCreateChild(bIsLeaf, aNewNode); --numToCreate) {
newNode = (Element)parent.createChild(bIsLeaf, aNewNode);
if (newNode != null) continue;
MsgFormatPos message = new MsgFormatPos(ResId.CantCreateSOMExpression);
message.format(somNodes);
throw new ExFull(message);
}
parent = newNode;
}
return new SOMParser.SomResultInfo(parent);
}
if (result.size() != 1) {
throw new ExFull(ResId.SOMTypeException);
}
return result.get(0);
}
void restoreDelta(Element delta) {
Element parent = this.getXFAParent();
if (parent != null) {
delta.remove();
parent.insertChild(delta, this, false);
delta.makeNonDefault(false);
this.remove();
}
}
public void saveXML(OutputStream outFile, DOMSaveOptions options) {
this.saveXML(outFile, options, false);
}
public void saveXML(OutputStream outFile, DOMSaveOptions options, boolean bSaveXMLScript) {
Document doc = this.getOwnerDocument();
AppModel appModel = this.getAppModel();
if (appModel != null) {
appModel.preSaveXML();
}
this.preSave(bSaveXMLScript);
if (options == null) {
options = new DOMSaveOptions();
options.setSaveTransient(true);
}
doc.saveAs(outFile, this, options);
}
public void saveFilteredXML(NodeList nodeList, OutputStream outFile, DOMSaveOptions options) {
Element clonedRoot = this.filterClone(nodeList);
if (clonedRoot != null) {
clonedRoot.saveXML(outFile, options);
}
}
private boolean isElementEmpty(DOMSaveOptions options) {
for (Node child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
if (child instanceof Element) {
if (!options.canBeSaved(((Element)child).isFragment(), child.isDefault(false), child.isTransient())) continue;
return false;
}
if (child instanceof Chars) {
Chars chars = (Chars)child;
if (StringUtils.isEmpty(chars.getText()) || !options.canBeSaved(false, child.isDefault(false), child.isTransient())) continue;
return false;
}
return false;
}
return true;
}
@Override
public void serialize(OutputStream outStream, DOMSaveOptions options, int level, Node prevSibling) throws IOException {
if (!options.canBeSaved(this.isFragment(), this.isDefault(false), this.isTransient())) {
return;
}
if (options.getIgnoreExtraRootData() && this.getAppModel().getDocument().isAllDataRootsEmpty() && this.getAppModel().getDocument().getAddedRootData() == this) {
return;
}
int eDisplayFormat = options.getDisplayFormat();
if (level != 0 || prevSibling != null) {
if (options.getDisplayFormat() == 2) {
if (prevSibling == null || !(prevSibling instanceof Chars) || ((Chars)prevSibling).isXMLSpace()) {
options.writeIndent(outStream, level);
}
} else if (level == 0 && (options.getFormatOutside() || options.getDisplayFormat() == 1)) {
outStream.write(Document.MarkupReturn);
}
}
outStream.write(Document.MarkupStartTag);
String qName = this.getXMLName();
String ns = this.getNSInternal();
String prefix = this.getPrefix();
outStream.write(qName.getBytes("UTF-8"));
int nAttrs = this.getNumAttrs();
for (int i = 0; i < nAttrs; ++i) {
Attribute a = this.getAttr(i);
if (a.isNameSpaceAttr() || a.getPrefix() == "") continue;
Element.addNamespaceDef(outStream, options, this, a.getPrefix(), a.getNS());
}
this.saveAttributesToStream(outStream, options);
Element.addNamespaceDef(outStream, options, this, prefix, ns);
if (this.isElementEmpty(options)) {
if (options.getDisplayFormat() == 1) {
outStream.write(Document.MarkupReturn);
}
if (options.getExpandElement()) {
outStream.write(Document.MarkupEndTag);
outStream.write(Document.MarkupCloseTag);
outStream.write(qName.getBytes("UTF-8"));
if (options.getDisplayFormat() == 1) {
outStream.write(Document.MarkupReturn);
}
outStream.write(Document.MarkupEndTag);
} else {
outStream.write(Document.MarkupEndTag2);
}
} else {
if (options.getDisplayFormat() == 1) {
outStream.write(Document.MarkupReturn);
}
outStream.write(Document.MarkupEndTag);
if (this.inhibitPrettyPrint() && options.getDisplayFormat() == 2) {
options.setDisplayFormat(0);
}
Node prevChild = null;
for (Node child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
child.serialize(outStream, options, level + 1, prevChild);
prevChild = child;
}
if (options.getDisplayFormat() == 2 && (prevChild instanceof Element || prevChild instanceof Chars && prevChild.getPreviousXMLSibling() != null && ((Chars)prevChild).isXMLSpace()) && (prevSibling == null || !(prevSibling instanceof Chars) || ((Chars)prevSibling).isXMLSpace())) {
options.writeIndent(outStream, level);
}
outStream.write(Document.MarkupCloseTag);
outStream.write(qName.getBytes("UTF-8"));
if (options.getDisplayFormat() == 1) {
outStream.write(Document.MarkupReturn);
}
outStream.write(Document.MarkupEndTag);
Element.removeNamespaceDef(this, prefix);
for (int i2 = 0; i2 < nAttrs; ++i2) {
Attribute attr = this.getAttr(i2);
if (attr.isNameSpaceAttr() || attr.getPrefix() == "") continue;
Element.removeNamespaceDef(this, attr.getPrefix());
}
}
options.setDisplayFormat(eDisplayFormat);
}
private void saveAttributesToStream(OutputStream outStream, DOMSaveOptions options) throws IOException {
int nAttrs = this.getNumAttrs();
if (options.getCanonicalizeNamespaceOrder()) {
int i;
int nDefaultNamespaceIndex = -1;
ArrayList<Integer> namespaceAttrIndexes = null;
for (i = 0; i < nAttrs; ++i) {
Attribute attr = this.getAttr(i);
if (!attr.isNameSpaceAttr()) continue;
if (attr.getQName() == "xmlns") {
nDefaultNamespaceIndex = i;
continue;
}
if (namespaceAttrIndexes == null) {
namespaceAttrIndexes = new ArrayList<Integer>(nAttrs);
}
namespaceAttrIndexes.add(i);
}
if (nDefaultNamespaceIndex >= 0) {
this.saveAttributeToStream(nDefaultNamespaceIndex, outStream, options);
}
if (namespaceAttrIndexes != null) {
Integer[] indexes = new Integer[namespaceAttrIndexes.size()];
namespaceAttrIndexes.toArray(indexes);
if (indexes.length > 1) {
Arrays.sort(indexes, new Comparator<Integer>(){
@Override
public int compare(Integer o1, Integer o2) {
return StringUtils.UCS_CODEPOINT_COMPARATOR.compare(Element.this.getAttrName(o1), Element.this.getAttrName(o2));
}
});
}
for (int i2 = 0; i2 < indexes.length; ++i2) {
this.saveAttributeToStream(indexes[i2], outStream, options);
}
}
for (i = 0; i < nAttrs; ++i) {
Attribute attr = this.getAttr(i);
if (attr.isNameSpaceAttr()) continue;
this.saveAttributeToStream(i, outStream, options);
}
} else {
for (int i = 0; i < nAttrs; ++i) {
this.saveAttributeToStream(i, outStream, options);
}
}
}
private void saveAttributeToStream(int attrIndex, OutputStream outStream, DOMSaveOptions options) throws IOException {
Attribute a = this.getAttr(attrIndex);
if (!options.canBeSaved(this.getAttrProp(attrIndex, 2), this.getAttrProp(attrIndex, 1), this.getAttrProp(attrIndex, 4))) {
return;
}
if (!a.isNameSpaceAttr() || Element.displayNamespace(a, this, options, false)) {
outStream.write(Document.MarkupSpace);
outStream.write(a.getQName().getBytes("UTF-8"));
outStream.write(Document.MarkupAttrMiddle);
String aValue = StringUtils.toXML(a.getAttrValue(), true);
if (aValue.length() > 0) {
outStream.write(aValue.getBytes("UTF-8"));
}
outStream.write(Document.MarkupDQuoteString);
}
}
public void setAttribute(Attribute attr, int eTag) {
String aPropertyName = this.getAtom(eTag);
if (eTag == XFA.IDTAG && this.isPropertySpecified(XFA.IDTAG, true, 0)) {
throw new ExFull(new MsgFormat(ResId.ImmutableAttributeException, aPropertyName));
}
if (attr == null) {
this.removeAttr(null, XFA.getString(eTag));
this.makeNonDefault(false);
this.setDirty();
return;
}
if (!this.isValidAttr(eTag, true, null)) {
MsgFormatPos message = new MsgFormatPos(ResId.InvalidSetPropertyException);
message.format(this.getClassAtom());
message.format(aPropertyName);
throw new ExFull(message);
}
Attribute defaultAttribute = this.defaultAttribute(eTag);
Attribute newValue = attr;
if (defaultAttribute.getClass() != attr.getClass() || defaultAttribute instanceof EnumValue && ((EnumValue)attr).getType() != ((EnumValue)defaultAttribute).getType()) {
newValue = defaultAttribute.newAttribute(attr.getNS(), aPropertyName, aPropertyName, attr.toString());
}
if (eTag == XFA.NAMETAG) {
this.maName = attr.toString();
}
String aAttrName = this.getAtom(eTag);
if (newValue.getName() != aAttrName) {
newValue = newValue.newAttribute(attr.getNS(), aPropertyName, aPropertyName, attr.toString());
}
newValue.normalize();
this.updateAttribute(newValue);
this.makeNonDefault(false);
if (!this.isMute() && !this.getModel().isLoading()) {
this.notifyPeers(1, aAttrName, newValue);
}
this.setDirty();
}
public final void setAttribute(int eVal, int eTag) {
EnumAttr value = EnumAttr.getEnum(eVal);
this.setAttribute(EnumValue.getEnum(eTag, value), eTag);
}
public final Attribute setAttribute(String nameSpace, String qName, String localName, String value) {
return this.setAttribute(nameSpace, qName, localName, value, true);
}
public final Attribute setAttribute(String nameSpace, String qName, String localName, String value, boolean internSymbols) {
Attribute a;
if (internSymbols) {
if (nameSpace != null) {
nameSpace = nameSpace.intern();
}
if (qName != null) {
qName = qName.intern();
}
if (localName != null) {
localName = localName.intern();
}
}
int n = this.findAttr(nameSpace, qName);
Element e = this.getXmlPeerElement();
if (n != -1) {
Attribute existingAttribute = e.mAttrs[n];
if (this.getOwnerDocument().isId(e.getNSInternal(), e.getLocalName(), existingAttribute.getNS(), existingAttribute.getLocalName())) {
throw new ExFull(ResId.DOM_MODIFY_ID_ERR);
}
a = existingAttribute.newAttribute(nameSpace, localName, qName, value = this.internAttributeValue(existingAttribute, value), internSymbols);
if (a.getLocalName() == "name") {
this.maName = a.toString();
}
e.mAttrs[n] = a;
} else {
a = this.createAttribute(localName, nameSpace, qName, value, this.getNodeSchema());
e.extendAttributes(a);
}
this.setDirty();
return a;
}
public final void setAttrProp(int attrIndex, int eProp, boolean bValue) {
Element e = this.getXmlPeerElement();
byte[] arrby = e.mAttrProperties;
int n = attrIndex;
arrby[n] = (byte)(arrby[n] & ~ eProp);
if (bValue) {
byte[] arrby2 = e.mAttrProperties;
int n2 = attrIndex;
arrby2[n2] = (byte)(arrby2[n2] | eProp);
}
}
protected void setClass(Element parent, int eTag) {
}
public void setDOMProperties(String uri, String localName, String qName, Attributes attributes) {
if (uri != null) {
this.setNameSpaceURI(uri, false, false, false);
}
this.setLocalName(localName);
this.setXMLName(qName);
if (attributes != null) {
this.assignAttrs(attributes);
}
}
public Node setElement(Node child, int eTag, int nOccurrence) {
ChildReln validChild;
if (child != null) {
eTag = child.getClassTag();
}
if ((validChild = this.getChildReln(eTag)) == null || validChild.getMax() == -1) {
String aPropertyName = this.getAtom(eTag);
MsgFormatPos message = new MsgFormatPos(ResId.InvalidSetPropertyException);
message.format(this.getClassAtom());
message.format(aPropertyName);
throw new ExFull(message);
}
if (validChild.getOccurrence() == 4) {
String aPropertyName = this.getAtom(eTag);
throw new ExFull(new MsgFormat(ResId.InvalidSetOneOfException, aPropertyName));
}
if (validChild.getMax() <= nOccurrence) {
throw new ExFull(new IndexOutOfBoundsException(""));
}
if (child == null) {
Element existingChild = this.getElementLocal(eTag, true, nOccurrence, false, false);
if (existingChild != null) {
existingChild.remove();
}
this.makeNonDefault(false);
this.setDirty();
return null;
}
Node oldChild = this.locateChildByClass(child.getClassTag(), nOccurrence);
if (oldChild == child) {
return null;
}
if (nOccurrence > 0 && oldChild == null) {
this.getElement(child.getClassTag(), false, nOccurrence - 1, false, false);
}
boolean bCloned = false;
if (child.getXFAParent() != null) {
child = child.clone(this);
bCloned = true;
}
if (oldChild == null) {
if (!bCloned) {
this.appendChild(child, false);
}
} else {
this.insertChild(child, oldChild, false);
oldChild.remove();
}
if (child instanceof Element) {
((Element)child).makeNonDefault(true);
}
this.makeNonDefault(false);
this.setDirty();
return child;
}
final void setFirstChild(Node child) {
this.mFirstXMLChild = child;
}
final void setID(String sId) {
this.setAttribute(new StringAttr("id", sId), XFA.IDTAG);
}
public final void setIsIndexed(boolean bIsIndexed) {
this.mbIsIndexed = bIsIndexed;
}
public final void setLineNumber(int nLineNumber) {
this.mnLineNumber = nLineNumber;
}
public void setLocalName(String name) {
if (this.mLocalName != name) {
String string = this.mLocalName = name != null ? name.intern() : null;
if (this instanceof DualDomNode) {
((Element)((DualDomNode)this).getXmlPeer()).mLocalName = this.mLocalName;
}
}
this.setDirty();
}
public final void setModel(Model model) {
this.mModel = model;
}
@Override
public void setName(String name) {
this.setAttribute(new StringAttr("name", name), XFA.NAMETAG);
}
protected final void setNameSpaceURI(String uri, boolean bBypassPrefixChecks, boolean bApplyToChildren, boolean bRemovePrefix) {
boolean bScrubPrefix = bRemovePrefix;
this.mURI = uri;
if (this instanceof Model) {
((Element)((Model)this).getXmlPeer()).mURI = this.mURI;
}
if (!bBypassPrefixChecks) {
Attribute poDefaultNSAttr;
int index;
Attribute poNSAttr;
String aPrefix = this.getPrefix();
String aNameAtom = "xmlns";
if (aPrefix != "") {
int nAttrs = this.getNumAttrs();
for (int i = 0; i < nAttrs; ++i) {
Attribute poAttr = this.getAttr(i);
if (poAttr.isNameSpaceAttr() || poAttr.getPrefix() != aPrefix) continue;
this.getXmlPeerElement().mAttrs[i] = poAttr.newAttribute(this.mURI, poAttr.getLocalName(), poAttr.getQName(), poAttr.getAttrValue(), false);
}
aNameAtom = aPrefix;
}
if ((index = this.findAttr(null, aNameAtom)) != -1 && (poNSAttr = this.getAttr(index)).isNameSpaceAttr()) {
if (bScrubPrefix) {
this.removeAttr(index);
} else {
this.setAttribute(poNSAttr.getNS(), poNSAttr.getQName(), poNSAttr.getLocalName(), this.mURI, false);
}
}
if (bScrubPrefix && aNameAtom != "xmlns" && (index = this.findAttr(null, "xmlns")) != -1 && (poDefaultNSAttr = this.getAttr(index)).isNameSpaceAttr()) {
this.removeAttr(index);
}
if (bScrubPrefix) {
this.mQName = this.mLocalName;
if (this instanceof Model) {
((Element)((Model)this).getXmlPeer()).mQName = this.mQName;
}
}
if (bApplyToChildren) {
for (Node poChild = this.getFirstXFAChild(); poChild != null; poChild = poChild.getNextXFASibling()) {
if (!(poChild instanceof Element)) continue;
((Element)poChild).setNameSpaceURI(this.mURI, bBypassPrefixChecks, bApplyToChildren, bRemovePrefix);
}
}
}
this.setDirty();
}
public final void setNS(String sNS) {
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Element)) continue;
Element e = (Element)child;
e.setNS(sNS);
if (e.mURI != null) continue;
e.mURI = sNS;
}
if (this.mURI == null) {
this.mURI = sNS;
}
}
final void setNS(Model model) {
String sNS = null;
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof Element)) continue;
Element e = (Element)child;
if (sNS == null) {
sNS = model.getNS();
}
e.setNS(sNS);
if (e.mURI != null) continue;
e.mURI = sNS;
}
if (this.mURI == null) {
if (sNS == null) {
sNS = model.getNS();
}
this.mURI = sNS;
}
}
final void setNSPrefix(String aPrefix, String aNS) {
if (aPrefix != "" && aNS != "") {
String sAttr = "xmlns:" + aPrefix;
this.setAttribute("", sAttr, aPrefix, aNS);
}
}
public Node setOneOfChild(Node child) {
ChildReln validChild;
if (child != null && ((validChild = this.getChildReln(child.getClassTag())) == null || validChild.getOccurrence() != 4)) {
throw new ExFull(new MsgFormat(ResId.InvalidSetOneOfException, child.getClassAtom()));
}
Node otherChild = this.getFirstXFAChild();
while (otherChild != null) {
Node nextSibling = otherChild.getNextXFASibling();
if (otherChild == child) {
child = null;
} else {
ChildReln childReln = this.getChildReln(otherChild.getClassTag());
if (childReln.getOccurrence() == 4) {
otherChild.remove();
break;
}
}
otherChild = nextSibling;
}
if (child != null) {
if (child.getXFAParent() != null) {
child = child.clone(this);
} else {
this.appendChild(child);
}
}
this.makeNonDefault(false);
return child;
}
public final void setProperty(Object property, int ePropertyTag) {
boolean bElement = false;
if (property == null) {
if (this.isValidAttr(ePropertyTag, false, null)) {
bElement = false;
} else if (this.isValidElement(ePropertyTag, false)) {
bElement = true;
}
} else if (property instanceof Element) {
bElement = true;
} else if (property instanceof Attribute) {
bElement = false;
} else {
return;
}
if (bElement) {
Element node = (Element)property;
this.setElement(node, ePropertyTag, 0);
} else {
Attribute attr = (Attribute)property;
this.setAttribute(attr, ePropertyTag);
}
}
public final void setProperty(Object property, String propertyName) {
String aPropertyName = propertyName.intern();
int eTag = XFA.getTag(aPropertyName);
if (eTag == XFA.INVALID_ELEMENT) {
MsgFormatPos message = new MsgFormatPos(ResId.InvalidSetPropertyException);
message.format(this.getClassName());
message.format(propertyName);
throw new ExFull(message);
}
this.setProperty(property, eTag);
}
public final void setQName(String name) {
if (this.mQName != name) {
String string = this.mQName = name != null ? name.intern() : null;
if (this instanceof DualDomNode) {
((Element)((DualDomNode)this).getXmlPeer()).mQName = this.mQName;
}
}
this.setDirty();
}
public void setSaveXMLSaveTransient(boolean bSaveTransient) {
this.mbSaveXMLSaveTransient = bSaveTransient;
}
public final void setTransparent(boolean isTransparent) {
this.mbTransparent = isTransparent;
}
protected final void updateAttribute(Attribute newValue) {
int index = this.findAttr(null, newValue.getLocalName());
if (newValue.getLocalName() == "rid") {
newValue = newValue.newAttribute("urn:oasis:names:tc:xliff:document:1.1", "rid", "xliff:rid", newValue.getAttrValue());
}
Element e = this.getXmlPeerElement();
if (index != -1) {
if (this.getOwnerDocument() != null && this.getOwnerDocument().isId(e.getNSInternal(), e.getLocalName(), newValue.getNS(), newValue.getLocalName())) {
throw new ExFull(ResId.DOM_MODIFY_ID_ERR);
}
e.mAttrs[index] = newValue;
} else {
e.extendAttributes(newValue);
}
}
protected final void updateAttributeInternal(Attribute newValue) {
int index = this.findAttr(null, newValue.getLocalName());
this.getXmlPeerElement().mAttrs[index] = newValue;
}
@Override
public void updateFromPeer(Object peer, int eventType, String arg1, Object arg2) {
if (eventType != 3) {
this.makeNonDefault(false);
}
super.updateFromPeer(peer, eventType, arg1, arg2);
}
private Element filterClone(NodeList keepNodes) {
ArrayNodeList ancestors = new ArrayNodeList();
ancestors.append(this);
int nKeepNodes = keepNodes.length();
for (int i = 0; i < nKeepNodes; ++i) {
for (Element keepNodesParent = ((Node)keepNodes.item((int)i)).getXFAParent(); keepNodesParent != null; keepNodesParent = keepNodesParent.getXFAParent()) {
boolean found = false;
int nAncestors = ancestors.length();
for (int j = 0; j < nAncestors; ++j) {
Obj ancestor = ancestors.item(j);
if (keepNodesParent != ancestor) continue;
found = true;
}
if (found) continue;
ancestors.append(keepNodesParent);
}
}
NodeList leaf = (NodeList)keepNodes.clone();
return this.cloneHelper(null, true, ancestors, leaf);
}
private final void updateModelAndDocument(Node newChild) {
if (newChild instanceof Element) {
Element e = (Element)newChild;
e.setModel(this.getModel());
e.setDocument(this.getOwnerDocument());
for (Node child = e.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
this.updateModelAndDocument(child);
}
}
}
@Override
final boolean useNameInSOM() {
int eType;
Element oParent = this.getXFAParent();
if (oParent != null && ((eType = oParent.getSchemaType(this.getClassTag())) == 0 || eType == 2 || eType == 3)) {
return false;
}
return this.getName() != "";
}
public boolean processTextChildrenDuringParse() {
return this.getClassTag() != XFA.INVALID_ELEMENT;
}
private boolean pruneNameSpaceDefn(Element element, String sNSAlias, String sNS) {
int len = element.getNumAttrs();
int nAttrToRemove = -1;
for (int i = 0; i < len; ++i) {
Attribute attr = element.getAttr(i);
if (attr.getNS() != null && attr.getNS().equals(sNS)) {
return true;
}
if (!attr.getQName().equals(sNSAlias)) continue;
nAttrToRemove = i;
}
for (Node child = element.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
if (!(child instanceof Element) || !this.pruneNameSpaceDefn((Element)child, sNSAlias, sNS)) continue;
return true;
}
if (nAttrToRemove > -1) {
element.removeAttr(nAttrToRemove);
}
return false;
}
@Override
protected boolean compareVersions(Node rollbackElement, Node container, Node.ChangeLogger changeLogger, Object userData) {
int eType;
Node child;
boolean bMatches = true;
if (this.getClassTag() != rollbackElement.getClassTag()) {
if (changeLogger != null) {
if (this.isContainer()) {
changeLogger.logChildChange(container, this, userData);
} else {
changeLogger.logPropChange(container, Element.getPropName(this.getXFAParent(), XFA.INVALID_ELEMENT), Element.getNodeAsXML(this), userData);
}
}
return false;
}
assert (rollbackElement instanceof Element);
Element rollback = (Element)rollbackElement;
Node containerNode = this.isContainer() ? this : container;
SchemaPairs attrs = this.getNodeSchema().getValidAttributes();
if (attrs != null) {
for (int i = 0; i < attrs.size(); ++i) {
int eTag = attrs.key(i);
if (this.compareVersionsAttrHelper(rollback, eTag)) continue;
bMatches = false;
if (changeLogger == null) continue;
changeLogger.logPropChange(containerNode, Element.getPropName(this, eTag), this.getAttribute(eTag).getAttrValue(), userData);
}
}
if (!bMatches && changeLogger == null) {
return false;
}
SchemaPairs children = this.getNodeSchema().getValidChildren();
boolean bSchemaDefinesValidOneOf = false;
if (children != null) {
int nChildren = children.size();
for (int i = 0; i < nChildren; ++i) {
int eTag = children.key(i);
ChildReln childR = (ChildReln)children.value(i);
if (childR.getOccurrence() == 4) {
bSchemaDefinesValidOneOf = true;
continue;
}
if (childR.getMax() == -1) continue;
long nMax = childR.getMax();
for (int nOccurrenceIndex = 0; nOccurrenceIndex < (int)nMax; ++nOccurrenceIndex) {
Node thisChild = this.getNode(eTag, nOccurrenceIndex);
Node rollbackChild = rollback.getNode(eTag, nOccurrenceIndex);
if (thisChild == null && rollbackChild == null) break;
if (thisChild == null) {
thisChild = this.defaultElement(eTag, nOccurrenceIndex);
}
if (rollbackChild == null) {
rollbackChild = rollback.defaultElement(eTag, nOccurrenceIndex);
}
if (thisChild == null || rollbackChild == null) {
bMatches = false;
if (changeLogger == null) break;
if (thisChild == null) {
changeLogger.logPropChange(containerNode, Element.getPropName((Element)rollbackChild, XFA.INVALID_ELEMENT), "", userData);
break;
}
changeLogger.logPropChange(containerNode, Element.getPropName(this, XFA.INVALID_ELEMENT), Element.getNodeAsXML(thisChild), userData);
break;
}
bMatches &= thisChild.compareVersions(rollbackChild, containerNode, changeLogger, userData);
}
if (bMatches || changeLogger != null) continue;
return false;
}
}
if (bSchemaDefinesValidOneOf) {
Node rollbackOneOf;
Node sourceOneOf = this.getOneOfChild(false, true);
if (sourceOneOf == null != ((rollbackOneOf = rollback.getOneOfChild(false, true)) == null)) {
bMatches = false;
if (changeLogger != null) {
if (sourceOneOf == null) {
changeLogger.logPropChange(containerNode, Element.getPropName((Element)rollbackOneOf, XFA.INVALID_ELEMENT), "", userData);
} else {
changeLogger.logPropChange(containerNode, Element.getPropName(this, XFA.INVALID_ELEMENT), Element.getNodeAsXML(sourceOneOf), userData);
}
}
} else if (sourceOneOf != null) {
bMatches &= sourceOneOf.compareVersions(rollbackOneOf, containerNode, changeLogger, userData);
}
if (!bMatches && changeLogger == null) {
return false;
}
}
ArrayNodeList sourceChildList = new ArrayNodeList();
ArrayNodeList rollbackChildList = new ArrayNodeList();
boolean bFoundSourceOneOf = false;
boolean bFoundRollbackOneOf = false;
for (child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
eType = this.getSchemaType(child.getClassTag());
if (eType == 4) {
sourceChildList.append(child);
continue;
}
if (eType == 3) {
if (!bFoundSourceOneOf) {
bFoundSourceOneOf = true;
continue;
}
sourceChildList.append(child);
continue;
}
if (eType != 5) continue;
sourceChildList.append(child);
}
for (child = rollback.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
eType = this.getSchemaType(child.getClassTag());
if (eType == 4) {
rollbackChildList.append(child);
continue;
}
if (eType == 3) {
if (!bFoundRollbackOneOf) {
bFoundRollbackOneOf = true;
continue;
}
rollbackChildList.append(child);
continue;
}
if (eType != 5) continue;
rollbackChildList.append(child);
}
bMatches &= this.compareVersionsListHelper(sourceChildList, rollbackChildList, containerNode, changeLogger, userData);
ArrayList<String> sourcePIs = new ArrayList<String>();
ArrayList<String> rollbackPIs = new ArrayList<String>();
this.getPI(sourcePIs, true);
rollback.getPI(rollbackPIs, true);
return bMatches &= this.compareVersionsPIHelper(sourcePIs, rollbackPIs, containerNode, changeLogger, userData);
}
protected boolean compareVersionsCanonically(Node rollbackElement, Node container, Node.ChangeLogger changeLogger, Object userData) {
String sCanonicalSource = "";
String sCanonicalRollback = "";
Canonicalize c = new Canonicalize(this, false, true);
byte[] buffer = c.canonicalize(4, null);
try {
sCanonicalSource = new String(buffer, "UTF-8");
}
catch (UnsupportedEncodingException ex) {
// empty catch block
}
Canonicalize cRollBack = new Canonicalize(rollbackElement, false, true);
buffer = cRollBack.canonicalize(4, null);
try {
sCanonicalRollback = new String(buffer, "UTF-8");
}
catch (UnsupportedEncodingException ex) {
// empty catch block
}
if (!sCanonicalSource.equals(sCanonicalRollback)) {
if (changeLogger != null) {
String sPropName = this.getModel().getSchema().getAtom(XFA.XMLMULTISELECTNODETAG);
changeLogger.logPropChange(container, sPropName, sCanonicalSource, userData);
}
return false;
}
return true;
}
protected boolean compareVersionsAttrHelper(Element oRollback, int eTag) {
if (eTag == XFA.USETAG || eTag == XFA.USEHREFTAG) {
return true;
}
if (eTag == XFA.CHECKSUMTAG) {
return true;
}
return this.compareVersionsAttr(oRollback, eTag);
}
public boolean compareVersionsAttr(Element oRollback, int eTag) {
String aAttrName = this.getAtom(eTag);
Attribute sourceAttr = this.getAttributeByName(aAttrName, true);
Attribute rollbackAttr = oRollback.getAttributeByName(aAttrName, true);
if (sourceAttr == null && rollbackAttr == null) {
return true;
}
String sSourceValue = sourceAttr != null ? sourceAttr.getAttrValue() : this.getAttribute(eTag, false, false).getAttrValue();
String sRollbackValue = rollbackAttr != null ? rollbackAttr.getAttrValue() : oRollback.getAttribute(eTag, false, false).getAttrValue();
return sSourceValue.equals(sRollbackValue);
}
private boolean compareVersionsListHelper(NodeList sourceList, NodeList rollbackList, Node container, Node.ChangeLogger changeLogger, Object userData) {
boolean bMatches = true;
int nSourceChildren = sourceList.length();
int nRollbackChildren = rollbackList.length();
for (int i = 0; i < nSourceChildren || i < nRollbackChildren; ++i) {
if (i >= nSourceChildren) {
bMatches = false;
if (changeLogger != null) {
changeLogger.logChildChange(container, (Node)rollbackList.item(i), userData);
}
} else if (i >= nRollbackChildren) {
bMatches = false;
if (changeLogger != null) {
changeLogger.logChildChange(container, (Node)sourceList.item(i), userData);
}
} else {
Node sourceChild = (Node)sourceList.item(i);
Node rollbackChild = (Node)rollbackList.item(i);
bMatches &= sourceChild.compareVersions(rollbackChild, container, changeLogger, userData);
}
if (bMatches || changeLogger != null) continue;
return false;
}
return bMatches;
}
private boolean compareVersionsPIHelper(List<String> sourcePIs, List<String> rollbackPIs, Node container, Node.ChangeLogger changeLogger, Object userData) {
boolean bMatches = true;
int nSourcePIs = sourcePIs.size();
int nRollbackPIs = rollbackPIs.size();
for (int i = 0; i < nSourcePIs || i < nRollbackPIs; ++i) {
if (i >= nSourcePIs) {
bMatches = false;
if (changeLogger != null) {
changeLogger.logPropChange(container, this.getPIName(this, rollbackPIs.get(i)), "", userData);
}
} else if (i >= nRollbackPIs) {
bMatches = false;
if (changeLogger != null) {
changeLogger.logPropChange(container, this.getPIName(this, sourcePIs.get(i)), Element.getPIAsXML(sourcePIs.get(i)), userData);
}
} else if (!sourcePIs.get(i).equals(rollbackPIs.get(i))) {
bMatches = false;
if (changeLogger != null) {
changeLogger.logPropChange(container, this.getPIName(this, sourcePIs.get(i)), Element.getPIAsXML(sourcePIs.get(i)), userData);
}
}
if (bMatches || changeLogger != null) continue;
return false;
}
return bMatches;
}
public void connectPeerToDocument() {
DualDomNode dualDomNode = (DualDomNode)((Object)this);
assert (dualDomNode.getXmlPeer() != null);
this.connectPeerToParent();
Element parent = this.getXFAParent();
Node peer = parent != null ? ((DualDomNode)((Object)parent)).getXmlPeer() : dualDomNode.getXmlPeer();
Document doc = peer.getOwnerDocument();
Element oldRoot = doc.getDocumentElement();
if (oldRoot != null) {
doc.removeChild(oldRoot);
}
doc.appendChild(peer);
}
protected void connectPeerToParent() {
assert (this instanceof DualDomNode);
Element domPeer = (Element)((DualDomNode)((Object)this)).getXmlPeer();
for (Node child = this.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
if (!(child instanceof DualDomNode)) continue;
assert (child instanceof Element);
Node domChild = ((DualDomNode)((Object)child)).getXmlPeer();
Element domParent = domChild.getXMLParent();
if (domParent == null) {
((Element)child).connectPeerToParent();
continue;
}
if (domParent == domPeer) continue;
domPeer.appendChild(domChild);
}
Element parent = this.getXFAParent();
if (parent != null) {
assert (!(domPeer instanceof DataModel.AttributeWrapper));
Element destination = (Element)((DualDomNode)((Object)parent)).getXmlPeer();
if (destination != domPeer.getXMLParent()) {
destination.appendChild(domPeer);
}
}
}
public final void setIsDataWindowRoot(boolean bIsRoot) {
this.mbIsDataWindowRoot = bIsRoot;
}
public Key constructKey(List<String> nodeAddressList, Node namespaceContextNode) {
ArrayList<Key> keyList = new ArrayList<Key>();
this.constructKeys(nodeAddressList, namespaceContextNode, keyList);
if (keyList.size() > 0) {
return keyList.get(0);
}
return new Key();
}
public void constructKeys(List<String> nodeAddressList, Node namespaceContextNode, List<Key> keys) {
XPath evaluator = Element.getXPathFactory().newXPath();
org.w3c.dom.Node contextNode = DOM.attach(this);
if (namespaceContextNode != null) {
evaluator.setNamespaceContext(new NamespaceContextImpl(DOM.attach(namespaceContextNode)));
}
for (int i = 0; i < nodeAddressList.size(); ++i) {
int j;
org.w3c.dom.NodeList nodeList;
try {
nodeList = (org.w3c.dom.NodeList)evaluator.evaluate(nodeAddressList.get(i), contextNode, XPathConstants.NODESET);
}
catch (XPathExpressionException ex) {
throw new ExFull(ResId.XPATH_ERROR, ex.getMessage());
}
if (i == 0) {
for (j = 0; j < nodeList.getLength(); ++j) {
keys.add(new Key(nodeAddressList.size()));
}
} else if (nodeList.getLength() < keys.size()) {
Element.trimToSize(keys, nodeList.getLength());
}
for (j = 0; j < nodeList.getLength() && j < keys.size(); ++j) {
org.w3c.dom.Node node = nodeList.item(j);
if (node instanceof Attr) {
keys.get(j).appendValue(node.getNodeValue());
continue;
}
if (node instanceof org.w3c.dom.Element) {
org.w3c.dom.Node text = node.getFirstChild();
if (text == null) {
Element.trimToSize(keys, j);
continue;
}
keys.get(j).appendValue(text.getNodeValue());
continue;
}
Element.trimToSize(keys, j);
}
}
}
private static <T> void trimToSize(List<T> list, int length) {
while (list.size() > length) {
list.remove(list.size() - 1);
}
}
public static void explodeQName(String aQName, StringHolder aPrefix, StringHolder aLocalName) {
int nOffset = aQName.indexOf(58);
if (nOffset > -1) {
aPrefix.value = aQName.substring(0, nOffset).intern();
aLocalName.value = aQName.substring(nOffset + 1).intern();
} else {
aPrefix.value = "";
aLocalName.value = aQName;
}
}
public String resolvePrefix(String aPrefix) {
int nSize = this.getNumAttrs();
for (int nIndex = 0; nIndex < nSize; ++nIndex) {
Attribute attr = this.getAttr(nIndex);
if (!attr.isNameSpaceAttr() || aPrefix != attr.getLocalName()) continue;
return attr.getAttrValue();
}
if (this.getXFAParent() == null) {
return "";
}
return this.getXFAParent().resolvePrefix(aPrefix);
}
private static class ElementScriptDynamicPropObj
extends ScriptDynamicPropObj {
private final String msGetFunc;
private final String msSetFunc;
ElementScriptDynamicPropObj(String sGetFunc, String sSetFunc, int nXFAVersion, int nAvailability) {
super(nXFAVersion, nAvailability);
this.msGetFunc = sGetFunc;
this.msSetFunc = sSetFunc;
}
@Override
public boolean invokeGetProp(Obj scriptThis, Arg retValue, String sPropertyName) {
if (this.msGetFunc == "locateOneOf") {
return ElementScript.locateOneOf(scriptThis, retValue, sPropertyName);
}
if (this.msGetFunc == "locatePropPeek") {
return ElementScript.locatePropPeek(scriptThis, retValue, sPropertyName);
}
if (this.msGetFunc == "locateProp") {
return ElementScript.locateProp(scriptThis, retValue, sPropertyName);
}
assert (false);
return false;
}
@Override
public boolean invokeSetProp(Obj scriptThis, Arg propertyValue, String sPropertyName) {
if (this.msSetFunc == "setProp") {
return ElementScript.setProp(scriptThis, propertyValue, sPropertyName);
}
assert (false);
return false;
}
@Override
public boolean hasSetter() {
return this.msSetFunc != null;
}
}
public static enum ReplaceContent {
None,
XFAContent,
AllContent;
private ReplaceContent() {
}
}
public static interface DualDomNode {
public Node getXmlPeer();
public void setXmlPeer(Node var1);
}
}