FormModel.java 242 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 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.xfa.form;

import com.adobe.xfa.AppModel;
import com.adobe.xfa.ArrayNodeList;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Chars;
import com.adobe.xfa.ChildReln;
import com.adobe.xfa.Comment;
import com.adobe.xfa.DOMSaveOptions;
import com.adobe.xfa.Delta;
import com.adobe.xfa.DependencyTracker;
import com.adobe.xfa.Dispatcher;
import com.adobe.xfa.Document;
import com.adobe.xfa.Element;
import com.adobe.xfa.EnumAttr;
import com.adobe.xfa.EnumValue;
import com.adobe.xfa.EventManager;
import com.adobe.xfa.EventPseudoModel;
import com.adobe.xfa.Generator;
import com.adobe.xfa.HostPseudoModel;
import com.adobe.xfa.Int;
import com.adobe.xfa.ListBase;
import com.adobe.xfa.LogMessenger;
import com.adobe.xfa.Model;
import com.adobe.xfa.ModelPeer;
import com.adobe.xfa.Node;
import com.adobe.xfa.NodeList;
import com.adobe.xfa.NodeSchema;
import com.adobe.xfa.Obj;
import com.adobe.xfa.Packet;
import com.adobe.xfa.ProcessingInstruction;
import com.adobe.xfa.ProtoableNode;
import com.adobe.xfa.RichTextNode;
import com.adobe.xfa.SOMParser;
import com.adobe.xfa.Schema;
import com.adobe.xfa.SchemaPairs;
import com.adobe.xfa.ScriptHandler;
import com.adobe.xfa.ScriptTable;
import com.adobe.xfa.StringAttr;
import com.adobe.xfa.TextNode;
import com.adobe.xfa.XFA;
import com.adobe.xfa.XFAList;
import com.adobe.xfa.XMLMultiSelectNode;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.content.ExDataValue;
import com.adobe.xfa.content.TextValue;
import com.adobe.xfa.data.DataModel;
import com.adobe.xfa.data.DataNode;
import com.adobe.xfa.data.DataWindow;
import com.adobe.xfa.form.CalculateDispatcher;
import com.adobe.xfa.form.ExecuteDispatcher;
import com.adobe.xfa.form.FormChoiceListField;
import com.adobe.xfa.form.FormDataListener;
import com.adobe.xfa.form.FormExclGroup;
import com.adobe.xfa.form.FormField;
import com.adobe.xfa.form.FormInstanceManager;
import com.adobe.xfa.form.FormItemsDataListener;
import com.adobe.xfa.form.FormListener;
import com.adobe.xfa.form.FormModelScript;
import com.adobe.xfa.form.FormSchema;
import com.adobe.xfa.form.FormSubform;
import com.adobe.xfa.form.FormSubformSet;
import com.adobe.xfa.form.ScriptRunAtDispatcher;
import com.adobe.xfa.form.SignDispatcher;
import com.adobe.xfa.form.SubmitDispatcher;
import com.adobe.xfa.form.ValidateDispatcher;
import com.adobe.xfa.service.storage.XMLStorage;
import com.adobe.xfa.template.Items;
import com.adobe.xfa.template.TemplateModel;
import com.adobe.xfa.template.Value;
import com.adobe.xfa.template.containers.Container;
import com.adobe.xfa.template.containers.Draw;
import com.adobe.xfa.template.containers.ExclGroup;
import com.adobe.xfa.template.containers.Field;
import com.adobe.xfa.template.containers.PageArea;
import com.adobe.xfa.template.containers.PageSet;
import com.adobe.xfa.template.containers.Subform;
import com.adobe.xfa.template.containers.SubformSet;
import com.adobe.xfa.ut.Base64;
import com.adobe.xfa.ut.BooleanHolder;
import com.adobe.xfa.ut.ExFull;
import com.adobe.xfa.ut.IntegerHolder;
import com.adobe.xfa.ut.LcData;
import com.adobe.xfa.ut.MsgFormat;
import com.adobe.xfa.ut.MsgFormatPos;
import com.adobe.xfa.ut.ObjectHolder;
import com.adobe.xfa.ut.Peer;
import com.adobe.xfa.ut.PictureFmt;
import com.adobe.xfa.ut.ResId;
import com.adobe.xfa.ut.StringHolder;
import com.adobe.xfa.ut.StringUtils;
import com.adobe.xfa.ut.trace.Trace;
import com.adobe.xfa.ut.trace.TraceHandler;
import com.adobe.xfa.ut.trace.TraceTimer;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import org.xml.sax.Attributes;

public class FormModel
extends Model {
    private static final ConnectHandler mConnectExportHandler = new ConnectHandler(){

        @Override
        public boolean handleConnect(Node formNode, String sConnectionRootRef, String sConnectRef, String sConnectPicture, Object handlerData, ObjectHolder<DataNode> ioRecursingData) {
            Model formModel = formNode.getModel();
            assert (formModel != null);
            AppModel appModel = (AppModel)formModel.getXFAParent();
            DataNode dataNode = null;
            DataNode connectionDataNode = (DataNode)appModel.resolveNode(sConnectionRootRef, false, false, true);
            assert (connectionDataNode != null);
            DataNode parentNode = (DataNode)ioRecursingData.value;
            NodeList nodes = parentNode != null ? parentNode.resolveNodes(sConnectRef, true, false, true) : connectionDataNode.resolveNodes(sConnectRef, true, false, true);
            boolean bMultiple = FormModel.isSomMultiple(sConnectRef);
            int nLen = nodes.length();
            for (int i = 0; i < nLen; ++i) {
                Node resolvedNode = (Node)nodes.item(i);
                if (bMultiple && resolvedNode.isMapped() || dataNode != null) continue;
                dataNode = (DataNode)resolvedNode;
                break;
            }
            if (dataNode == null) {
                DataModel dataModel = DataModel.getDataModel(appModel, false, false);
                boolean bUseDV = FormModel.useDV(formNode);
                dataNode = parentNode != null ? (DataNode)dataModel.resolveRef(sConnectRef, parentNode, bUseDV, false) : (DataNode)dataModel.resolveRef(sConnectRef, connectionDataNode, bUseDV, false);
            }
            if (dataNode != null) {
                if (dataNode.getIsDDPlaceholder()) {
                    dataNode.setIsDDPlaceholder(false);
                }
                if (formNode instanceof FormField) {
                    ((FormField)formNode).setDataNode(dataNode, true, false, sConnectPicture, true);
                    ((FormModel)formModel).consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                } else if (formNode instanceof FormExclGroup) {
                    ((FormExclGroup)formNode).setDataNode(dataNode, true, false);
                    ((FormModel)formModel).consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                } else if (formNode instanceof FormSubform) {
                    ((FormModel)formModel).consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                    ioRecursingData.value = dataNode;
                }
            }
            return true;
        }
    };
    private static final ConnectHandler mConnectImportHandler = new ConnectHandler(){

        @Override
        public boolean handleConnect(Node formNode, String sConnectionRootRef, String sConnectRef, String sConnectPicture, Object handlerData, ObjectHolder<DataNode> ioRecursingData) {
            FormModel formModel = (FormModel)formNode.getModel();
            assert (formModel != null);
            AppModel appModel = formNode.getModel().getAppModel();
            DataNode parentNode = (DataNode)ioRecursingData.value;
            String sDataRef = sConnectRef;
            boolean bMultiple = FormModel.isSomMultiple(sDataRef);
            NodeList resolvedDataNodes = parentNode != null ? parentNode.resolveNodes(sDataRef, true, false, true) : appModel.resolveNodes(sDataRef, true, false, true);
            if (resolvedDataNodes.length() != 0) {
                DataNode dataNode = null;
                for (int i = 0; i < resolvedDataNodes.length(); ++i) {
                    DataNode item = (DataNode)resolvedDataNodes.item(i);
                    if (bMultiple && item.isMapped()) continue;
                    dataNode = item;
                    break;
                }
                if (dataNode != null) {
                    if (formNode instanceof FormField) {
                        ((FormField)formNode).setDataNode(dataNode, false, false, sConnectPicture, false);
                        formModel.consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                    } else if (formNode instanceof FormExclGroup) {
                        ((FormExclGroup)formNode).setDataNode(dataNode, false, false);
                        formModel.consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                    } else if (formNode instanceof FormSubform) {
                        formModel.consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                        ioRecursingData.value = dataNode;
                    }
                    if (formNode instanceof Container) {
                        ((FormModel)formNode.getModel()).setConnectionDataContextInfo((Container)formNode, dataNode);
                    }
                }
            }
            return true;
        }
    };
    private static final ConnectHandler mConnectImportPermCheckHandler = new ConnectHandler(){

        @Override
        public boolean handleConnect(Node formNode, String sConnectionRootRef, String sConnectRef, String sConnectPicture, Object handlerData, ObjectHolder<DataNode> ioRecursingData) {
            assert (handlerData != null);
            BooleanHolder overallResult = (BooleanHolder)handlerData;
            AppModel appModel = formNode.getModel().getAppModel();
            Node parentNode = (Node)ioRecursingData.value;
            String sDataRef = sConnectRef;
            boolean bMultiple = FormModel.isSomMultiple(sDataRef);
            NodeList resolvedDataNodes = parentNode != null ? parentNode.resolveNodes(sDataRef, true, false, true) : appModel.resolveNodes(sDataRef, true, false, true);
            if (resolvedDataNodes.length() != 0) {
                DataNode dataNode = null;
                for (int i = 0; i < resolvedDataNodes.length(); ++i) {
                    DataNode item = (DataNode)resolvedDataNodes.item(i);
                    if (bMultiple && item.isMapped()) continue;
                    dataNode = item;
                    break;
                }
                if (dataNode != null) {
                    if (formNode instanceof FormSubform) {
                        ioRecursingData.value = dataNode;
                    }
                    if (!formNode.checkPerms() || !formNode.checkAncestorPerms()) {
                        overallResult.value = false;
                    }
                }
            }
            return overallResult.value;
        }
    };
    private static final FormSchema gsFormSchema = new FormSchema();
    static final int XFAEVENTTYPE_EVENTS = 1;
    static final int XFAEVENTTYPE_CALCULATE = 2;
    static final int XFAEVENTTYPE_VALIDATE = 4;
    static final int XFAEVENTTYPE_ALL = 7;
    private static final int CYCLE_MAX = 10;
    private static final Boolean UPDATE_DATA = true;
    private boolean mbWeightedData;
    private boolean mbAdjustData;
    private boolean mbEmptyMerge;
    private boolean mbMergeComplete = true;
    private boolean mbAllowNewNodes;
    private boolean mbExchangingDataWithServer;
    private boolean mbRegisterNewEvents = true;
    private boolean mbValidateBeforeSubmit;
    private boolean mbValidateBeforeExecute;
    private DataModel mDataModel;
    private TemplateModel mTemplateModel;
    private DataNode mStartNode;
    private final List<DataNode> mGlobalDataNodes = new ArrayList<DataNode>();
    private final List<Element> mExplicitMatchNodes = new ArrayList<Element>();
    private int mnCalcEventId;
    private int mnValidateEventId;
    private int mnValidationStateEventId;
    private boolean mbRecursiveIndexChange;
    private boolean mbEnableIncrementalMerge = true;
    private boolean mbWasIncrementalMerge;
    private final List<Node> mPendingCalculateNodes = new ArrayList<Node>();
    private int mnNextPendingCalculateNode;
    private final List<Node> mPendingValidateNodes = new ArrayList<Node>();
    private int mnNextPendingValidateNode;
    private final List<Node> mNewValidateNodes = new ArrayList<Node>();
    private Validate mValidate;
    private Validate mDefaultValidate;
    private final List<Container> moValidationStateChanges = new ArrayList<Container>();
    private int mnValidationRecursionDepth;
    private final List<LayoutContentInfo> mLayoutContent = new ArrayList<LayoutContentInfo>();
    private Subform mRootSubform;
    private FormSubform mRootFormSubform;
    private Element mCurrentPageSet;
    private DataNode mDataDescription;
    private String msLocale = "";
    private boolean mbMatchDescendantsOnly = false;
    private String msSubmitURL;
    private String[] mExcludeList;
    private int meRunAtSetting = 1080754178;
    private ServerExchange mServerExchange;
    private Submit mSubmit;
    private Execute mExecute;
    private HostPseudoModel mHostPseudoModel;
    private EventPseudoModel mEventPseudoModel;
    private boolean mbIgnoreCalcEnabledFlag;
    private boolean mbIgnoreValidationsEnabledFlag;
    private String msConnectionName;
    private boolean mbConnectionMerge;
    private boolean mbFormStateUsage;
    private boolean mbFormStateRemoved;
    private boolean mbOverlayDataMergeUsage;
    private int mnPanel;
    private boolean mbIsXFAF;
    private FormField mActiveField;
    private FormField mPrevActiveField;
    private FormSubform mDeltasSubform;
    private boolean mbRestoreDeltas;
    private boolean mbForceRestore;
    private boolean mbIsCalculating;
    private boolean mbDisableRemerge = false;
    private boolean mbSkipCyclicAndDuplicateCheck = false;
    private boolean mbGlobalConsumption = true;
    private PostMergeHandler mPostMergeHandler;
    private Object mPostMergeHandlerClientData;
    List<Container> moContainersWithFormInfo = new ArrayList<Container>();
    private boolean mbIgnoreChecksum;
    private boolean mb_IsMergedXDP = false;
    static boolean mbXfaAcroDotGuard_3083363;

    private static boolean getConnectSOMStrings(Node node, String strConnectionName, int eUsage, StringHolder outConnectionRootRef, StringHolder outConnectRef, StringHolder sConnectPicture) {
        Element connectNode = null;
        if (node instanceof Field || node instanceof ExclGroup || node instanceof Subform) {
            connectNode = ((Container)node).getConnectNode(strConnectionName, eUsage, false);
        }
        if (connectNode != null) {
            TextNode textNode;
            Element picture;
            outConnectRef.value = connectNode.getAttribute(XFA.REFTAG).toString();
            outConnectionRootRef.value = "!connectionData." + strConnectionName;
            if (sConnectPicture != null && (picture = connectNode.getElement(XFA.PICTURETAG, true, 0, false, false)) != null && (textNode = picture.getText(true, false, false)) != null) {
                sConnectPicture.value = textNode.getValue();
            }
            return true;
        }
        return false;
    }

    static DataNode getDataNode(Node formNode) {
        if (null != formNode) {
            if (formNode instanceof FormField) {
                return ((FormField)formNode).getDataNode();
            }
            if (formNode instanceof FormChoiceListField) {
                return ((FormChoiceListField)formNode).getDataNode();
            }
            if (formNode instanceof FormSubform) {
                return ((FormSubform)formNode).getDataNode();
            }
            if (formNode instanceof FormExclGroup) {
                return ((FormExclGroup)formNode).getDataNode();
            }
        }
        return null;
    }

    public static FormModel getFormModel(AppModel appModel, boolean bCreateIfNotFound) {
        FormModel form = null;
        if (appModel != null) {
            TemplateModel template = null;
            for (Node child = appModel.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                if (child instanceof FormModel) {
                    form = (FormModel)child;
                    continue;
                }
                if (!(child instanceof TemplateModel)) continue;
                template = (TemplateModel)child;
            }
            if (bCreateIfNotFound && form == null && template != null) {
                FormModel newFormModel = new FormModel(appModel, null);
                newFormModel.setDocument(Document.createDocument(appModel));
                newFormModel.setXmlPeer(new ModelPeer(newFormModel.getDocument(), null, "http://www.xfa.org/schema/xfa-form/2.8/", "form", "form", null, newFormModel));
                appModel.notifyPeers(4, "form", newFormModel);
                return FormModel.getFormModel(appModel, false);
            }
        }
        return form;
    }

    static Element getMappedParent(Node formNode) {
        if (formNode == null) {
            return null;
        }
        Element parent = formNode.getXFAParent();
        if (parent == null) {
            return parent;
        }
        if (parent.isMapped()) {
            DataNode dataNode = FormModel.getDataNode(parent);
            if (dataNode == null) {
                return FormModel.getMappedParent(parent);
            }
            return parent;
        }
        return FormModel.getMappedParent(parent);
    }

    private static Schema getModelSchema() {
        return gsFormSchema;
    }

    static String getValidationMessage(Element validateNode, String aType) {
        return TemplateModel.getValidationMessage(validateNode, aType);
    }

    private static boolean incrementalMergeCheckDataDescription(Node dataDescriptionNode) {
        if (dataDescriptionNode instanceof Element) {
            String sModel;
            String sMaxOccur;
            boolean bVariableOccurrence;
            String sMinOccur;
            Element element = (Element)dataDescriptionNode;
            int nMinOccur = 1;
            int nMaxOccur = 1;
            int index = element.findAttr("http://ns.adobe.com/data-description/", "minOccur");
            if (index != -1 && !StringUtils.isEmpty(sMinOccur = element.getAttrVal(index))) {
                try {
                    nMinOccur = Integer.parseInt(sMinOccur);
                }
                catch (NumberFormatException ex) {
                    // empty catch block
                }
            }
            if ((index = element.findAttr("http://ns.adobe.com/data-description/", "maxOccur")) != -1 && !StringUtils.isEmpty(sMaxOccur = element.getAttrVal(index))) {
                try {
                    nMaxOccur = Integer.parseInt(sMaxOccur);
                }
                catch (NumberFormatException ex) {
                    // empty catch block
                }
            }
            boolean bl = bVariableOccurrence = nMinOccur != nMaxOccur || nMinOccur == -1 || nMaxOccur == -1;
            if (bVariableOccurrence) {
                return false;
            }
            index = element.findAttr("http://ns.adobe.com/data-description/", "model");
            if (index != -1 && ((sModel = element.getAttrVal(index)).equals("choice") || sModel.equals("unordered"))) {
                return false;
            }
            for (Node child = element.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                if (FormModel.incrementalMergeCheckDataDescription(child)) continue;
                return false;
            }
        }
        return true;
    }

    public static void recurseConnectOnNode(Node node, String strConnectionName, int eUsage, ConnectHandler handler, Object handlerData) {
        ObjectHolder<DataNode> recursingData = new ObjectHolder<DataNode>();
        FormModel.recurseConnectOnNodeHelper(node, strConnectionName, eUsage, handler, handlerData, recursingData);
    }

    private static boolean recurseConnectOnNodeHelper(Node node, String strConnectionName, int eUsage, ConnectHandler handler, Object handlerData, ObjectHolder<DataNode> recursingData) {
        StringHolder strConnectionRootRef = new StringHolder();
        StringHolder strConnectRef = new StringHolder();
        StringHolder strConnectPictureRef = new StringHolder();
        ObjectHolder<DataNode> tempioRecursingData = new ObjectHolder<DataNode>();
        boolean bContinue = true;
        for (Node child = node.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
            strConnectionRootRef.value = null;
            strConnectRef.value = null;
            strConnectPictureRef.value = "";
            tempioRecursingData.value = recursingData.value;
            if (child instanceof Container) {
                Container.FormInfo formInfo;
                if (FormModel.getConnectSOMStrings(child, strConnectionName, eUsage, strConnectionRootRef, strConnectRef, strConnectPictureRef)) {
                    bContinue = handler.handleConnect(child, strConnectionRootRef.value, strConnectRef.value, strConnectPictureRef.value, handlerData, tempioRecursingData);
                }
                if (bContinue && eUsage == 6225921 && (child instanceof FormSubform || child instanceof FormField || child instanceof FormExclGroup)) {
                    ((FormModel)child.getModel()).setDynamicProperties((Container)child, strConnectionName, false);
                }
                if (bContinue) {
                    bContinue = FormModel.recurseConnectOnNodeHelper(child, strConnectionName, eUsage, handler, handlerData, tempioRecursingData);
                }
                if ((formInfo = ((Container)child).getFormInfo()) != null) {
                    ((Container)child).setFormInfo(null);
                }
            }
            if (!bContinue) break;
        }
        return bContinue;
    }

    static void setValidationMessage(Element validateNode, String sMessage, String aType) {
        TemplateModel.setValidationMessage(validateNode, sMessage, aType);
    }

    static boolean isSomMultiple(String sSom) {
        if (sSom.indexOf(42) != -1) {
            return true;
        }
        if (sSom.contains(".[")) {
            return true;
        }
        if (sSom.contains(".(")) {
            return true;
        }
        return false;
    }

    public FormModel(Element parent, Node prevSibling) {
        super(parent, prevSibling, "http://www.xfa.org/schema/xfa-form/2.8/", "form", "form", "$form", XFA.FORMTAG, "form", FormModel.getModelSchema());
    }

    void addScriptDependency(Element node, Obj dependsOn, boolean bIsCalculate) {
        List<FormListener> listenerTable = null;
        if (node instanceof FormField) {
            listenerTable = ((FormField)node).getFormListeners(true);
        } else if (node instanceof FormExclGroup) {
            listenerTable = ((FormExclGroup)node).getFormListeners(true);
        } else if (node instanceof FormSubform) {
            listenerTable = ((FormSubform)node).getFormListeners(true);
        }
        if (listenerTable != null && dependsOn instanceof Obj) {
            FormListener listener = new FormListener(this, node, dependsOn, bIsCalculate);
            listenerTable.add(listener);
        }
    }

    @Override
    public void addUseNode(Element useNode) {
        if (this.isLoading() || this.mbAllowNewNodes || useNode.isContainer() || this.mTemplateModel == null || this.mTemplateModel.getLegacySetting(AppModel.XFA_LEGACY_V27_SCRIPTING)) {
            return;
        }
        super.addUseNode(useNode);
    }

    void addValidationStateChanged(Container container) {
        this.moValidationStateChanges.add(container);
    }

    @Override
    public void addUseHRefNode(Element useHRefNode) {
    }

    private void adjustData(Element formParent, Element dataParent) {
        for (Node formChild = formParent.getFirstXFAChild(); formChild != null; formChild = formChild.getNextXFASibling()) {
            Obj dataChild = null;
            boolean bAdjustChild = true;
            int eMergeType = this.mergeType(formChild, "", null);
            switch (eMergeType) {
                case 2031617: {
                    if (formChild instanceof FormSubform && ((FormSubform)formChild).isLayoutNode()) {
                        assert (false);
                        break;
                    }
                    if (formChild.isMapped()) {
                        dataChild = FormModel.getDataNode(formChild);
                    }
                    if (dataChild != null) {
                        if (dataParent == null) break;
                        boolean bMove = false;
                        if (dataParent != dataChild.getXFAParent()) {
                            bMove = true;
                        } else if (formParent instanceof FormSubformSet && -2144600063 == formParent.getEnum(XFA.RELATIONTAG)) {
                            bMove = true;
                        }
                        if (!bMove || dataChild.getClassTag() == XFA.DATAVALUETAG && ((DataNode)dataChild).isAttribute()) break;
                        dataParent.appendChild((Node)dataChild, true);
                        break;
                    }
                    dataChild = dataParent == null ? this.createDataNode((Container)formChild, this.mStartNode, eMergeType, false) : this.createDataNode((Container)formChild, dataParent, eMergeType, false);
                    this.bindNodes(formChild, (DataNode)dataChild, true);
                    this.consumeDataNode(null, (Node)dataChild, DatasetSelector.MAIN_DATASET);
                    break;
                }
                case 2031618: 
                case 2031619: 
                case 2031620: {
                    bAdjustChild = false;
                    break;
                }
            }
            if (!bAdjustChild || !formChild.isContainer()) continue;
            if (dataChild == null) {
                dataChild = dataParent;
            }
            if (formChild instanceof ExclGroup && dataChild.getClassTag() == XFA.DATAVALUETAG) continue;
            this.adjustData((Element)formChild, (Element)dataChild);
        }
    }

    public boolean allowNewNodes(boolean bAllow) {
        boolean bOldValue = this.mbAllowNewNodes;
        this.mbAllowNewNodes = bAllow;
        return bOldValue;
    }

    void bindNodes(Node formNode, DataNode dataNode, boolean bUpdateData) {
        if (dataNode == null) {
            return;
        }
        boolean bPeer = true;
        if (this.mbConnectionMerge) {
            for (Element parentDataNode = dataNode.getXFAParent(); parentDataNode != null && !(parentDataNode instanceof DataModel); parentDataNode = parentDataNode.getXFAParent()) {
                if (parentDataNode.getClassTag() != XFA.DATAGROUPTAG || parentDataNode.getName() != "connectionData") continue;
                bPeer = false;
                break;
            }
        }
        if (bUpdateData) {
            Field templateField;
            FormField formField;
            if (this.mergeMode() == 9175040 && dataNode.isMapped()) {
                bUpdateData = false;
            }
            if (this.mergeMode() == 9175041 && formNode instanceof FormField && StringUtils.isEmpty((templateField = (Field)(formField = (FormField)formNode).getProto()).getRawValue())) {
                bUpdateData = false;
            }
        }
        if (dataNode instanceof DataNode && dataNode.getIsDDPlaceholder()) {
            dataNode.setIsDDPlaceholder(false);
            bUpdateData = true;
        }
        if (formNode instanceof FormField) {
            ((FormField)formNode).setDataNode(dataNode, bUpdateData, bPeer, "", true);
        } else if (formNode instanceof FormSubform) {
            ((FormSubform)formNode).setDataNode(dataNode, true);
        } else if (formNode instanceof FormExclGroup) {
            ((FormExclGroup)formNode).setDataNode(dataNode, bUpdateData, bPeer);
        } else {
            return;
        }
        FormModel.outputTraceMessage(ResId.FormNodeMatchedTrace, formNode, dataNode, "");
    }

    boolean calculationsPending() {
        return this.mPendingCalculateNodes.size() > 0;
    }

    private boolean canBeQueued(Node node, boolean bCalculate) {
        int ePresence;
        int nStart;
        Container container;
        if (node.getXFAParent() == null) {
            return false;
        }
        if (this.mTemplateModel != null && this.mTemplateModel.getOriginalXFAVersion() >= 30 && node instanceof Container && 1076494339 == (ePresence = (container = (Container)node).getRuntimePresence(0))) {
            return false;
        }
        List<Node> list = bCalculate ? this.mPendingCalculateNodes : this.mPendingValidateNodes;
        int n = nStart = bCalculate ? this.mnNextPendingCalculateNode : this.mnNextPendingValidateNode;
        if (!this.mbSkipCyclicAndDuplicateCheck) {
            int nCycleCount = 0;
            for (int i = 0; i < list.size(); ++i) {
                if (list.get(i) != node) continue;
                if (i < nStart) {
                    if (++nCycleCount <= 10) continue;
                    return false;
                }
                return false;
            }
        }
        return true;
    }

    private void checkForItems(FormField field, Node dataMatch) {
        Node currentUI;
        Element ui = field.getElement(XFA.UITAG, true, 0, false, false);
        if (ui != null && (currentUI = ui.getOneOfChild(true, false)) != null && currentUI.isSameClass(XFA.CHOICELISTTAG)) {
            NodeList dataChildren = dataMatch.getNodes();
            int nNodes = dataChildren.length();
            boolean bFoundItems = false;
            Node itemsDataNode = null;
            for (int i = 0; i < nNodes; ++i) {
                itemsDataNode = (Node)dataChildren.item(i);
                String sName = itemsDataNode.getName();
                if (sName.compareToIgnoreCase("items") != 0) continue;
                bFoundItems = true;
                break;
            }
            if (!bFoundItems || itemsDataNode == null) {
                return;
            }
            this.consumeDataNode(null, itemsDataNode, DatasetSelector.MAIN_DATASET);
            NodeList dataItemsChildren = itemsDataNode.getNodes();
            int n = dataItemsChildren.length();
            Field.ItemPair itemPair = new Field.ItemPair();
            field.getItemLists(false, itemPair, true);
            Items displayItems = itemPair.mDisplayItems;
            Items saveItems = itemPair.mSaveItems;
            if (displayItems != null) {
                displayItems.clearItems(false);
            }
            if (saveItems != null) {
                saveItems.clearItems(false);
            }
            int i2 = 0;
            while (i2 < n) {
                Node dataChild = (Node)dataItemsChildren.item(i2);
                this.consumeDataNode(null, dataChild, DatasetSelector.MAIN_DATASET);
                String aChildName = dataChild.getName();
                if (aChildName == null) {
                    ++i2;
                    continue;
                }
                String sSaveValue = ((DataNode)dataChild).getValue();
                Node displayChild = (Node)dataItemsChildren.item(++i2);
                this.consumeDataNode(null, displayChild, DatasetSelector.MAIN_DATASET);
                String aDisplayChildName = displayChild.getName();
                String sDisplayValue = aDisplayChildName == "save" ? sSaveValue : ((DataNode)displayChild).getValue();
                if (displayItems != null) {
                    displayItems.addItem(sDisplayValue, false);
                }
                if (saveItems != null && saveItems != displayItems) {
                    saveItems.addItem(sSaveValue, false);
                }
                ++i2;
            }
        }
    }

    void cleanupLayoutNodes() {
        while (this.mLayoutContent.size() > 0) {
            Element parent;
            Element last = this.mLayoutContent.get((int)(this.mLayoutContent.size() - 1)).mNode;
            this.mLayoutContent.remove(this.mLayoutContent.size() - 1);
            if (null == last || (parent = last.getXFAParent()) == null || parent.getModel() == null) continue;
            if (parent.isSameClass(XFA.SUBFORMSETTAG)) {
                ((SubformSet)parent).reset();
            } else if (parent.isSameClass(XFA.SUBFORMTAG)) {
                ((Subform)parent).reset();
            }
            last.remove();
            this.removeReferencesImpl(last, false);
        }
        this.mCurrentPageSet = null;
    }

    void cleanupLayoutNodes(Node node) {
        Node child = node.getFirstXFAChild();
        while (child != null) {
            Node nextChild = child.getNextXFASibling();
            if (child.isContainer() && !child.isSameClass(XFA.DRAWTAG) && !child.isSameClass(XFA.FIELDTAG)) {
                if (child instanceof FormSubform && ((FormSubform)child).isLayoutNode()) {
                    if (node.getModel() != null) {
                        child.remove();
                        this.removeReferences(child);
                    }
                } else {
                    this.cleanupLayoutNodes(child);
                }
            }
            child = nextChild;
        }
    }

    public void clearFocus() {
        this.mPrevActiveField = this.mActiveField;
        this.mActiveField = null;
    }

    private String computeCheckSum() {
        return this.computeCheckSum(true);
    }

    private String computeCheckSum(boolean bCanonicalizeNamespaceOrder) {
        if (!this.mbIgnoreChecksum) {
            MessageDigest md;
            ByteArrayOutputStream tempStream = new ByteArrayOutputStream();
            DOMSaveOptions formStateOptions = new DOMSaveOptions();
            formStateOptions.setExcludePreamble(true);
            formStateOptions.setExpandElement(true);
            formStateOptions.setDisplayFormat(0);
            if (bCanonicalizeNamespaceOrder) {
                formStateOptions.setCanonicalizeNamespaceOrder(true);
            }
            try {
                md = MessageDigest.getInstance("SHA-1");
            }
            catch (NoSuchAlgorithmException ex) {
                assert (false);
                return "";
            }
            this.mTemplateModel.saveXML(tempStream, formStateOptions);
            md.update(tempStream.toByteArray());
            tempStream.reset();
            this.mDataModel.saveXML(tempStream, formStateOptions);
            md.update(tempStream.toByteArray());
            tempStream = null;
            byte[] hash = md.digest();
            return Base64.encode(hash, false);
        }
        return "";
    }

    private int countOverlayDataChild(Node formNode, Node dataParent) {
        int nCount = 0;
        for (Node dataChild = dataParent.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
            if (!FormModel.isMappableForOverlayData(formNode, dataChild, false)) continue;
            ++nCount;
        }
        return nCount;
    }

    void createAndMatchChildren(Element templateNode, DataNode dataNode, Element formNode, Element connectionDataParent) {
        if (formNode.isContainer() && connectionDataParent != null) {
            this.setConnectionDataContextInfo((Container)formNode, connectionDataParent);
        }
        if (!formNode.isContainer() || formNode.isSameClass(XFA.FIELDTAG) || formNode.isSameClass(XFA.DRAWTAG)) {
            return;
        }
        boolean bMatchDescendantsOnly = this.getMatchDescendantsOnly();
        if (!bMatchDescendantsOnly) {
            int eMergeType = this.mergeType(templateNode, "", null);
            switch (eMergeType) {
                case 2031618: 
                case 2031619: 
                case 2031620: {
                    this.setMatchDescendantsOnly(true);
                }
            }
        }
        for (Node templateChild = templateNode.getFirstXFAChild(); templateChild != null; templateChild = templateChild.getNextXFASibling()) {
            Element templateElement;
            if (!(templateChild instanceof Element) || !this.mapChild(templateElement = (Element)templateChild, formNode)) continue;
            this.createAndMatchNode(templateElement, dataNode, formNode, connectionDataParent);
        }
        this.setMatchDescendantsOnly(bMatchDescendantsOnly);
    }

    int createAndMatchNode(Element templateNode, DataNode dataParent, Element formParent, Element connectionDataParent) {
        int nNumCreated = 0;
        if (templateNode instanceof Subform) {
            Element formNode;
            FormInstanceManager instanceManager = this.createInstanceManager(templateNode, formParent);
            int nMax = this.getOccurAttribute(templateNode, XFA.MAXTAG);
            if (nMax != -1 && nMax < 1) {
                return 0;
            }
            int nRequired = this.getOccurAttribute(templateNode, XFA.MINTAG);
            Container.FormInfo formInfo = this.getFormInfo(templateNode, dataParent, connectionDataParent);
            DataNode dataMatch = this.findMatch(formInfo, true, DatasetSelector.MAIN_DATASET);
            while (dataMatch != null) {
                ++nNumCreated;
                if (!formInfo.bConnectDataRef) {
                    formNode = this.createFormNode(templateNode, formParent, instanceManager);
                    this.bindNodes(formNode, dataMatch, false);
                    this.consumeDataNode(formInfo, dataMatch, DatasetSelector.MAIN_DATASET);
                    this.resetLocalConsumptionContext(templateNode);
                    this.createAndMatchChildren(templateNode, dataMatch, formNode, connectionDataParent);
                } else {
                    Element formNode2;
                    this.consumeDataNode(formInfo, dataMatch, DatasetSelector.MAIN_DATASET);
                    DataNode actualDataMatch = this.findMatch(formInfo, true, DatasetSelector.ALT_DATASET);
                    if (actualDataMatch != null) {
                        formNode2 = this.createFormNode(templateNode, formParent, instanceManager);
                        this.resetLocalConsumptionContext(templateNode);
                        this.createAndMatchChildren(templateNode, actualDataMatch, formNode2, dataMatch);
                        this.bindNodes(formNode2, actualDataMatch, UPDATE_DATA);
                        this.consumeDataNode(formInfo, actualDataMatch, DatasetSelector.ALT_DATASET);
                    } else {
                        formNode2 = this.createFormNode(templateNode, formParent, instanceManager);
                        this.resetLocalConsumptionContext(templateNode);
                        this.createAndMatchChildren(templateNode, dataParent, formNode2, dataMatch);
                    }
                }
                if (nMax != -1 && nNumCreated == nMax) {
                    return nNumCreated;
                }
                formInfo = this.getFormInfo(templateNode, dataParent, connectionDataParent);
                dataMatch = this.findMatch(formInfo, true, DatasetSelector.MAIN_DATASET);
            }
            if (formInfo.eMergeType == 2031616 || this.mergeMode() == 9175040) {
                while (this.hasDescendantMatch(templateNode, dataParent, connectionDataParent, formInfo.eMergeType, false, null)) {
                    formNode = this.createFormNode(templateNode, formParent, instanceManager);
                    this.createAndMatchChildren(templateNode, dataParent, formNode, connectionDataParent);
                    if (nMax == -1 || ++nNumCreated != nMax) continue;
                    break;
                }
            }
            if (nNumCreated == 0) {
                nRequired = this.getOccurAttribute(templateNode, XFA.INITIALTAG);
            }
            while (nNumCreated < nRequired) {
                if (this.mergeMode() == 9175040) {
                    this.createEmptyFormNode(templateNode, formParent, connectionDataParent, instanceManager);
                } else {
                    formNode = this.createFormNode(templateNode, formParent, instanceManager);
                    dataMatch = null;
                    if (!formInfo.bAssociation) {
                        if (formInfo.eMergeType == 2031616) {
                            dataMatch = dataParent;
                        } else if (this.mapChild(templateNode, formParent)) {
                            dataMatch = this.createDataNode(formNode, dataParent, formInfo.eMergeType, true);
                            this.bindNodes(formNode, dataMatch, UPDATE_DATA);
                            this.consumeDataNode(null, dataMatch, DatasetSelector.MAIN_DATASET);
                        }
                    }
                    this.createAndMatchChildren(templateNode, dataMatch, formNode, connectionDataParent);
                }
                ++nNumCreated;
            }
        } else if (templateNode instanceof Field) {
            FormField formNode = (FormField)this.createFormNode(templateNode, formParent, null);
            Container.FormInfo formInfo = this.getFormInfo(templateNode, dataParent, connectionDataParent);
            assert (formInfo != null);
            DataNode dataMatch = this.findMatch(formInfo, false, DatasetSelector.MAIN_DATASET);
            if (formInfo.bConnectDataRef && dataMatch != null) {
                formNode.setDataNode(dataMatch, false, false, "", true);
                this.consumeDataNode(formInfo, dataMatch, DatasetSelector.MAIN_DATASET);
                this.setConnectionDataContextInfo(formNode, dataMatch);
                DataNode actualDataMatch = this.findMatch(formInfo, false, DatasetSelector.ALT_DATASET);
                if (actualDataMatch != null) {
                    this.bindNodes(formNode, actualDataMatch, UPDATE_DATA);
                    this.consumeDataNode(formInfo, actualDataMatch, DatasetSelector.ALT_DATASET);
                }
            } else {
                if (dataMatch == null && (formInfo.eMergeType == 2031617 || formInfo.eMergeType == 2031620)) {
                    dataMatch = this.findNestedAttrMatch(formNode, dataParent, formInfo.eMergeType);
                }
                if (dataMatch != null || this.mergeMode() == 9175040) {
                    this.bindNodes(formNode, dataMatch, false);
                    this.consumeDataNode(formInfo, dataMatch, DatasetSelector.MAIN_DATASET);
                } else {
                    dataMatch = this.createDataNode(formNode, dataParent, formInfo.eMergeType, true);
                    this.bindNodes(formNode, dataMatch, UPDATE_DATA);
                    this.consumeDataNode(null, dataMatch, DatasetSelector.MAIN_DATASET);
                }
            }
            ++nNumCreated;
        } else if (templateNode instanceof SubformSet) {
            nNumCreated += this.mapSubformSet(templateNode, formParent, dataParent, connectionDataParent);
        } else if (templateNode instanceof ExclGroup) {
            Container.FormInfo formInfo = this.getFormInfo(templateNode, dataParent, null);
            if (formInfo.eMergeType == 2031616) {
                Element formNode = this.createFormNode(templateNode, formParent, null);
                this.createAndMatchChildren(templateNode, dataParent, formNode, connectionDataParent);
            } else {
                Element formNode;
                DataNode dataMatch = this.findMatch(formInfo, false, DatasetSelector.MAIN_DATASET);
                if (dataMatch == null) {
                    if (this.mergeMode() == 9175040) {
                        this.createEmptyFormNode(templateNode, formParent, connectionDataParent, null);
                    } else {
                        formNode = this.createEmptyFormNode(templateNode, formParent, connectionDataParent, null);
                        dataMatch = this.createDataNode(formNode, dataParent, formInfo.eMergeType, true);
                        this.bindNodes(formNode, dataMatch, UPDATE_DATA);
                        this.consumeDataNode(null, dataMatch, DatasetSelector.MAIN_DATASET);
                    }
                } else if (dataMatch.getClassTag() == XFA.DATAGROUPTAG) {
                    formNode = this.createFormNode(templateNode, formParent, null);
                    this.bindNodes(formNode, dataMatch, false);
                    this.consumeDataNode(formInfo, dataMatch, DatasetSelector.MAIN_DATASET);
                    this.resetLocalConsumptionContext(templateNode);
                    this.createAndMatchChildren(templateNode, dataMatch, formNode, connectionDataParent);
                } else {
                    formNode = this.createEmptyFormNode(templateNode, formParent, connectionDataParent, null);
                    this.bindNodes(formNode, dataMatch, false);
                    this.consumeDataNode(formInfo, dataMatch, DatasetSelector.MAIN_DATASET);
                }
            }
            ++nNumCreated;
        } else {
            Element formNode = this.createFormNode(templateNode, formParent, null);
            this.createAndMatchChildren(templateNode, dataParent, formNode, connectionDataParent);
            ++nNumCreated;
        }
        return nNumCreated;
    }

    DataNode createDataNode(Element formNode, Element dataParent, int eMergeType, boolean bSearchForNewlyCreatedFirst) {
        DataNode newDataNode = null;
        if (eMergeType == 2031616) {
            return null;
        }
        if (eMergeType == 2031618) {
            boolean bUseDV = FormModel.useDV(formNode);
            newDataNode = (DataNode)this.resolveCreateGlobal(formNode, bSearchForNewlyCreatedFirst, bUseDV);
        } else if (eMergeType == 2031619) {
            String sRef = this.getDataRef(formNode, "", null);
            boolean bUseDV = FormModel.useDV(formNode);
            if (this.mergeMode() == 9175041) {
                if (FormModel.somIsStar(sRef) && formNode instanceof FormSubform) {
                    FormSubform formSubform = (FormSubform)formNode;
                    sRef = sRef.substring(0, sRef.length() - 3);
                    sRef = sRef + "[" + formSubform.getInstanceIndex(null) + "]";
                }
                if (this.getMatchDescendantsOnly() && FormModel.somIsRelative(sRef) && sRef.charAt(0) != '$') {
                    sRef = "$." + sRef;
                }
            }
            if ((newDataNode = this.resolveCreateDataRef(sRef, dataParent, bSearchForNewlyCreatedFirst, bUseDV)) != null && !FormModel.isMappable(formNode, newDataNode, false, false)) {
                MsgFormatPos msg = new MsgFormatPos(ResId.FormInvalidDataRef);
                msg.format(sRef);
                msg.format(formNode.getName());
                msg.format(newDataNode.getClassAtom());
                throw new ExFull(msg);
            }
        } else if (eMergeType == 2031617 || eMergeType == 2031620) {
            String aName = formNode.getName();
            if (aName == "") {
                return null;
            }
            boolean bUseDV = FormModel.useDV(formNode);
            if (dataParent != null) {
                if (this.mDataDescription != null) {
                    int nDot;
                    StringBuilder sTemp = new StringBuilder(aName);
                    int fromIndex = 0;
                    while ((nDot = sTemp.indexOf(".", fromIndex)) != -1) {
                        sTemp.insert(nDot, '\\');
                        fromIndex = nDot + 2;
                    }
                    StringBuilder sName = new StringBuilder();
                    if (this.getMatchDescendantsOnly()) {
                        sName.append("$.");
                    }
                    sName.append(sTemp);
                    if (this.mergeMode() == 9175040) {
                        sName.append("[*]");
                    } else {
                        sName.append("[" + formNode.getIndex(true) + "]");
                    }
                    newDataNode = this.resolveCreateDataRef(sName.toString(), dataParent, bSearchForNewlyCreatedFirst, bUseDV);
                } else {
                    newDataNode = bUseDV ? (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, dataParent, aName, null, true) : (DataNode)this.mDataModel.createNode(XFA.DATAGROUPTAG, dataParent, aName, null, true);
                    if (!this.mbAdjustData) {
                        newDataNode.makeDefault();
                    }
                }
            }
        }
        if (newDataNode != null) {
            FormModel.outputTraceMessage(ResId.NodeCreatedTrace, newDataNode, null, "");
        } else if (eMergeType != 2031616) {
            FormModel.outputTraceMessage(ResId.UnmappedNode, formNode, null, "");
        }
        if (this.mbMergeComplete && newDataNode != null && newDataNode.getXFAParent() != null) {
            newDataNode.getXFAParent().notifyPeers(4, newDataNode.getClassAtom(), newDataNode);
        }
        return newDataNode;
    }

    Element createEmptyFormNode(Element templateNode, Element formParent, Element connectionDataParent, FormInstanceManager instanceManager) {
        boolean bMatchDescendantsOnly;
        int eRelation;
        Element formNode = null;
        DataNode dataNode = null;
        int eMergeType = this.mergeType(templateNode, "", null);
        if (this.mapChild(templateNode, formParent)) {
            if (!(eMergeType != 2031618 || this.mergeMode() != 9175040 || (dataNode = this.resolveGlobal(templateNode, true)) == null || templateNode.isSameClass(XFA.EXCLGROUPTAG) && dataNode.isSameClass(XFA.DATAVALUETAG))) {
                formNode = this.createFormNode(templateNode, formParent, instanceManager);
                this.bindNodes(formNode, dataNode, false);
                this.consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
                this.resetLocalConsumptionContext(templateNode);
                this.createAndMatchChildren(templateNode, dataNode, formNode, connectionDataParent);
                return formNode;
            }
        } else {
            return null;
        }
        formNode = this.createFormNode(templateNode, formParent, instanceManager);
        if (!templateNode.isContainer() || formNode.isSameClass(XFA.FIELDTAG) || formNode.isSameClass(XFA.DRAWTAG)) {
            return formNode;
        }
        boolean bChoice = false;
        if (templateNode instanceof SubformSet && (eRelation = ((EnumValue)((SubformSet)templateNode).getAttribute(XFA.RELATIONTAG)).getInt()) == -2144600062) {
            bChoice = true;
        }
        if (!(bMatchDescendantsOnly = this.getMatchDescendantsOnly())) {
            switch (eMergeType) {
                case 2031618: 
                case 2031619: 
                case 2031620: {
                    this.setMatchDescendantsOnly(true);
                }
            }
        }
        int nRequired = 1;
        for (Node templateChild = templateNode.getFirstXFAChild(); templateChild != null; templateChild = templateChild.getNextXFASibling()) {
            if (!(templateChild instanceof Element)) continue;
            Element templateElement = (Element)templateChild;
            FormInstanceManager newInstanceManager = this.createInstanceManager(templateElement, formNode);
            nRequired = this.getOccurAttribute(templateElement, XFA.INITIALTAG);
            for (int nCount = 0; nCount < nRequired; ++nCount) {
                this.createEmptyFormNode(templateElement, formNode, connectionDataParent, newInstanceManager);
            }
            if (bChoice && templateChild.isContainer()) break;
        }
        if (dataNode != null) {
            this.bindNodes(formNode, dataNode, false);
            this.consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
        }
        this.setMatchDescendantsOnly(bMatchDescendantsOnly);
        return formNode;
    }

    public int mergeMode() {
        return this.mbGlobalConsumption ? 9175040 : 9175041;
    }

    Element createFormNode(Element templateNode, Element formParent, FormInstanceManager instanceManager) {
        Element newFormNode;
        assert (templateNode.getModel() instanceof TemplateModel);
        boolean bProtoChildren = !templateNode.isContainer();
        boolean bNodeCanHaveEvents = false;
        if (templateNode.isSameClass(XFA.FIELDTAG)) {
            Element fieldElement = templateNode;
            boolean bIsMultiSelect = false;
            if (this.mTemplateModel.validateGlobalField(fieldElement)) {
                EnumAttr eOpen;
                Node currentUI;
                Element ui = fieldElement.getElement(XFA.UITAG, true, 0, false, false);
                if (ui != null && (currentUI = ui.getOneOfChild(true, false)) != null && currentUI.isSameClass(XFA.CHOICELISTTAG) && (eOpen = EnumAttr.getEnum(((Element)currentUI).getEnum(XFA.OPENTAG))).getInt() == 2293763) {
                    bIsMultiSelect = true;
                }
                newFormNode = bIsMultiSelect ? new FormChoiceListField(formParent, null) : new FormField(formParent, null);
            } else {
                throw new ExFull(new MsgFormat(ResId.XFAGlobalFieldConflictException, templateNode.getName()));
            }
            bProtoChildren = true;
            bNodeCanHaveEvents = true;
        } else if (templateNode.isSameClass(XFA.SUBFORMTAG)) {
            newFormNode = new FormSubform(formParent, null);
            if (templateNode == this.mRootSubform) {
                this.mRootFormSubform = newFormNode;
                String sLocale = this.getAmbientLocale();
                if (!StringUtils.isEmpty(sLocale)) {
                    StringAttr oLocaleProp = new StringAttr("locale", sLocale);
                    ((FormSubform)newFormNode).setAttribute(oLocaleProp, XFA.LOCALETAG);
                }
            }
            if (instanceManager != null) {
                instanceManager.addInstance(newFormNode, false);
            }
            bNodeCanHaveEvents = true;
        } else if (templateNode.isSameClass(XFA.SUBFORMSETTAG)) {
            newFormNode = new FormSubformSet(formParent, null);
            if (instanceManager != null) {
                instanceManager.addInstance(newFormNode, false);
            }
        } else if (templateNode.isSameClass(XFA.EXCLGROUPTAG)) {
            newFormNode = new FormExclGroup(formParent, null);
            bNodeCanHaveEvents = true;
        } else {
            newFormNode = (Element)this.createNode(templateNode.getClassTag(), formParent, "", "", true);
        }
        if (newFormNode != null) {
            String aNodeName = templateNode.getName();
            if (aNodeName != null && "" != aNodeName) {
                newFormNode.privateSetName(aNodeName);
            }
            FormModel.outputTraceMessage(ResId.NodeCreatedTrace, newFormNode, null, "");
            if (bProtoChildren) {
                ((ProtoableNode)newFormNode).resolveProto((ProtoableNode)templateNode, false, false, false);
            } else {
                ((ProtoableNode)newFormNode).setProto((ProtoableNode)templateNode);
            }
            newFormNode.makeDefault();
            if (this.mergeMode() == 9175040) {
                int eMergeType = this.mergeType(templateNode, "", null);
                switch (eMergeType) {
                    case 2031618: 
                    case 2031619: 
                    case 2031620: {
                        this.mExplicitMatchNodes.add(newFormNode);
                    }
                }
            }
            if (this.mbRegisterNewEvents && (newFormNode.isSameClass(XFA.EVENTTAG) || bNodeCanHaveEvents)) {
                this.registerEvents(newFormNode, 7);
            }
        }
        return newFormNode;
    }

    private void createFormState() {
        if (!this.getFormStateUsage()) {
            return;
        }
        Element formState = (Element)this.getAppModel().locateChildByName("formState", 0);
        if (formState == null) {
            AppModel appModel = (AppModel)this.getXFAParent();
            formState = new Packet(appModel, null);
            new ModelPeer((Element)appModel.getXmlPeer(), null, null, "formState", "formState", null, formState);
        } else {
            ModelPeer formStateDomPeer = (ModelPeer)((Packet)formState).getXmlPeer();
            Node node = formStateDomPeer.getFirstXFAChild();
            while (node != null) {
                Node oNext = node.getNextXFASibling();
                node.remove();
                node = oNext;
            }
        }
        for (Node node = this.getFirstXFAChild(); node != null; node = node.getNextXFASibling()) {
            if (!(node instanceof Element)) continue;
            this.createFormState((Element)node, formState);
        }
    }

    private void createFormState(Element formNode, Element oFormState) {
        Document domDoc = oFormState.getOwnerDocument();
        for (Node formChild = formNode.getFirstXFAChild(); formChild != null; formChild = formChild.getNextXFASibling()) {
            if (formChild instanceof FormField) {
                Node currentUI;
                FormField field = (FormField)formChild;
                Element ui = field.getElement(XFA.UITAG, true, 0, false, false);
                if (ui == null || (currentUI = ui.getOneOfChild(true, false)) == null || !currentUI.isSameClass(XFA.CHOICELISTTAG)) continue;
                Field.ItemPair itemPair = new Field.ItemPair();
                field.getItemLists(true, itemPair, false);
                Items saveItem = itemPair.mSaveItems;
                Items displayItem = itemPair.mDisplayItems;
                boolean bModifiedList = false;
                ListBase saveItems = new ArrayNodeList();
                int nSaveItems = 0;
                if (saveItem != null) {
                    if (!saveItem.isDefault(false) && saveItem.getXFAParent() == field) {
                        bModifiedList = true;
                    }
                    saveItems = saveItem.getNodes();
                    nSaveItems = saveItems.length();
                }
                ListBase displayItems = new ArrayNodeList();
                int nDisplayItems = 0;
                if (displayItem != null) {
                    if (!displayItem.isDefault(false) && displayItem.getXFAParent() == field) {
                        bModifiedList = true;
                    }
                    displayItems = displayItem.getNodes();
                    nDisplayItems = displayItems.length();
                }
                if (!bModifiedList) continue;
                int nValues = 0;
                nValues = nSaveItems != 0 && nDisplayItems != 0 && nSaveItems != nDisplayItems ? (nSaveItems < nDisplayItems ? nSaveItems : nDisplayItems) : nSaveItems;
                if (nValues == 0) continue;
                Element newState = domDoc.createElementNS("", "state", oFormState);
                String sRef = field.getSOMExpression(this, false);
                newState.setAttribute("", "ref", "ref", sRef);
                Element newItems = domDoc.createElementNS("", "items", newState);
                String sDisplay = "";
                String sSave = "";
                for (int k = 0; k < nValues; ++k) {
                    TextNode textNode;
                    if (saveItems.item(k) instanceof TextNode) {
                        textNode = (TextNode)saveItems.item(k);
                        sSave = textNode.getValue();
                    }
                    if (displayItems.item(k) instanceof TextNode) {
                        textNode = (TextNode)displayItems.item(k);
                        sDisplay = textNode.getValue();
                    }
                    Element save = domDoc.createElementNS("", "save", newItems);
                    new TextNode(save, null, sSave);
                    Element display = domDoc.createElementNS("", "display", newItems);
                    new TextNode(display, null, sDisplay);
                }
                continue;
            }
            if (!formNode.isContainer()) continue;
            this.createFormState((Element)formChild, oFormState);
        }
    }

    private FormInstanceManager createInstanceManager(Element templateNode, Element formParent) {
        if (this.mbIsXFAF && (!(templateNode instanceof Subform) || templateNode.getXFAParent() != this.mRootSubform)) {
            return null;
        }
        if ((templateNode instanceof Subform || templateNode instanceof SubformSet) && (formParent instanceof FormSubform || formParent instanceof FormSubformSet || formParent.isSameClass(XFA.PAGEAREATAG))) {
            FormInstanceManager formInstanceManager = new FormInstanceManager(formParent, null);
            formInstanceManager.setTemplateNode((ProtoableNode)templateNode);
            formInstanceManager.setMatchDescendantsOnly(this.getMatchDescendantsOnly());
            formInstanceManager.makeDefault();
            return formInstanceManager;
        }
        return null;
    }

    private ProtoableNode createLayoutNode(ProtoableNode staticContent, Element parent) {
        assert (staticContent != null);
        assert (staticContent instanceof PageSet || staticContent instanceof Subform || staticContent instanceof SubformSet);
        Element newStaticContent = this.importNode(staticContent, parent, !(staticContent instanceof PageSet));
        if (parent != null) {
            this.mLayoutContent.add(new LayoutContentInfo(newStaticContent));
        }
        if (newStaticContent instanceof FormSubform) {
            ((FormSubform)newStaticContent).setLayoutNode();
        } else if (newStaticContent instanceof FormSubformSet) {
            this.setLayoutNodes((FormSubformSet)newStaticContent);
        }
        return (ProtoableNode)newStaticContent;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    Node createLeaderTrailer(String sReference, Container container, boolean bPeek) {
        this.mbRegisterNewEvents = !bPeek;
        try {
            ProtoableNode protoableContainer;
            Container containerTemplateContext = container;
            for (protoableContainer = container; protoableContainer != null && !(protoableContainer.getModel() instanceof TemplateModel); protoableContainer = protoableContainer.getProto()) {
            }
            containerTemplateContext = protoableContainer;
            assert (containerTemplateContext != null);
            ProtoableNode templateSF = null;
            if (containerTemplateContext != null) {
                templateSF = this.mTemplateModel.createLeaderTrailer(sReference, containerTemplateContext, bPeek);
            }
            if (templateSF != null) {
                ProtoableNode newNode;
                ProtoableNode oProtoableTemplateSF = templateSF;
                if (this.mTemplateModel.getLegacySetting(AppModel.XFA_OVERFLOW_TARGET_ALTERNATE)) {
                    int nProtoedIndex = 0;
                    newNode = oProtoableTemplateSF.getProtoed(nProtoedIndex++);
                    while (oProtoableTemplateSF.getProtoed(nProtoedIndex) != null) {
                        newNode = oProtoableTemplateSF.getProtoed(nProtoedIndex++);
                    }
                    if (newNode != null) {
                        SubformSet oNewSubformSet;
                        if (newNode instanceof FormSubform) {
                            FormSubform oNewSubform = (FormSubform)newNode;
                            if (oNewSubform.getInstanceManager() != null) {
                                ProtoableNode protoableNode = newNode;
                                return protoableNode;
                            }
                        } else if (newNode instanceof SubformSet && (oNewSubformSet = (SubformSet)newNode).getInstanceManager() != null) {
                            ProtoableNode protoableNode = newNode;
                            return protoableNode;
                        }
                    }
                }
                newNode = bPeek ? this.createLayoutNode(templateSF, null) : this.createLayoutNode(templateSF, container);
                ProtoableNode nProtoedIndex = newNode;
                return nProtoedIndex;
            }
            Node oProtoableTemplateSF = null;
            return oProtoableTemplateSF;
        }
        finally {
            this.mbRegisterNewEvents = true;
        }
    }

    @Override
    public Node createNode(int eClassTag, Element parent, String aNodeName, String aNS, boolean bDoVersionCheck) {
        assert (aNodeName != null);
        assert (aNS != null);
        Element newFormNode = null;
        if (!(this.mbAllowNewNodes || eClassTag != XFA.FIELDTAG && eClassTag != XFA.SUBFORMTAG && eClassTag != XFA.SUBFORMSETTAG && eClassTag != XFA.EXCLGROUPTAG && eClassTag != XFA.DRAWTAG && eClassTag != XFA.AREATAG && eClassTag != XFA.PAGEAREATAG && eClassTag != XFA.PAGESETTAG)) {
            return newFormNode;
        }
        assert (eClassTag != XFA.XMLMULTISELECTNODETAG);
        newFormNode = eClassTag == XFA.FIELDTAG ? new FormField(parent, null) : (eClassTag == XFA.SUBFORMTAG ? new FormSubform(parent, null) : (eClassTag == XFA.EXCLGROUPTAG ? new FormExclGroup(parent, null) : (eClassTag == XFA.SUBFORMSETTAG ? new FormSubformSet(parent, null) : this.getSchema().getInstance(eClassTag, this, parent, null, bDoVersionCheck))));
        if (newFormNode != null && aNodeName != "") {
            newFormNode.privateSetName(aNodeName);
        }
        return newFormNode;
    }

    private void createOverlayData(Node formNode) {
        Element overlayDataNode = null;
        for (Node node = this.mDataModel.getFirstXFAChild(); node != null; node = node.getNextXFASibling()) {
            if (node.getName() != "overlayData") continue;
            overlayDataNode = (Element)node;
            break;
        }
        if (overlayDataNode != null) {
            // empty if block
        }
        overlayDataNode = (Element)this.mDataModel.createNode(XFA.DATAGROUPTAG, this.mDataModel, "overlayData", this.mDataModel.getNS(), true);
        Element panelDataNode = null;
        if (formNode instanceof FormSubform) {
            String aName = formNode.getName();
            panelDataNode = aName == "" ? overlayDataNode : (Element)this.mDataModel.createNode(XFA.DATAGROUPTAG, overlayDataNode, aName, "", true);
        }
        this.createOverlayData(formNode, panelDataNode);
    }

    private void createOverlayData(Node form, Element dataParent) {
        Node formChild = form.getFirstXFAChild();
        while (formChild != null) {
            String sRawValue;
            Element newDataNode;
            DataNode rawValue;
            String aChildName = formChild.getName();
            if (formChild instanceof FormField) {
                String sFormattedValue;
                Node currentUI;
                Element ui;
                FormField field = (FormField)formChild;
                sRawValue = field.getRawValue();
                newDataNode = (Element)this.mDataModel.createNode(XFA.DATAGROUPTAG, dataParent, aChildName, "", true);
                if (form instanceof FormChoiceListField) {
                    Node valueContent;
                    Value value;
                    if (formChild.isPropertySpecified(XFA.VALUETAG, true, 0) && (valueContent = (value = (Value)((FormChoiceListField)formChild).getElement(XFA.VALUETAG, 0)).getOneOfChild()) instanceof ExDataValue) {
                        ArrayList<String> selectionList = new ArrayList<String>();
                        Node node = ((ExDataValue)valueContent).getOneOfChild();
                        if (node instanceof XMLMultiSelectNode) {
                            XMLMultiSelectNode multiSelect = (XMLMultiSelectNode)node;
                            multiSelect.getValues(selectionList);
                            int nNumberSelected = selectionList.size();
                            for (int j = 0; j < nNumberSelected; ++j) {
                                sRawValue = selectionList.get(j);
                                DataNode rawValue2 = (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, newDataNode, "value", "", true);
                                rawValue2.setValue(sRawValue, true);
                            }
                        }
                    }
                } else {
                    rawValue = (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, newDataNode, "value", "", true);
                    rawValue.setValue(sRawValue, true);
                }
                if (!(sFormattedValue = field.getFormattedValue()).equals(sRawValue)) {
                    DataNode oFormattedValue = (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, newDataNode, "formattedValue", "", true);
                    oFormattedValue.setValue(sFormattedValue, true);
                }
                if ((ui = field.getElement(XFA.UITAG, true, 0, false, false)) != null && (currentUI = ui.getOneOfChild(true, false)) != null && currentUI.isSameClass(XFA.CHOICELISTTAG)) {
                    NodeList displayItems;
                    int nSaveItems;
                    NodeList saveItems;
                    int nDisplayItems;
                    Field.ItemPair itemPair = new Field.ItemPair();
                    field.getItemLists(true, itemPair, false);
                    Items displayItem = itemPair.mDisplayItems;
                    Items saveItem = itemPair.mSaveItems;
                    if (saveItem != null) {
                        saveItems = saveItem.getNodes();
                        nSaveItems = saveItems.length();
                    } else {
                        saveItems = new ArrayNodeList();
                        nSaveItems = 0;
                    }
                    if (displayItem != null) {
                        displayItems = displayItem.getNodes();
                        nDisplayItems = displayItems.length();
                    } else {
                        displayItems = new ArrayNodeList();
                        nDisplayItems = 0;
                    }
                    int nValues = nSaveItems != 0 && nDisplayItems != 0 && nSaveItems != nDisplayItems ? Math.min(nSaveItems, nDisplayItems) : nSaveItems;
                    if (nValues != 0) {
                        Element items = (Element)this.mDataModel.createNode(XFA.DATAGROUPTAG, newDataNode, "items", "", true);
                        String sDisplayValue = "";
                        String sSaveValue = "";
                        for (int k = 0; k < nValues; ++k) {
                            TextValue textNode;
                            if (saveItems.item(k) instanceof TextNode) {
                                textNode = (TextValue)saveItems.item(k);
                                sSaveValue = textNode.getValue();
                            }
                            if (displayItems.item(k) instanceof TextNode) {
                                textNode = (TextValue)displayItems.item(k);
                                sDisplayValue = textNode.getValue();
                            }
                            DataNode save = (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, items, "save", "", true);
                            save.setValue(sSaveValue, true);
                            DataNode display = (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, items, "display", "", true);
                            display.setValue(sDisplayValue, true);
                        }
                    }
                }
            } else if (formChild instanceof FormExclGroup) {
                FormExclGroup group = (FormExclGroup)formChild;
                newDataNode = (Element)this.mDataModel.createNode(XFA.DATAGROUPTAG, dataParent, aChildName, "", true);
                sRawValue = group.getRawValue();
                rawValue = (DataNode)this.mDataModel.createNode(XFA.DATAVALUETAG, newDataNode, "value", "", true);
                rawValue.setValue(sRawValue, true);
            } else if (formChild instanceof FormSubform) {
                newDataNode = aChildName == "" ? dataParent : (Element)this.mDataModel.createNode(XFA.DATAGROUPTAG, dataParent, aChildName, "", true);
                this.createOverlayData(formChild, newDataNode);
            }
            formChild = form.getNextXFASibling();
        }
    }

    PageArea createPage(PageArea page) {
        assert (this.mCurrentPageSet != null);
        return (PageArea)this.importNode(page, this.mCurrentPageSet, true);
    }

    PageSet createPageSet(PageSet pageSet) {
        Element pageSetParent = pageSet.getXFAParent();
        Element parent = this.mCurrentPageSet;
        if (parent == null) {
            parent = this.mRootFormSubform;
        }
        while (parent instanceof PageSet && ((PageSet)parent).getProto() != pageSetParent) {
            parent = parent.getXFAParent();
        }
        assert (parent.isSameClass(pageSetParent));
        this.mCurrentPageSet = this.createLayoutNode(pageSet, parent);
        return (PageSet)this.mCurrentPageSet;
    }

    public void createPanelOverlayData(int nPanel) {
        Node topSubform = this.getFirstXFAChild();
        Node targetSubform = null;
        int nCnt = 0;
        for (Node child = topSubform.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
            if (!(child instanceof FormSubform)) continue;
            if (nCnt == nPanel) {
                targetSubform = child;
                break;
            }
            ++nCnt;
        }
        if (targetSubform != null) {
            this.createOverlayData(targetSubform);
        }
    }

    private void doBindItems(Element bindItems, FormField field, String sRequestConnectionName) {
        String sConnection = "";
        Attribute connection = bindItems.getAttribute(XFA.CONNECTIONTAG, true, false);
        if (connection != null) {
            sConnection = connection.toString();
        }
        String sRef = "";
        Attribute ref = bindItems.getAttribute(XFA.REFTAG, true, false);
        if (ref != null) {
            sRef = ref.toString();
        }
        if (sRef.length() != 0 && sConnection.length() != 0) {
            if (sRequestConnectionName.equals(sConnection)) {
                field.setItemsDataListener(null);
                field.updateItemsFromData(bindItems, true);
            }
        } else if ((sRef.length() == 0 || sConnection.length() == 0) && sRequestConnectionName.length() == 0) {
            FormItemsDataListener listener = new FormItemsDataListener(field, bindItems);
            field.setItemsDataListener(listener);
            field.updateItemsFromData(bindItems, false);
        }
    }

    @Override
    protected Node doLoadNode(Element parent, Node node, Generator genTag) {
        assert (node instanceof Element || node instanceof Chars);
        if (parent instanceof ExDataValue && node instanceof Element) {
            boolean bCreate = false;
            int eNewNodeTag = XFA.RICHTEXTNODETAG;
            if (((Element)node).getNS() == "http://www.w3.org/1999/xhtml") {
                bCreate = true;
            } else {
                String sContent = parent.getAttribute(XFA.CONTENTTYPETAG).toString();
                if (sContent.equals("text/xml")) {
                    eNewNodeTag = XFA.XMLMULTISELECTNODETAG;
                    bCreate = true;
                }
            }
            if (bCreate) {
                return this.importContent(parent, node, eNewNodeTag);
            }
            MsgFormatPos msg = new MsgFormatPos(ResId.InvalidNodeTypeException, ((Element)node).getLocalName());
            this.addErrorList(new ExFull(msg), 3, null);
            return null;
        }
        return super.doLoadNode(parent, node, genTag);
    }

    private Node importContent(Element parent, Node node, int eType) {
        if (node instanceof Chars) {
            return new TextNode(parent, null, ((Chars)node).getText());
        }
        if (node instanceof Element) {
            Element element = (Element)node;
            Element newElement = null;
            if (eType == XFA.RICHTEXTNODETAG) {
                newElement = new RichTextNode(parent, null);
            } else if (eType == XFA.XMLMULTISELECTNODETAG) {
                newElement = new XMLMultiSelectNode(parent, null);
            } else assert (false);
            newElement.setDOMProperties(element.getNS(), element.getLocalName(), element.getXMLName(), null);
            for (int i = 0; i < element.getNumAttrs(); ++i) {
                Attribute attr = element.getAttr(i);
                newElement.setAttribute(attr.getNS(), attr.getName(), attr.getLocalName(), attr.getAttrValue(), false);
            }
            for (Node child = element.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
                this.importContent(newElement, child, eType);
            }
            return newElement;
        }
        if (node instanceof Comment) {
            return new Comment(parent, null, ((Comment)node).getData());
        }
        if (node instanceof ProcessingInstruction) {
            ProcessingInstruction pi = (ProcessingInstruction)node;
            return new ProcessingInstruction(parent, null, pi.getName(), pi.getData());
        }
        MsgFormatPos msg = new MsgFormatPos(ResId.InvalidNodeTypeException, node.getClassName());
        this.addErrorList(new ExFull(msg), 3, null);
        return null;
    }

    private void doSetProperty(Element setProperty, Container container, boolean bIsConnectionBind) {
        Element dataNode2;
        TextNode textNode;
        String sTarget;
        String sRef;
        Attribute ref = setProperty.getAttribute(XFA.REFTAG, true, false);
        Attribute target = setProperty.getAttribute(XFA.TARGETTAG, true, false);
        if (ref == null || target == null) {
            return;
        }
        sRef = ref.toString();
        sTarget = target.toString();
        if (sRef.length() == 0 || sTarget.length() == 0) {
            return;
        }
        Element dataNode2 = null;
        if (bIsConnectionBind) {
            for (Element node = container; node != null; node = node.getXFAParent()) {
                if (node instanceof Container && node.getFormInfo() != null) {
                    dataNode2 = node.getFormInfo().connectionDataNode;
                }
                if (dataNode2 == null) {
                    continue;
                }
                break;
            }
        } else {
            dataNode2 = FormModel.getDataNode(container);
        }
        NodeList refNodes = dataNode2 != null ? dataNode2.resolveNodes(sRef, true, false, true) : this.mDataModel.resolveNodes(sRef, true, false, true);
        Node refNode = null;
        if (refNodes.length() > 0) {
            refNode = (Node)refNodes.item(0);
        }
        if (refNode == null || !refNode.isSameClass(XFA.DATAVALUETAG)) {
            return;
        }
        String sSetValue = ((DataNode)refNode).getValue();
        StringHolder sTargetProperty = new StringHolder();
        Node targetNode = this.resolveSetPropertyTarget(container, sTarget, sTargetProperty);
        if (!(targetNode instanceof Element)) {
            return;
        }
        if (!FormModel.isValidSetPropertyTarget(targetNode, container)) {
            return;
        }
        Element targetElement = (Element)targetNode;
        if (!StringUtils.isEmpty(sTargetProperty.value)) {
            targetElement.setProperty((Object)new StringAttr(sTargetProperty.value, sSetValue), sTargetProperty.value);
        } else if (targetNode instanceof TextValue) {
            ((TextValue)targetNode).setValue(sSetValue);
        } else if (targetElement.isPropertyValid(XFA.TEXTNODETAG) && (textNode = targetElement.getText(false, true, false)) != null) {
            textNode.setValue(sSetValue, true, false);
        }
    }

    void enableIncrementalMerge(boolean bEnableIncrementalMerge) {
        this.mbEnableIncrementalMerge = bEnableIncrementalMerge;
    }

    void enumerateScripts(List<com.adobe.xfa.ScriptInfo> scripts, String sSingleLanguage) {
        TemplateModel.enumerateScripts(this, this, scripts, sSingleLanguage);
    }

    private boolean eventOccurred(EventManager em, int nEventId, int eReason, Element container, boolean recursiveCall) {
        boolean bEventsDispatched = false;
        bEventsDispatched |= this.preExecEvent(em, nEventId, eReason, container, recursiveCall);
        bEventsDispatched |= this.execEvent(em, nEventId, eReason, container);
        return bEventsDispatched |= this.postExecEvent(em, nEventId, eReason, container);
    }

    public boolean eventOccurred(String sActivity, Obj container) {
        Element node;
        int eReason = ScriptHandler.stringToExecuteReason(sActivity);
        EventManager em = this.getEventManager();
        int nId = em.getEventID(sActivity);
        if (container instanceof Element && (node = (Element)container).getModel() == this) {
            return this.eventOccurred(em, nId, eReason, node, false);
        }
        return em.eventOccurred(nId, container);
    }

    private boolean execEvent(EventManager em, int nEventId, int eReason, Node node) {
        int ePresence;
        Container container;
        int eAccess;
        if (eReason == 15 && !node.isSameClass(XFA.SUBFORMTAG)) {
            return false;
        }
        if (eReason > 22 && eReason < 32 && this.mTemplateModel != null && !this.mTemplateModel.getLegacySetting(AppModel.XFA_LEGACY_V27_EVENTMODEL) && node instanceof Container && ((Container)node).isValidAttr(XFA.ACCESSTAG, false, null) && (eAccess = (container = (Container)node).getRuntimeAccess(0)) == 65536) {
            return false;
        }
        if (this.mTemplateModel != null && this.mTemplateModel.getOriginalXFAVersion() >= 30 && node instanceof Container && 1076494339 == (ePresence = (container = (Container)node).getRuntimePresence(0))) {
            return false;
        }
        return em.eventOccurred(nEventId, node);
    }

    public void exportConnectionData(String strConnectionName, String sDataDescriptionName) {
        Node old;
        AppModel appModel = (AppModel)this.getXFAParent();
        this.mDataModel = DataModel.getDataModel(appModel, false, false);
        DataNode connectionDataNode = (DataNode)this.resolveNode("!connectionData");
        if (connectionDataNode == null) {
            connectionDataNode = (DataNode)this.mDataModel.createChild(false, "connectionData");
        }
        if ((old = connectionDataNode.resolveNode(strConnectionName, false, false, true)) != null) {
            old.remove();
        }
        DataNode exportDataRoot = new DataNode(connectionDataNode, null);
        String internedConnectionName = strConnectionName.intern();
        exportDataRoot.setDOMProperties(null, internedConnectionName, internedConnectionName, null);
        Node dataDescription = null;
        for (Node dataModelChild = this.mDataModel.getFirstXFAChild(); dataModelChild != null; dataModelChild = dataModelChild.getNextXFASibling()) {
            Element dataModelChildElement;
            int index;
            if (!(dataModelChild instanceof Element) || (dataModelChildElement = (Element)dataModelChild).getNS() != "http://ns.adobe.com/data-description/" || dataModelChildElement.getName() != "dataDescription" || (index = dataModelChildElement.findAttr("http://ns.adobe.com/data-description/", "name")) == -1 || !dataModelChildElement.getAttrVal(index).equals(sDataDescriptionName)) continue;
            dataDescription = dataModelChild;
            break;
        }
        if (dataDescription == null) {
            return;
        }
        DataNode dataDescriptionRoot = (DataNode)dataDescription.resolveNode(strConnectionName, false, false, true);
        if (dataDescriptionRoot == null) {
            return;
        }
        exportDataRoot.setDataDescription(dataDescriptionRoot);
        this.mDataModel.initFromDataDescription(exportDataRoot);
        FormModel.recurseConnectOnNode(this, strConnectionName, 6225920, mConnectExportHandler, null);
        DataModel.removeDDPlaceholderFlags(exportDataRoot, true);
    }

    private Element findDescendantMatch(List<Container> list, Element dataParent, Element connectionDataParent) {
        if (!this.mbWeightedData && this.mStartNode != null) {
            this.mStartNode.setWeight(1);
            this.mbWeightedData = true;
        }
        Container targetNode = null;
        int nWeight = 0;
        int nCount = list.size();
        for (int i = 0; i < nCount; ++i) {
            Container templateNode = list.get(i);
            Container.FormInfo formInfo = this.getFormInfo(templateNode, dataParent, connectionDataParent);
            int nNewWeight = 0;
            DataNode dataNode = this.findMatch(formInfo, true, DatasetSelector.MAIN_DATASET);
            if (dataNode != null) {
                nNewWeight = dataNode.getWeight();
            } else if (formInfo.eMergeType == 2031616 || this.mbGlobalConsumption) {
                IntegerHolder newWeight = new IntegerHolder(nNewWeight);
                this.hasDescendantMatch(templateNode, dataParent, connectionDataParent, formInfo.eMergeType, false, newWeight);
                nNewWeight = newWeight.value;
            }
            if (nNewWeight <= 0 || nWeight != 0 && nNewWeight >= nWeight) continue;
            nWeight = nNewWeight;
            targetNode = templateNode;
        }
        return targetNode;
    }

    private Node findGlobalNode(Element templateNode, Element dataParent, IntegerHolder nCount, DataWindow dataWindow) {
        Node match = null;
        for (Node dataChild = dataParent.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
            if (FormModel.isMappable(templateNode, dataChild, true, false)) {
                ++nCount.value;
                match = dataChild;
            }
            if (dataChild.getClassTag() == XFA.DATAGROUPTAG) {
                if (dataWindow != null && dataWindow.isRecordGroup((DataNode)dataChild)) continue;
                Node temp = this.findGlobalNode(templateNode, (DataNode)dataChild, nCount, dataWindow);
                if (temp != null) {
                    match = temp;
                }
            }
            if (match != null && (dataWindow == null || dataWindow.recordAbsIndex(0) == nCount.value)) break;
        }
        return match;
    }

    DataNode findMatch(Container.FormInfo formInfo, boolean bUnMappedOnly, DatasetSelector eDataset) {
        if (formInfo == null || formInfo.eMergeType == 2031616) {
            return null;
        }
        if (formInfo.eMergeType == 2031618 && bUnMappedOnly) {
            return null;
        }
        NodeList list = null;
        switch (eDataset) {
            case MAIN_DATASET: {
                list = formInfo.dataNodes;
                break;
            }
            case ALT_DATASET: {
                list = formInfo.altDataNodes;
                break;
            }
            default: {
                assert (false);
                break;
            }
        }
        Container templateNode = formInfo.templateContainerNode;
        while (list.length() > 0) {
            DataNode dataNode = (DataNode)list.item(0);
            if (this.mergeMode() == 9175040) {
                if (formInfo.bRemoveAfterUse && dataNode.isMapped() || !FormModel.isMappable(templateNode, dataNode, false, false)) {
                    list.remove(dataNode);
                    continue;
                }
                if (bUnMappedOnly && !dataNode.isMapped() || !bUnMappedOnly) {
                    return dataNode;
                }
                return null;
            }
            if (this.mergeMode() != 9175041) continue;
            return dataNode;
        }
        if (formInfo.eMergeType == 2031617) {
            Element parent;
            boolean bAdded = false;
            while (!bAdded && formInfo.scopeData != null && this.mDataModel != (parent = formInfo.scopeData.getXFAParent())) {
                formInfo.scopeData = parent;
                if (formInfo.scopeData == null || formInfo.scopeData.getModel() != this.mDataModel) break;
                if (FormModel.getAssociation(parent, templateNode.getName(), list)) continue;
                for (Node dataChild = formInfo.scopeData.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
                    DataWindow dataWindow;
                    if (!FormModel.isMappable(templateNode, dataChild, true, true) || dataChild.getClassTag() == XFA.DATAGROUPTAG && (dataWindow = this.mDataModel.getDataWindow()) != null && dataWindow.isRecordGroup((DataNode)dataChild)) continue;
                    list.append(dataChild);
                    bAdded = true;
                }
            }
            if (bAdded) {
                return this.findMatch(formInfo, bUnMappedOnly, eDataset);
            }
        }
        return null;
    }

    private Node findUnMappedOverlayDataChild(Node dormNode, Node dataParent) {
        for (Node dataChild = dataParent.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
            if (!FormModel.isMappableForOverlayData(dormNode, dataChild, true)) continue;
            return dataChild;
        }
        return null;
    }

    public boolean getAdjustData() {
        return this.mbAdjustData;
    }

    public String getAmbientLocale() {
        return this.msLocale;
    }

    @Override
    public String getBaseNS() {
        return "http://www.xfa.org/schema/xfa-form/";
    }

    ScriptInfo getCalculateInfo(ProtoableNode node) {
        assert (node != null);
        Element calcProp = node.getElement(XFA.CALCULATETAG, true, 0, false, false);
        if (calcProp == null) {
            return null;
        }
        return this.getScriptInfo(node, calcProp);
    }

    public boolean getCalculationsEnabled() {
        if (this.mbIgnoreCalcEnabledFlag) {
            return true;
        }
        if (this.mHostPseudoModel != null) {
            return this.mHostPseudoModel.getCalculationsEnabled();
        }
        return true;
    }

    String getConnectionName() {
        return this.msConnectionName;
    }

    private String getDataRef(Element node, String sConnect, BooleanHolder bIsConnect) {
        Element bind;
        String sDataRef = "";
        if (bIsConnect != null) {
            bIsConnect.value = false;
        }
        if ((bind = node.getElement(XFA.BINDTAG, true, 0, false, false)) != null) {
            sDataRef = bind.getAttribute(XFA.REFTAG).toString();
        }
        if (!StringUtils.isEmpty(sConnect)) {
            StringHolder strConnectionRootRef = new StringHolder();
            StringHolder strConnectRef = new StringHolder();
            if (FormModel.getConnectSOMStrings(node, this.msConnectionName, 6225921, strConnectionRootRef, strConnectRef, null)) {
                sDataRef = strConnectRef.value;
            }
            if (bIsConnect != null && !StringUtils.isEmpty(strConnectRef.value)) {
                bIsConnect.value = true;
            }
        }
        return sDataRef;
    }

    public Validate getDefaultValidate() {
        return this.mDefaultValidate;
    }

    @Override
    public Obj getDelta(Element node, String sSOM) {
        Element delta = null;
        FormSubform deltaSubform = this.getDeltaSubform();
        if (deltaSubform != null) {
            String sSOM2 = node.getSOMExpression(this.mRootFormSubform, false);
            delta = (Element)deltaSubform.resolveNode(sSOM2, true, false, false);
        }
        return new Delta(node, delta, sSOM);
    }

    public Obj getDeltas(Element node) {
        Element delta;
        String sSOM;
        XFAList list = new XFAList();
        FormSubform deltaSubform = this.getDeltaSubform();
        if (deltaSubform != null && (delta = (Element)deltaSubform.resolveNode(sSOM = node.getSOMExpression(this.mRootFormSubform, false), true, false, false)) != null && delta.isSameClass(node)) {
            node.getDeltas(delta, list);
        }
        return list;
    }

    FormSubform getDeltaSubform() {
        return this.mDeltasSubform;
    }

    boolean getMatchDescendantsOnly() {
        return this.mbMatchDescendantsOnly;
    }

    boolean getEmptyMerge() {
        return this.mbEmptyMerge;
    }

    public Execute getExecute() {
        return this.mExecute;
    }

    ExecuteInfo getExecuteInfo(ProtoableNode node, Node eventNode) {
        Node executeNode = null;
        String sEventContext = "$";
        if (!eventNode.isSameClass(XFA.EVENTTAG)) {
            return null;
        }
        Element eventElement = (Element)eventNode;
        executeNode = eventElement.getOneOfChild(true, false);
        sEventContext = eventElement.getAttribute(XFA.REFTAG).toString();
        if (executeNode == null || !executeNode.isSameClass(XFA.EXECUTETAG)) {
            return null;
        }
        return new ExecuteInfo(sEventContext, node);
    }

    public FormField getFocus() {
        return this.mActiveField;
    }

    Container.FormInfo getFormInfo(Node templateNode, Element dataParent, Element connectionDataParent) {
        if (templateNode == null) {
            return null;
        }
        if (dataParent != null && dataParent.getModel() != this.mDataModel) {
            return null;
        }
        if (templateNode instanceof Container) {
            Container container = (Container)templateNode;
            Container.FormInfo formInfo = container.getFormInfo();
            if (formInfo != null && formInfo.dataParent == dataParent && formInfo.connectionDataParent == connectionDataParent) {
                return formInfo;
            }
            BooleanHolder bAssociation = new BooleanHolder(false);
            boolean bConnectDataRef = false;
            int eMergeType = this.mergeType(container, this.msConnectionName, null);
            if (eMergeType == 2031617 || eMergeType == 2031620) {
                ArrayNodeList list = new ArrayNodeList();
                if (dataParent != null) {
                    if (this.mergeMode() == 9175041 && FormModel.getAssociation(dataParent, container.getName(), list)) {
                        bAssociation.value = true;
                    } else {
                        boolean bMatchAll = true;
                        int nTargetIndex = 0;
                        if (this.mergeMode() == 9175041 && templateNode.getSibling(1, true, false) != null) {
                            bMatchAll = false;
                            nTargetIndex = templateNode.getIndex(true);
                        }
                        int nCurrIndex = 0;
                        for (Node dataChild = dataParent.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
                            if (!FormModel.isMappable(container, dataChild, true, true)) continue;
                            if (bMatchAll || nCurrIndex == nTargetIndex) {
                                list.append(dataChild);
                                continue;
                            }
                            ++nCurrIndex;
                        }
                    }
                }
                this.setFormInfo(container, dataParent, list, bAssociation.value, eMergeType, true, bConnectDataRef, connectionDataParent, null);
            } else if (eMergeType == 2031619) {
                boolean bSomIsAbsolute;
                int eDataMergeType;
                BooleanHolder bConnectDataRef2 = new BooleanHolder();
                String sSom = this.getDataRef(container, this.msConnectionName, bConnectDataRef2);
                boolean bl = bSomIsAbsolute = !FormModel.somIsRelative(sSom);
                if (formInfo != null && bSomIsAbsolute) {
                    return formInfo;
                }
                ListBase dataNodes = new ArrayNodeList();
                Element resolveContext = null;
                resolveContext = bConnectDataRef2.value ? connectionDataParent : dataParent;
                if (resolveContext == null && bSomIsAbsolute && this.mergeMode() == 9175041) {
                    resolveContext = this.mStartNode;
                }
                if (resolveContext != null) {
                    dataNodes = resolveContext.resolveNodes(sSom, true, false, true, null, bAssociation);
                }
                if (this.mergeMode() == 9175041) {
                    for (int i = dataNodes.length() - 1; i >= 0; --i) {
                        Node candidate = (Node)dataNodes.item(i);
                        if (FormModel.isMappable(container, candidate, false, false)) continue;
                        dataNodes.remove(candidate);
                    }
                }
                ArrayNodeList altDataNodes = new ArrayNodeList();
                if (bConnectDataRef2.value && ((eDataMergeType = this.mergeType(container, "", null)) == 2031617 || eDataMergeType == 2031620) && dataParent != null) {
                    if (this.mergeMode() == 9175041 && FormModel.getAssociation(dataParent, container.getName(), altDataNodes)) {
                        bAssociation.value = true;
                    } else {
                        for (Node dataChild = dataParent.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
                            if (!FormModel.isMappable(container, dataChild, true, true)) continue;
                            altDataNodes.append(dataChild);
                        }
                    }
                }
                this.setFormInfo(container, dataParent, (NodeList)dataNodes, bAssociation.value, eMergeType, FormModel.isSomMultiple(sSom), bConnectDataRef2.value, connectionDataParent, altDataNodes);
            } else if (eMergeType == 2031618) {
                if (formInfo == null) {
                    boolean bUseDV = FormModel.useDV(templateNode);
                    ArrayNodeList dataNodes = new ArrayNodeList();
                    DataNode dataNode = this.resolveGlobal(container, bUseDV);
                    if (dataNode != null) {
                        dataNodes.append(dataNode);
                    }
                    this.setFormInfo(container, dataParent, dataNodes, bAssociation.value, eMergeType, false, false, null, null);
                }
            } else if (eMergeType == 2031616) {
                this.setFormInfo(container, dataParent, null, bAssociation.value, eMergeType, false, false, connectionDataParent, null);
            }
            Container.FormInfo ret = container.getFormInfo();
            assert (ret != null);
            return ret;
        }
        return null;
    }

    NodeList getFormNodes(Node dataNode) {
        ArrayNodeList ret = new ArrayNodeList();
        if (dataNode != null) {
            int nPeer = 0;
            Peer peer = dataNode.getPeer(nPeer);
            while (peer != null) {
                Element formNode;
                if (peer instanceof FormDataListener && (formNode = ((FormDataListener)peer).getFormNode()) != null) {
                    ret.append(formNode);
                }
                peer = dataNode.getPeer(++nPeer);
            }
        }
        return ret;
    }

    public boolean getFormStateRemoved() {
        return this.mbFormStateRemoved;
    }

    boolean getFormStateUsage() {
        return this.mbFormStateUsage;
    }

    public String getFriendlyName(Element formNode) {
        assert (formNode instanceof FormSubform || formNode instanceof FormField || formNode instanceof FormExclGroup);
        String sReturnVal = "";
        if (formNode instanceof FormSubform || formNode instanceof FormField || formNode instanceof FormExclGroup) {
            Element assist = null;
            int ePriority = 6160384;
            boolean bDisableSpeak = false;
            if (formNode.isPropertySpecified(XFA.ASSISTTAG, true, 0) && (assist = formNode.getElement(XFA.ASSISTTAG, true, 0, false, false)) != null && assist.isPropertySpecified(XFA.SPEAKTAG, true, 0)) {
                Element speak = assist.peekElement(XFA.SPEAKTAG, false, 0);
                if (speak != null && speak.isPropertySpecified(XFA.DISABLETAG, true, 0) && speak.getEnum(XFA.DISABLETAG) == 1074003969) {
                    bDisableSpeak = true;
                }
                if (speak != null && speak.isPropertySpecified(XFA.PRIORITYTAG, true, 0) && speak.isPropertySpecified(XFA.PRIORITYTAG, true, 0)) {
                    ePriority = speak.getEnum(XFA.PRIORITYTAG);
                }
            }
            int[] props = new int[4];
            if (ePriority == 6160384) {
                props[0] = XFA.SPEAKTAG;
                props[1] = XFA.TOOLTIPTAG;
                props[2] = XFA.CAPTIONTAG;
                props[3] = XFA.NAMETAG;
            } else if (ePriority == 6160385) {
                props[0] = XFA.TOOLTIPTAG;
                props[1] = XFA.SPEAKTAG;
                props[2] = XFA.CAPTIONTAG;
                props[3] = XFA.NAMETAG;
            } else if (ePriority == 6160386) {
                props[0] = XFA.CAPTIONTAG;
                props[1] = XFA.SPEAKTAG;
                props[2] = XFA.TOOLTIPTAG;
                props[3] = XFA.NAMETAG;
            } else {
                props[0] = XFA.NAMETAG;
                props[1] = XFA.SPEAKTAG;
                props[2] = XFA.TOOLTIPTAG;
                props[3] = XFA.CAPTIONTAG;
            }
            for (int nIndex = 0; nIndex < 4; ++nIndex) {
                TextNode text;
                int nProp = props[nIndex];
                if (nProp == XFA.SPEAKTAG && !bDisableSpeak) {
                    ProtoableNode speak;
                    if (assist == null || !assist.isPropertySpecified(XFA.SPEAKTAG, true, 0) || (speak = (ProtoableNode)assist.peekElement(XFA.SPEAKTAG, false, 0)) == null || (text = speak.getText(true, false, false)) == null) continue;
                    sReturnVal = text.getValue();
                    break;
                }
                if (nProp == XFA.TOOLTIPTAG) {
                    ProtoableNode tooltip;
                    if (assist == null || !assist.isPropertySpecified(XFA.TOOLTIPTAG, true, 0) || (tooltip = (ProtoableNode)assist.peekElement(XFA.TOOLTIPTAG, false, 0)) == null || (text = tooltip.getText(true, false, false)) == null) continue;
                    sReturnVal = text.getValue();
                    break;
                }
                if (nProp == XFA.CAPTIONTAG) {
                    Content captionContent;
                    Value value;
                    Element caption = formNode.getElement(XFA.CAPTIONTAG, true, 0, false, false);
                    if (caption == null || (value = (Value)caption.peekElement(XFA.VALUETAG, false, 0)) == null || (captionContent = (Content)value.getOneOfChild(true, false)) == null) continue;
                    if (captionContent.getClassTag() == XFA.EXDATATAG) {
                        sReturnVal = ((ExDataValue)captionContent).getValue(false, false, false);
                        break;
                    }
                    TextNode text2 = captionContent.getText(true, false, false);
                    if (text2 == null) continue;
                    sReturnVal = text2.getValue();
                    break;
                }
                if (nProp != XFA.NAMETAG) continue;
                sReturnVal = formNode.getAttribute(XFA.NAMETAG).toString();
                break;
            }
        }
        return sReturnVal;
    }

    @Override
    public String getHeadNS() {
        return "http://www.xfa.org/schema/xfa-form/2.8/";
    }

    public HostPseudoModel getHost() {
        return this.mHostPseudoModel;
    }

    private int getOccurAttribute(Element templateNode, int eTag) {
        int nValue = 1;
        if (this.mbIsXFAF ? !(templateNode instanceof Subform) || templateNode.getXFAParent() != this.mRootSubform : !(templateNode instanceof Subform) && !(templateNode instanceof SubformSet)) {
            return nValue;
        }
        Element occur = templateNode.getElement(XFA.OCCURTAG, true, 0, false, false);
        if (occur != null) {
            Int value = (Int)occur.getAttribute(eTag);
            nValue = value.getValue();
        }
        return nValue;
    }

    public boolean getOverlayDataMergeUsage() {
        return this.mbOverlayDataMergeUsage;
    }

    public int getPanelToMergeAgainst() {
        return this.mnPanel;
    }

    void getPanelSubforms(Node container, NodeList panelSFList) {
        if (container != null) {
            if (container instanceof Subform == container.getXFAParent() instanceof FormModel) {
                for (Node child = container.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                    if (child == null) continue;
                    if (child instanceof Subform) {
                        panelSFList.append(child);
                        continue;
                    }
                    if (!(child instanceof SubformSet)) continue;
                    this.getPanelSubforms(child, panelSFList);
                }
            } else assert (false);
        }
    }

    void getPanelSubforms(NodeList panelSFList) {
        for (Node topSubform = this.getFirstXFAChild(); topSubform != null; topSubform = topSubform.getNextXFASibling()) {
            if (!(topSubform instanceof Subform)) continue;
            this.getPanelSubforms(topSubform, panelSFList);
            break;
        }
    }

    public PostMergeHandler getPostMergeHandler() {
        return this.mPostMergeHandler;
    }

    @Override
    public List<ProtoableNode> getProtoList() {
        return this.mTemplateModel.getProtoList();
    }

    public int getRunScripts() {
        return this.meRunAtSetting;
    }

    ScriptInfo getScriptInfo(ProtoableNode node, Element eventNode) {
        Element scriptNode = null;
        if (eventNode == null) {
            return null;
        }
        String sEventContext = "$";
        if (eventNode.isSameClass(XFA.EVENTTAG)) {
            scriptNode = (Element)eventNode.getOneOfChild(true, false);
            sEventContext = eventNode.getAttribute(XFA.REFTAG).toString();
        } else {
            scriptNode = eventNode.getElement(XFA.SCRIPTTAG, true, 0, false, false);
        }
        if (scriptNode == null || !scriptNode.isSameClass(XFA.SCRIPTTAG)) {
            return null;
        }
        String sBinding = scriptNode.getAttribute(XFA.BINDINGTAG).toString();
        if (!StringUtils.isEmpty(sBinding) && !sBinding.equals("XFA")) {
            return null;
        }
        Attribute oRunAt = scriptNode.getAttribute(XFA.RUNATTAG);
        int eRunAt = ((EnumValue)oRunAt).getInt();
        String sScriptType = scriptNode.getAttribute(XFA.CONTENTTYPETAG).toString();
        TextNode scriptText = scriptNode.getText(true, false, false);
        if (scriptText == null) {
            return null;
        }
        String sScriptText = scriptText.getValue();
        return new ScriptInfo(sScriptText, sScriptType, sEventContext, eRunAt, node);
    }

    @Override
    public ScriptTable getScriptTable() {
        return FormModelScript.getScriptTable();
    }

    public ServerExchange getServerExchange() {
        return this.mServerExchange;
    }

    public Submit getSubmit() {
        return this.mSubmit;
    }

    private SubmitInfo getSubmitInfo(ProtoableNode node, Node eventNode) {
        Element submitNode = null;
        String sEventContext = "$";
        if (!eventNode.isSameClass(XFA.EVENTTAG)) {
            return null;
        }
        Element eventElement = (Element)eventNode;
        submitNode = (Element)eventElement.getOneOfChild(true, false);
        sEventContext = eventElement.getAttribute(XFA.REFTAG).toString();
        if (submitNode == null || !submitNode.isSameClass(XFA.SUBMITTAG)) {
            return null;
        }
        return new SubmitInfo(sEventContext, node);
    }

    public String getSubmitURL() {
        return this.msSubmitURL;
    }

    Validate getValidate() {
        return this.mValidate;
    }

    private ValidateInfo getValidateInfo(ProtoableNode node) {
        Node currentUI;
        Element ui;
        Attribute attr;
        if (this.getOverlayDataMergeUsage()) {
            int nPanel = this.getPanelToMergeAgainst();
            if (node.isSameClass(XFA.FIELDTAG) || node.isSameClass(XFA.SUBFORMTAG) || node.isSameClass(XFA.EXCLGROUPTAG)) {
                boolean bIsTopSubform;
                Node topSubform = this.getFirstXFAChild();
                boolean bl = bIsTopSubform = node == topSubform;
                if (!bIsTopSubform) {
                    int nIndex;
                    Element panelSubform = null;
                    if (node.isSameClass(XFA.SUBFORMTAG)) {
                        panelSubform = node;
                    }
                    for (Element parent = node.getXFAParent(); parent != null && parent != topSubform; parent = parent.getXFAParent()) {
                        if (!parent.isSameClass(XFA.SUBFORMTAG)) continue;
                        panelSubform = parent;
                    }
                    if (panelSubform != null && (nIndex = panelSubform.getClassIndex()) != nPanel) {
                        return null;
                    }
                }
            }
        }
        Element validateNode = node.getElement(XFA.VALIDATETAG, true, 0, false, false);
        String sBarcodeType = "";
        if (validateNode == null && node.isSameClass(XFA.FIELDTAG) && (ui = node.getElement(XFA.UITAG, true, 0, false, false)) != null && (currentUI = ui.getOneOfChild(true, false)) != null && currentUI.isSameClass(XFA.BARCODETAG) && (attr = ((Element)currentUI).getAttribute(XFA.TYPETAG)) != null) {
            sBarcodeType = attr.toString();
        }
        if (validateNode == null && !StringUtils.isEmpty(sBarcodeType)) {
            return new ValidateInfo(null, null, "$", sBarcodeType, 1079836672, node);
        }
        if (validateNode == null) {
            return null;
        }
        Element scriptNode = validateNode.getElement(XFA.SCRIPTTAG, true, 0, false, false);
        Element pictureNode = validateNode.getElement(XFA.PICTURETAG, true, 0, false, false);
        boolean bNullTest = validateNode.getEnum(XFA.NULLTESTTAG) != 3670016;
        boolean bFormatTest = validateNode.getEnum(XFA.FORMATTESTTAG) != 3670016 && pictureNode != null;
        String sScriptType = null;
        String sScriptText = null;
        int eRunAt = 1079836674;
        if (scriptNode != null && scriptNode.isSameClass(XFA.SCRIPTTAG)) {
            TextNode scriptTextNode;
            Attribute runAt = scriptNode.getAttribute(XFA.RUNATTAG);
            eRunAt = ((EnumValue)runAt).getInt();
            sScriptType = scriptNode.getAttribute(XFA.CONTENTTYPETAG).toString();
            String sBinding = scriptNode.getAttribute(XFA.BINDINGTAG).toString();
            if ((StringUtils.isEmpty(sBinding) || sBinding.equals("XFA")) && (scriptTextNode = scriptNode.getText(true, false, false)) != null) {
                sScriptText = scriptTextNode.getValue();
            }
        }
        if (sScriptText == null && !bNullTest && !bFormatTest) {
            return null;
        }
        return new ValidateInfo(sScriptText, sScriptType, "$", null, eRunAt, node);
    }

    public boolean getValidationsEnabled() {
        if (this.mbIgnoreValidationsEnabledFlag) {
            return true;
        }
        if (this.mHostPseudoModel != null) {
            return this.mHostPseudoModel.getValidationsEnabled();
        }
        return true;
    }

    private boolean hasDescendantMatch(Element templateNode, Element dataParent, Element connectionDataParent, int eMergeType, boolean bConnectOnly, IntegerHolder weight) {
        if (templateNode instanceof Field || templateNode instanceof Draw || templateNode instanceof ExclGroup && eMergeType != 2031616) {
            return false;
        }
        if (eMergeType == 2031618 || eMergeType == 2031619) {
            bConnectOnly = true;
        }
        if (bConnectOnly && StringUtils.isEmpty(this.msConnectionName)) {
            return false;
        }
        if (bConnectOnly) {
            dataParent = null;
        }
        boolean bMatchFound = false;
        for (Node templateChild = templateNode.getFirstXFAChild(); templateChild != null; templateChild = templateChild.getNextXFASibling()) {
            Container.FormInfo info = this.getFormInfo(templateChild, dataParent, connectionDataParent);
            if (info == null) continue;
            DataNode dataNode = this.findMatch(info, true, DatasetSelector.MAIN_DATASET);
            if (dataNode != null && (!bConnectOnly || info.bConnectDataRef)) {
                int nNewWeight;
                if (weight != null && (nNewWeight = dataNode.getWeight()) > 0 && (weight.value == 0 || nNewWeight < weight.value)) {
                    weight.value = nNewWeight;
                }
                bMatchFound = true;
            } else if (info.eMergeType == 2031616 || this.mbGlobalConsumption) {
                bMatchFound |= this.hasDescendantMatch((Element)templateChild, dataParent, connectionDataParent, info.eMergeType, bConnectOnly, weight);
            }
            if (weight == null && bMatchFound) break;
        }
        return bMatchFound;
    }

    public void importConnectionData(String strConnectionName) {
        BooleanHolder allowed = new BooleanHolder(true);
        FormModel.recurseConnectOnNode(this, strConnectionName, 6225921, mConnectImportPermCheckHandler, allowed);
        if (!allowed.value) {
            MsgFormatPos message = new MsgFormatPos(ResId.PermissionsViolationExceptionMethod);
            message.format("execute");
            throw new ExFull(message);
        }
        FormModel.recurseConnectOnNode(this, strConnectionName, 6225921, mConnectImportHandler, null);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public Element importNode(ProtoableNode templateNode, Element formParent, boolean bFull) {
        boolean bWasAllowingNewNodes = this.allowNewNodes(true);
        boolean bOldAdjustData = this.mbAdjustData;
        if (formParent == null) {
            this.mbAdjustData = false;
        }
        ProtoableNode newFormNode = (ProtoableNode)this.createNode(templateNode.getClassTag(), formParent, "", "", true);
        String aNodeName = templateNode.getName();
        if (aNodeName != null && "" != aNodeName) {
            newFormNode.privateSetName(aNodeName);
        }
        FormModel.outputTraceMessage(ResId.NodeCreatedTrace, newFormNode, null, "");
        newFormNode.setProto(templateNode);
        if (bFull) {
            DataNode dataParent;
            Element mappedParent = FormModel.getMappedParent(newFormNode);
            dataParent = null;
            if (mappedParent != null) {
                dataParent = FormModel.getDataNode(mappedParent);
            }
            if (dataParent == null) {
                dataParent = this.mDataModel.getDataRoot();
            }
            for (Node templateChild = templateNode.getFirstXFAChild(); templateChild != null; templateChild = templateChild.getNextXFASibling()) {
                if (!(templateChild instanceof Element)) continue;
                Element templateChildElement = (Element)templateChild;
                FormInstanceManager newInstanceManager = this.createInstanceManager(templateChildElement, newFormNode);
                if (this.mbEmptyMerge) {
                    this.createEmptyFormNode(templateChildElement, newFormNode, null, newInstanceManager);
                    continue;
                }
                this.createAndMatchNode(templateChildElement, dataParent, newFormNode, null);
            }
            FormSubform deltaSubform = this.getDeltaSubform();
            if (deltaSubform != null) {
                this.isLoading(true);
                try {
                    String sSOM = newFormNode.getSOMExpression(this.mRootFormSubform, false);
                    Element delta = (Element)deltaSubform.resolveNode(sSOM, true, false, false);
                    XFAList list = new XFAList();
                    if (delta != null && delta.isSameClass(newFormNode)) {
                        if (this.mbRestoreDeltas) {
                            newFormNode.getDeltas(delta, list);
                        } else {
                            newFormNode.getDeltas(delta, null);
                        }
                        int nLen = list.length();
                        for (int i = 0; i < nLen; ++i) {
                            Delta deltaNode = (Delta)list.item(i);
                            deltaNode.restore();
                        }
                    }
                }
                finally {
                    this.isLoading(false);
                }
            }
            this.mergeSecondPass(newFormNode, dataParent);
            if (newFormNode instanceof Container) {
                this.setDynamicProperties((Container)newFormNode, "", true);
            }
        }
        this.mbAdjustData = bOldAdjustData;
        this.allowNewNodes(bWasAllowingNewNodes);
        return newFormNode;
    }

    private boolean incrementalMerge() {
        DataNode newRecord;
        if (this.mDataModel == null || this.mRootSubform == null) {
            return false;
        }
        if (this.mDataDescription == null) {
            return false;
        }
        if (!FormModel.incrementalMergeCheckDataDescription(this.mDataDescription)) {
            return false;
        }
        DataWindow dataWindow = this.mDataModel.getDataWindow();
        if (dataWindow == null || !dataWindow.isDefined()) {
            return false;
        }
        DataNode previousRecord = FormModel.getDataNode(this.mRootFormSubform);
        if (previousRecord == (newRecord = dataWindow.record(0))) {
            return false;
        }
        return this.incrementalMergeUpdateTree(previousRecord, newRecord);
    }

    private boolean incrementalMergeUpdateTree(DataNode prevDataNode, DataNode newDataNode) {
        if (!prevDataNode.isSameClass(newDataNode)) {
            return false;
        }
        if (prevDataNode.getName() != newDataNode.getName()) {
            return false;
        }
        int nPeer = 0;
        Peer peer = prevDataNode.getPeer(nPeer);
        while (peer != null) {
            if (peer instanceof FormDataListener) {
                FormDataListener listener = (FormDataListener)peer;
                Element formNode = listener.getFormNode();
                assert (newDataNode != listener.getDataNode());
                if (formNode != null) {
                    listener.setDataNode(newDataNode);
                    if (this.mergeMode() == 9175040) {
                        newDataNode.setMapped(true);
                    }
                }
            }
            peer = prevDataNode.getPeer(++nPeer);
        }
        int nPrevDataChildren = this.dataNodeChildrenCount(prevDataNode);
        int nNewDataChildren = this.dataNodeChildrenCount(newDataNode);
        if (nNewDataChildren > nPrevDataChildren) {
            return false;
        }
        List<DataNode> prevDataChildren = this.dataNodeChildren(prevDataNode);
        List<DataNode> newDataChildren = this.dataNodeChildren(newDataNode);
        int nPrev = 0;
        int nNew = 0;
        while (nPrev < nPrevDataChildren) {
            DataNode newDataChild;
            DataNode prevDataChild = prevDataChildren.get(nPrev);
            if (nPrev == nNewDataChildren) {
                if (prevDataChild.getClassTag() != XFA.DATAVALUETAG) {
                    return false;
                }
                DataNode prevDataNodeChild = prevDataChild;
                if (prevDataChild.isDefault(false)) {
                    newDataChildren.add(prevDataChild);
                    --nPrev;
                    --nPrevDataChildren;
                } else {
                    newDataChildren.add((DataNode)prevDataNodeChild.clone(newDataNode, true));
                    assert (++nNewDataChildren == nPrev + 1);
                }
            }
            if (!this.incrementalMergeUpdateTree(prevDataChild, newDataChild = newDataChildren.get(nNew))) {
                return false;
            }
            nPrevDataChildren = prevDataNode.getXFAChildCount();
            ++nPrev;
            ++nNew;
        }
        return true;
    }

    private int dataNodeChildrenCount(Node node) {
        int count = 0;
        for (Node child = node.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
            if (!(child instanceof DataNode)) continue;
            ++count;
        }
        return count;
    }

    private List<DataNode> dataNodeChildren(Node node) {
        ArrayList<DataNode> nodeList = new ArrayList<DataNode>();
        for (Node child = node.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
            if (!(child instanceof DataNode)) continue;
            nodeList.add((DataNode)child);
        }
        return nodeList;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public boolean initialize() {
        boolean bRet = false;
        if (this.mRootFormSubform != null) {
            String sInitialize = EnumAttr.getString(4915200);
            EventManager em = this.getEventManager();
            int nID = em.getEventID(sInitialize);
            bRet = this.eventOccurred(em, nID, 3, this.mRootFormSubform, false);
            try {
                this.mbRecursiveIndexChange = true;
                String sIndexChange = EnumAttr.getString(4915221);
                nID = em.getEventID(sIndexChange);
                bRet |= this.eventOccurred(em, nID, 15, this.mRootFormSubform, false);
            }
            finally {
                this.mbRecursiveIndexChange = false;
            }
        }
        return bRet;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public boolean initializeNewContentNodes() {
        boolean bEventsDispatched = false;
        String sInitialize = EnumAttr.getString(4915200);
        EventManager em = this.getEventManager();
        int nInitID = em.getEventID(sInitialize);
        int nIndexChangeID = em.getEventID(sInitialize);
        for (int i = 0; i < this.mLayoutContent.size(); ++i) {
            LayoutContentInfo layoutContentInfo = this.mLayoutContent.get(i);
            if (layoutContentInfo.mbInitializeOccurred) continue;
            layoutContentInfo.mbInitializeOccurred = true;
            bEventsDispatched |= this.eventOccurred(em, nInitID, 3, layoutContentInfo.mNode, false);
            try {
                this.mbRecursiveIndexChange = true;
                bEventsDispatched |= this.eventOccurred(em, nIndexChangeID, 15, layoutContentInfo.mNode, false);
            }
            finally {
                this.mbRecursiveIndexChange = false;
            }
        }
        return bEventsDispatched;
    }

    boolean isActivityExcluded(String activity) {
        if (this.mExcludeList != null) {
            for (int i = 0; i < this.mExcludeList.length; ++i) {
                if (!this.mExcludeList[i].equals(activity)) continue;
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean isCompatibleNS(String aNS) {
        return Model.checkforCompatibleNS(aNS, "http://www.xfa.org/schema/xfa-template/") || Model.checkforCompatibleNS(aNS, "http://www.xfa.org/schema/xfa-form/");
    }

    private static boolean isMappable(Element formNode, Node dataNode, boolean bCheckNames, boolean bUnMapped) {
        FormModel.outputTraceMessage(ResId.NodeComparedTrace, formNode, dataNode, "");
        if (bUnMapped && dataNode.isMapped()) {
            return false;
        }
        if (bCheckNames) {
            if (formNode.getName() == "") {
                return false;
            }
            if (formNode.getName() != dataNode.getName()) {
                return false;
            }
        }
        if (formNode instanceof Field && dataNode.getClassTag() != XFA.DATAVALUETAG) {
            Node currentUI;
            boolean bIsMultiSelect = false;
            Element ui = ((Field)formNode).getElement(XFA.UITAG, true, 0, false, false);
            if (ui != null && (currentUI = ui.getOneOfChild(true, false)) != null && currentUI.getClassAtom() == "choiceList" && ((Element)currentUI).getEnum(XFA.OPENTAG) == 2293763) {
                bIsMultiSelect = true;
            }
            if (!bIsMultiSelect) {
                return false;
            }
            if (bIsMultiSelect && dataNode.getClassTag() != XFA.DATAGROUPTAG) {
                return false;
            }
        }
        if (formNode instanceof Subform && dataNode.getClassTag() != XFA.DATAGROUPTAG) {
            return false;
        }
        return true;
    }

    private static boolean isMappableForOverlayData(Node formNode, Node dataNode, boolean bUnMapped) {
        if (bUnMapped && dataNode.isMapped()) {
            return false;
        }
        if (formNode.getName() == "") {
            return false;
        }
        if (formNode.getName() != dataNode.getName()) {
            return false;
        }
        if (formNode instanceof Subform && dataNode.getClassTag() != XFA.DATAGROUPTAG) {
            return false;
        }
        return true;
    }

    private static boolean isValidSetPropertyTarget(Node target, Container container) {
        if (target == null) {
            return false;
        }
        for (Node parent = target; parent != null; parent = parent.getXFAParent()) {
            if (!(parent instanceof Container) || parent != container) continue;
            return true;
        }
        return false;
    }

    private void loadDeltas() {
        Node subformChild;
        if (!this.mbForceRestore) {
            this.mbRestoreDeltas = this.mbRestoreDeltas && this.mRootSubform.getEnum(XFA.RESTORESTATETAG) == 7864321;
        }
        AppModel appModel = this.getAppModel();
        Node formNode = null;
        for (Node child = appModel.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
            if (child.getName() != "form" || !child.isSameClass(XFA.PACKETTAG)) continue;
            formNode = (Packet)child;
        }
        if (formNode == null) {
            return;
        }
        formNode.remove();
        String sCheckSum = formNode.getAttribute("checksum");
        if (!this.mbIgnoreChecksum && StringUtils.isEmpty(sCheckSum)) {
            return;
        }
        if (!(this.mbIgnoreChecksum || this.computeCheckSum().equals(sCheckSum) || this.computeCheckSum(false).equals(sCheckSum))) {
            return;
        }
        for (subformChild = formNode.getFirstXMLChild(); !(subformChild == null || subformChild instanceof Element && ((Element)subformChild).getLocalName() == "subform"); subformChild = subformChild.getNextXMLSibling()) {
        }
        if (subformChild == null) {
            return;
        }
        this.mDeltasSubform = new FormSubform(null, null);
        this.mDeltasSubform.setModel(this);
        this.mDeltasSubform.setNS(((Element)subformChild).getNS());
        this.doLoadAttributes((Element)subformChild, this.mDeltasSubform);
        this.isLoading(true);
        Generator genTag = new Generator("", "");
        for (Node child2 = subformChild.getFirstXMLChild(); child2 != null; child2 = child2.getNextXMLSibling()) {
            if (!(child2 instanceof Element) && !(child2 instanceof Chars)) continue;
            this.doLoadNode(this.mDeltasSubform, child2, genTag);
        }
        this.isLoading(false);
    }

    @Override
    protected void loadXMLImpl(Element parent, InputStream is, boolean bIgnoreAggregatingTag, Element.ReplaceContent eReplaceContent) {
        MsgFormatPos oMessage = new MsgFormatPos(ResId.UnsupportedOperationException);
        oMessage.format("loadXML");
        oMessage.format(parent.getClassAtom());
        throw new ExFull(oMessage);
    }

    boolean mapChild(Element templateNode, Element formParent) {
        boolean bPageSetTag;
        boolean bPageAreaTag = (!this.mb_IsMergedXDP || !this.mbIgnoreChecksum) && templateNode.isSameClass(XFA.PAGEAREATAG);
        boolean bProtoTag = templateNode.isSameClass(XFA.PROTOTAG);
        boolean bl = bPageSetTag = (!this.mb_IsMergedXDP || !this.mbIgnoreChecksum) && templateNode.isSameClass(XFA.PAGESETTAG);
        if (bPageAreaTag || bProtoTag || bPageSetTag || formParent == null || this.mbIsXFAF && templateNode.isSameClass(XFA.SUBFORMSETTAG)) {
            return false;
        }
        ChildReln reln = formParent.getChildReln(templateNode.getClassTag());
        if (reln.getMax() == -1) {
            return true;
        }
        return false;
    }

    private int mapOrderedSubformSet(Element templateNode, Element formParent, DataNode dataParent, Element connectionDataParent, FormInstanceManager instanceManager) {
        int nMax = this.getOccurAttribute(templateNode, XFA.MAXTAG);
        if (nMax != -1 && nMax < 1) {
            return 0;
        }
        int nRequired = this.getOccurAttribute(templateNode, XFA.MINTAG);
        int nCreated = 0;
        while (this.hasDescendantMatch(templateNode, dataParent, connectionDataParent, this.mergeType(templateNode, "", null), false, null)) {
            Element formNode = this.createFormNode(templateNode, formParent, instanceManager);
            this.createAndMatchChildren(templateNode, dataParent, formNode, connectionDataParent);
            if (nMax == -1 || ++nCreated != nMax) continue;
            break;
        }
        if (nCreated == 0) {
            nRequired = this.getOccurAttribute(templateNode, XFA.INITIALTAG);
        }
        for (int nCount = 0; nCount < (nRequired -= nCreated); ++nCount) {
            if (this.mergeMode() == 9175040) {
                this.createEmptyFormNode(templateNode, formParent, connectionDataParent, instanceManager);
            } else {
                Element formNode = this.createFormNode(templateNode, formParent, instanceManager);
                this.createAndMatchChildren(templateNode, dataParent, formNode, connectionDataParent);
            }
            ++nCreated;
        }
        return nCreated;
    }

    private int mapSubformSet(Element templateNode, Element formParent, DataNode dataParent, Element connectionDataParent) {
        boolean bSaveMatchDescendantsOnly = this.mbMatchDescendantsOnly;
        if (!this.mbGlobalConsumption) {
            this.mbMatchDescendantsOnly = true;
        }
        int nCreated = 0;
        int eRelation = ((EnumValue)templateNode.getAttribute(XFA.RELATIONTAG)).getInt();
        FormInstanceManager instanceManager = this.createInstanceManager(templateNode, formParent);
        nCreated = eRelation == -2144600064 ? this.mapOrderedSubformSet(templateNode, formParent, dataParent, connectionDataParent, instanceManager) : (eRelation == -2144600062 ? this.mapUnorderedSubformSet(templateNode, formParent, dataParent, connectionDataParent, instanceManager, true) : this.mapUnorderedSubformSet(templateNode, formParent, dataParent, connectionDataParent, instanceManager, false));
        this.mbMatchDescendantsOnly = bSaveMatchDescendantsOnly;
        return nCreated;
    }

    private int mapUnorderedSubformSet(Element templateNode, Element formParent, DataNode dataParent, Element connectionDataParent, FormInstanceManager instanceManager, boolean bIsChoice) {
        int nMax = this.getOccurAttribute(templateNode, XFA.MAXTAG);
        if (nMax != -1 && nMax < 1) {
            return 0;
        }
        int nRequired = this.getOccurAttribute(templateNode, XFA.MINTAG);
        int nCreated = 0;
        List unusedChildren = new ArrayList<Container>();
        for (Node templateChild = templateNode.getFirstXFAChild(); templateChild != null; templateChild = templateChild.getNextXFASibling()) {
            if (!(templateChild instanceof Subform) && !(templateChild instanceof SubformSet)) continue;
            unusedChildren.add((Container)((Container)templateChild));
        }
        Element targetProto = this.findDescendantMatch(unusedChildren, dataParent, connectionDataParent);
        while (targetProto != null) {
            ++nCreated;
            Element subformSet = this.createFormNode(templateNode, formParent, instanceManager);
            this.createAndMatchNode(targetProto, dataParent, subformSet, connectionDataParent);
            unusedChildren.remove(targetProto);
            if (!bIsChoice && unusedChildren.size() > 0) {
                while (unusedChildren.size() > 0 && (targetProto = this.findDescendantMatch(unusedChildren, dataParent, connectionDataParent)) != null) {
                    this.createAndMatchNode(targetProto, dataParent, subformSet, connectionDataParent);
                    unusedChildren.remove(targetProto);
                }
                for (int i = 0; i < unusedChildren.size(); ++i) {
                    Element subChild = unusedChildren.get(i);
                    if (this.mergeMode() == 9175040) {
                        this.createInstanceManager(subChild, subformSet);
                        int nRequired2 = this.getOccurAttribute(subChild, XFA.MINTAG);
                        for (int nCount = 0; nCount < nRequired2; ++nCount) {
                            this.createEmptyFormNode(subChild, subformSet, connectionDataParent, instanceManager);
                        }
                    } else {
                        this.createAndMatchNode(subChild, dataParent, subformSet, connectionDataParent);
                    }
                    unusedChildren.remove(targetProto);
                }
            }
            if (nMax != -1 && nCreated == nMax) break;
            ArrayList<Container> newList = new ArrayList<Container>();
            Node templateChild2 = templateNode.getFirstXFAChild();
            while (templateChild2 != null) {
                if (templateChild2 instanceof Subform || templateChild2 instanceof SubformSet) {
                    newList.add((Container)templateChild2);
                }
                templateChild2 = templateChild2.getNextXFASibling();
            }
            unusedChildren = newList;
            targetProto = this.findDescendantMatch(unusedChildren, dataParent, connectionDataParent);
        }
        if (nCreated == 0) {
            nRequired = this.getOccurAttribute(templateNode, XFA.INITIALTAG);
        }
        for (int nCount = 0; nCount < (nRequired -= nCreated); ++nCount) {
            if (this.mergeMode() == 9175040) {
                this.createEmptyFormNode(templateNode, formParent, connectionDataParent, instanceManager);
            } else {
                Element subformSet = this.createFormNode(templateNode, formParent, instanceManager);
                if (bIsChoice) {
                    Container subChild = unusedChildren.get(0);
                    this.createAndMatchNode(subChild, dataParent, subformSet, connectionDataParent);
                } else {
                    this.createAndMatchChildren(templateNode, dataParent, subformSet, connectionDataParent);
                }
            }
            ++nCreated;
        }
        return nCreated;
    }

    public void merge(boolean bEmptyMerge, boolean bAdjustData, boolean bInitialize, boolean bRestoreDeltas, boolean bForceRestore) {
        this.merge(bEmptyMerge, bAdjustData, "", bInitialize, bRestoreDeltas, bForceRestore);
    }

    public void merge(boolean bEmptyMerge, boolean bAdjustData, String sConnectionName, boolean bInitialize, boolean bRestoreDeltas, boolean bForceRestore) {
        this.merge(bEmptyMerge, bAdjustData, sConnectionName, bInitialize, bRestoreDeltas, bForceRestore, false, false);
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void merge(boolean bEmptyMerge, boolean bAdjustData, String sConnectionName, boolean bInitialize, boolean bRestoreDeltas, boolean bForceRestore, boolean bIgnoreChecksum, boolean bIsMergedXDP) {
        TraceTimer timer;
        block32 : {
            TraceTimer mergeOnlyTimer = new TraceTimer(TraceHandler.TimingType.XFA_MERGE_ONLY_TIMING);
            try {
                if (!this.mbEnableIncrementalMerge) {
                    FormModel.outputTraceMessage(ResId.IncrementalMergeDisabledTrace, null, null, "");
                }
                this.mbWasIncrementalMerge = false;
                if (this.mbEnableIncrementalMerge && this.mbAdjustData == bAdjustData && this.mbEmptyMerge == bEmptyMerge && this.incrementalMerge()) {
                    if (bInitialize && !this.mbExchangingDataWithServer && this.getRunScripts() != 1080754179) {
                        if (this.getXFAParent() != null && this.getEventManager() != null) {
                            this.getEventManager().reset();
                        }
                        TraceTimer timer2 = new TraceTimer(TraceHandler.TimingType.XFAPA_MERGE_CALC_TIMING);
                        try {
                            this.initialize();
                        }
                        finally {
                            timer2.stopTiming();
                        }
                    }
                    this.notifyPeers(0, "", null);
                    FormModel.outputTraceMessage(ResId.IncrementalMergeSucceededTrace, null, null, "");
                    this.mbWasIncrementalMerge = true;
                    return;
                }
                if (this.mbEnableIncrementalMerge) {
                    FormModel.outputTraceMessage(ResId.IncrementalMergeFullMergeTrace, null, null, "");
                }
                this.mActiveField = null;
                this.mPrevActiveField = null;
                if (this.mbMergeComplete) {
                    this.reset();
                }
                this.mbAdjustData = bAdjustData;
                this.mbEmptyMerge = bEmptyMerge;
                this.mbRestoreDeltas = bRestoreDeltas;
                this.mbForceRestore = bForceRestore;
                this.mbIgnoreChecksum = bIgnoreChecksum;
                this.mb_IsMergedXDP = bIsMergedXDP;
                this.preMerge(sConnectionName);
                this.mergeFirstPass();
                FormSubform deltaSubform = this.getDeltaSubform();
                if (deltaSubform == null) break block32;
                this.isLoading(true);
                try {
                    XFAList list = new XFAList();
                    if (this.mbRestoreDeltas) {
                        this.mRootFormSubform.getDeltas(deltaSubform, list);
                    } else {
                        this.mRootFormSubform.getDeltas(deltaSubform, null);
                    }
                    for (int i = 0; i < list.length(); ++i) {
                        Delta delta = (Delta)list.item(i);
                        delta.restore();
                    }
                }
                finally {
                    this.isLoading(false);
                }
            }
            finally {
                mergeOnlyTimer.stopTiming();
            }
        }
        this.mergeSecondPass(this, null);
        if (this.mPostMergeHandler != null) {
            this.mPostMergeHandler.handlePostMerge(this.mPostMergeHandlerClientData);
        }
        if (bInitialize && !this.mbExchangingDataWithServer && this.getRunScripts() != 1080754179) {
            timer = new TraceTimer(TraceHandler.TimingType.XFAPA_MERGE_CALC_TIMING);
            try {
                this.initialize();
            }
            finally {
                timer.stopTiming();
            }
        }
        this.updateFromFormState();
        this.mergeOverlayData();
        this.setDynamicProperties(this.mRootFormSubform, sConnectionName, true);
        this.mbMergeComplete = true;
        if (this.getRunScripts() != 1080754179) {
            timer = new TraceTimer(TraceHandler.TimingType.XFAPA_MERGE_CALC_TIMING);
            try {
                this.runExecEvents();
            }
            finally {
                timer.stopTiming();
            }
        }
        if (this.getFormStateUsage()) {
            this.createFormState();
        } else {
            Node formState = this.getAppModel().locateChildByName("formState", 0);
            if (formState != null) {
                for (Node stateChild = formState.getFirstXMLChild(); stateChild != null; stateChild = stateChild.getNextXMLSibling()) {
                    if (!(stateChild instanceof Element)) continue;
                    this.mbFormStateRemoved = true;
                    break;
                }
                formState.remove();
            }
        }
        this.notifyPeers(0, "", null);
    }

    private void mergeOverlayData() {
        if (this.getOverlayDataMergeUsage()) {
            int nPanel = this.getPanelToMergeAgainst();
            Node overlayData = null;
            for (Node child = this.mDataModel.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                if (child.getName() != "overlayData") continue;
                overlayData = child;
                break;
            }
            if (overlayData != null) {
                Node topSubform = this.getFirstXFAChild();
                Node targetSubform = null;
                int nCnt = 0;
                Node subformChild = topSubform.getFirstXFAChild();
                while (subformChild != null) {
                    if (subformChild instanceof FormSubform) {
                        if (nCnt == nPanel) {
                            targetSubform = subformChild;
                            break;
                        }
                        ++nCnt;
                    }
                    subformChild.getNextXFASibling();
                }
                if (targetSubform != null) {
                    this.mergeOverlayData(targetSubform, overlayData);
                    this.mDataModel.getNodes().remove(overlayData);
                } else {
                    MsgFormatPos formatError = new MsgFormatPos(ResId.OverlayDataSubformNotFound);
                    throw new ExFull(formatError);
                }
            }
        }
    }

    public void mergeOverlayData(Node formNode, Node overlayData) {
        Node formChild;
        for (formChild = formNode.getFirstXFAChild(); formChild != null; formChild = formChild.getNextXFASibling()) {
            if (!(formChild instanceof FormSubform)) continue;
            FormSubform subform = (FormSubform)formChild;
            FormInstanceManager manager = subform.getInstanceManager();
            int nCount = this.countOverlayDataChild(formChild, overlayData);
            int nInstances = manager.getCount();
            int nMin = manager.getMin();
            int nMax = manager.getMax();
            if (nCount == nInstances || nCount < nMin || nCount > nMax && nMax != -1) continue;
            manager.setInstances(nCount, true);
        }
        block1 : for (formChild = formNode.getFirstXFAChild(); formChild != null; formChild = formChild.getNextXFASibling()) {
            Node dataMatch;
            if (formChild instanceof FormSubform) {
                Node dataMatch2 = this.findUnMappedOverlayDataChild(formChild, overlayData);
                if (dataMatch2 != null) {
                    this.consumeDataNode(null, dataMatch2, DatasetSelector.MAIN_DATASET);
                    this.mergeOverlayData(formChild, dataMatch2);
                    continue;
                }
                this.mergeOverlayData(formChild, overlayData);
                continue;
            }
            if (formChild instanceof FormField) {
                Node currentUI;
                FormField field = (FormField)formChild;
                dataMatch = this.findUnMappedOverlayDataChild(formChild, overlayData);
                if (dataMatch != null) {
                    this.consumeDataNode(null, dataMatch, DatasetSelector.MAIN_DATASET);
                    NodeList dataChildren = dataMatch.getNodes();
                    int nNodes = dataChildren.length();
                    if (formChild instanceof FormChoiceListField) {
                        StringBuilder sValue = new StringBuilder();
                        for (int i = 0; i < nNodes; ++i) {
                            Node dataChildNode = (Node)dataChildren.item(i);
                            String aName = dataChildNode.getName();
                            if (aName != "value") continue;
                            sValue.append(((DataNode)dataChildNode).getValue());
                            sValue.append('\n');
                        }
                        field.setRawValue(sValue.toString());
                        break;
                    }
                    for (int i = 0; i < nNodes; ++i) {
                        Node dataChildNode = (Node)dataChildren.item(i);
                        String aName = dataChildNode.getName();
                        if (aName == "value") {
                            String sValue = ((DataNode)dataChildNode).getValue();
                            field.setRawValue(sValue);
                            continue;
                        }
                        if (aName != "formattedValue") continue;
                        String sValue = ((DataNode)dataChildNode).getValue();
                        Element valueNode = field.getElement(XFA.VALUETAG, true, 0, true, false);
                        Node contentNode = null;
                        if (valueNode != null) {
                            contentNode = valueNode.getOneOfChild(false, true);
                        }
                        StringHolder sCanon = new StringHolder();
                        if (!StringUtils.isEmpty(sValue) && contentNode != null && (contentNode.isSameClass(XFA.INTEGERTAG) || contentNode.isSameClass(XFA.FLOATTAG) || contentNode.isSameClass(XFA.DECIMALTAG))) {
                            String sPict;
                            int nWidth;
                            int nPrec;
                            int nOptn;
                            LcData data2;
                            String sLocale = field.getInstalledLocale();
                            LcData data = new LcData(sLocale);
                            if (StringUtils.isEmpty(sCanon.value)) {
                                sPict = data.getNumberFormat(0, 0);
                                PictureFmt.parseNumeric(sValue, sPict, sLocale, sCanon);
                            }
                            if (StringUtils.isEmpty(sCanon.value)) {
                                sPict = data.getNumberFormat(0, 1);
                                PictureFmt.parseNumeric(sValue, sPict, sLocale, sCanon);
                            }
                            if (StringUtils.isEmpty(sCanon.value)) {
                                nOptn = 0;
                                data2 = new LcData(sLocale);
                                nPrec = data2.getNumberPrecision(sValue);
                                nOptn |= LcData.withPrecision(nPrec | 128);
                                nWidth = sValue.length();
                                if (nWidth > 0) {
                                    nOptn |= LcData.withWidth(nWidth);
                                }
                                sPict = data2.getNumberFormat(1, nOptn);
                                PictureFmt.parseNumeric(sValue, sPict, sLocale, sCanon);
                            }
                            if (StringUtils.isEmpty(sCanon.value)) {
                                nOptn = 1;
                                data2 = new LcData(sLocale);
                                nPrec = data2.getNumberPrecision(sValue);
                                nOptn |= LcData.withPrecision(nPrec | 128);
                                nWidth = sValue.length();
                                if (nWidth > 0) {
                                    nOptn |= LcData.withWidth(nWidth);
                                }
                                sPict = data2.getNumberFormat(1, nOptn);
                                PictureFmt.parseNumeric(sValue, sPict, sLocale, sCanon);
                            }
                        }
                        if (!StringUtils.isEmpty(sCanon.value)) {
                            field.setRawValue(sCanon.value);
                            continue;
                        }
                        field.setFormattedValue(sValue);
                    }
                    this.checkForItems(field, dataMatch);
                    continue;
                }
                Element ui = field.getElement(XFA.UITAG, true, 0, false, false);
                if (ui == null || (currentUI = ui.getOneOfChild(true, false)) == null || !currentUI.isSameClass(XFA.CHECKBUTTONTAG) && !currentUI.isSameClass(XFA.CHOICELISTTAG)) continue;
                field.setOn(false);
                continue;
            }
            if (formChild instanceof FormExclGroup) {
                FormExclGroup group = (FormExclGroup)formChild;
                dataMatch = this.findUnMappedOverlayDataChild(group, overlayData);
                if (dataMatch == null) continue;
                String sValue = "";
                NodeList dataChildren = dataMatch.getNodes();
                int nDataNodes = dataChildren.length();
                for (int i = 0; i < nDataNodes; ++i) {
                    Node dataChildNode = (Node)dataChildren.item(i);
                    String aName = dataChildNode.getName();
                    if (aName != "value") continue;
                    sValue = ((DataNode)dataChildNode).getValue();
                }
                NodeList exclGroupChildren = formChild.getNodes();
                int nNodes = exclGroupChildren.length();
                for (int j = 0; j < nNodes; ++j) {
                    String sSub;
                    Node childNode = (Node)exclGroupChildren.item(j);
                    if (!(childNode instanceof FormField)) continue;
                    String sSom = childNode.getSOMExpression();
                    int nFoundAt = sSom.indexOf(46);
                    boolean bFound = nFoundAt != -1;
                    int saveFoundAt = nFoundAt;
                    if (bFound) {
                        do {
                            boolean bFound2;
                            boolean bl = bFound2 = (nFoundAt = sSom.indexOf(".", saveFoundAt + 1)) != -1;
                            if (!bFound2) break;
                            saveFoundAt = nFoundAt;
                        } while (true);
                        nFoundAt = saveFoundAt;
                    }
                    if (!(sSub = !bFound ? sSom : sSom.substring(nFoundAt + 1)).equals(sValue)) continue;
                    String sOn = ((FormField)childNode).getOnValue();
                    group.setRawValue(sOn);
                    continue block1;
                }
                continue;
            }
            if (!formNode.isContainer()) continue;
            this.mergeOverlayData(formChild, overlayData);
        }
    }

    int mergeType(Node node, String sConnect, BooleanHolder bIsConnect) {
        EnumValue eScope;
        String sDataRef;
        if (!(node.isSameClass(XFA.SUBFORMTAG) || node.isSameClass(XFA.FIELDTAG) || node.isSameClass(XFA.EXCLGROUPTAG))) {
            return 2031616;
        }
        if (node.isSameClass(XFA.SUBFORMTAG) && (eScope = (EnumValue)((Element)node).getAttribute(XFA.SCOPETAG)).getInt() == 5963777) {
            return 2031616;
        }
        boolean bCheckForRef = !StringUtils.isEmpty(sConnect);
        int eRetValue = 2031617;
        Container container = (Container)node;
        Element bind = container.getElement(XFA.BINDTAG, true, 0, false, false);
        if (bind != null) {
            EnumValue eType = (EnumValue)bind.getAttribute(XFA.MATCHTAG, true, false);
            if (eType != null) {
                eRetValue = eType.getInt();
            } else {
                bCheckForRef = true;
            }
        }
        if (bCheckForRef && !StringUtils.isEmpty(sDataRef = this.getDataRef(container, this.msConnectionName, bIsConnect))) {
            eRetValue = 2031619;
        }
        if (eRetValue == 2031619) {
            return eRetValue;
        }
        if (node.getName() == "") {
            return 2031616;
        }
        if (eRetValue == 2031617) {
            if (this.mergeMode() == 9175041) {
                eRetValue = 2031620;
            } else if (this.getMatchDescendantsOnly()) {
                eRetValue = 2031620;
            }
        }
        return eRetValue;
    }

    String metaData(int nOutputType) {
        return this.mHostPseudoModel != null ? this.mHostPseudoModel.metaData(nOutputType) : "";
    }

    @Override
    public void normalizeNameSpaces() {
        this.setNameSpaceURI("http://www.xfa.org/schema/xfa-form/2.8/", false, false, false);
        for (Node child = this.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
            if (!(child instanceof Element)) continue;
            super.normalizeNameSpaces((Element)child, "http://www.xfa.org/schema/xfa-form/2.8/");
        }
    }

    private static void outputTraceMessage(int nResId, Node inputNode1, Node inputNode2, String sInput) {
        if (!Trace.isEnabled("merge", 1)) {
            return;
        }
        MsgFormatPos msg = new MsgFormatPos(nResId);
        int nTraceLevel = 0;
        if (nResId == ResId.StartMergeDataGroup) {
            assert (inputNode1 != null);
            msg.format("'" + inputNode1.getSOMExpression() + "'");
            nTraceLevel = 1;
        } else if (nResId == ResId.FormNodeMatchedTrace) {
            assert (inputNode1 != null);
            assert (inputNode2 != null);
            msg.format(inputNode1.getClassAtom());
            msg.format("'" + inputNode1.getSOMExpression() + "'");
            msg.format(inputNode2.getClassAtom());
            msg.format("'" + inputNode2.getSOMExpression() + "'");
            nTraceLevel = 1;
        } else if (nResId == ResId.IncrementalMergeDisabledTrace) {
            nTraceLevel = 1;
        } else if (nResId == ResId.IncrementalMergeSucceededTrace) {
            nTraceLevel = 1;
        } else if (nResId == ResId.IncrementalMergeFullMergeTrace) {
            nTraceLevel = 1;
        }
        if (Trace.isEnabled("merge", 2)) {
            nTraceLevel = 2;
            if (nResId == ResId.NodeCreatedTrace) {
                assert (inputNode1 != null);
                msg.format(inputNode1.getClassAtom());
                msg.format("'" + inputNode1.getSOMExpression() + "'");
            } else if (nResId == ResId.DataNodeMoved) {
                assert (inputNode1 != null);
                assert (!StringUtils.isEmpty(sInput));
                msg.format(inputNode1.getClassAtom());
                msg.format("'" + sInput + "'");
                msg.format("'" + inputNode1.getSOMExpression() + "'");
            } else if (nResId == ResId.UnmappedNode) {
                assert (inputNode1 != null);
                msg.format(inputNode1.getClassAtom());
                msg.format("'" + inputNode1.getSOMExpression() + "'");
            }
        }
        if (Trace.isEnabled("merge", 3)) {
            nTraceLevel = 3;
            if (nResId == ResId.NodeComparedTrace) {
                assert (inputNode1 != null);
                assert (inputNode2 != null);
                msg.format("'" + inputNode1.getSOMExpression() + "'");
                msg.format("'" + inputNode2.getSOMExpression() + "'");
            }
        }
        if (nTraceLevel > 0) {
            Trace.trace("merge", nTraceLevel, msg);
        }
    }

    boolean performPreEventValidations() {
        boolean bValidationSucceeded = true;
        Validate validate = null;
        if (this.getDefaultValidate() != null) {
            validate = this.getDefaultValidate().clone();
        }
        if (validate != null) {
            validate.setFormatTestEnabled(true);
            validate.setNullTestEnabled(true);
            validate.setScriptTestEnabled(true);
        }
        this.recalculate(false, validate, true);
        this.validate(validate, null, true, true);
        if (validate != null && validate.getFailCount() != 0) {
            bValidationSucceeded = false;
        }
        return bValidationSucceeded;
    }

    private boolean postExecEvent(EventManager em, int nEventId, int eReason, Element container) {
        if (container != null && eReason == 24 && (container instanceof FormSubform || container instanceof FormExclGroup)) {
            if (this.getDefaultValidate() == null) {
                return true;
            }
            Validate validate = this.getDefaultValidate().clone();
            if (this.validate(validate, container, false, false)) {
                return true;
            }
        } else if (container != null && eReason == 3 && (container.isSameClass(XFA.SUBFORMTAG) || container.isSameClass(XFA.FIELDTAG) || container.isSameClass(XFA.EXCLGROUPTAG)) && this.fireValidationStateEvent((Container)container)) {
            return true;
        }
        return false;
    }

    @Override
    protected void postLoad() {
    }

    void mergeSecondPass(Element formParent, Element dataParent) {
        this.msConnectionName = "";
        this.mbConnectionMerge = false;
        if (this.mergeMode() == 9175040) {
            if (this.mbAdjustData && this.mDataDescription == null) {
                this.adjustData(formParent, dataParent);
            }
            this.findOrCreateMissingData();
        }
        if (this.mbMergeComplete || dataParent == null) {
            FormModel.recursiveDeleteFormInfos(this.mRootSubform, this.moContainersWithFormInfo);
            this.mExplicitMatchNodes.clear();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private boolean preExecEvent(EventManager em, int nEventId, int eReason, Node container, boolean recursiveCall) {
        boolean bRecursive;
        Element parent;
        boolean bNotifyParent;
        if (container == null || !container.isContainer() || container.getModel() == null) {
            return false;
        }
        boolean bEventDispatched = false;
        boolean bl = bRecursive = eReason == 2 || eReason == 1 || eReason == 3 || this.mbRecursiveIndexChange || eReason == 15 && !container.isSameClass(XFA.SUBFORMTAG);
        if (bRecursive && container.getClassTag() != XFA.DRAWTAG && container.getClassTag() != XFA.FIELDTAG) {
            NodeList children = (NodeList)container.getNodes().clone();
            for (int i = 0; i < children.length(); ++i) {
                Node child = (Node)children.item(i);
                if (child == null || !child.isContainer() || child.getModel() == null || !this.eventOccurred(em, nEventId, eReason, (Element)child, true)) continue;
                bEventDispatched = true;
            }
        }
        boolean bl2 = bNotifyParent = (parent = container.getXFAParent()) != null && parent.isSameClass(XFA.EXCLGROUPTAG) && !recursiveCall && (eReason == 27 || eReason == 28 || eReason == 29);
        if (bNotifyParent) {
            bEventDispatched |= this.eventOccurred(em, nEventId, eReason, parent, false);
        }
        if (eReason == 23) {
            int i;
            ArrayList<Container> exitNodes = new ArrayList<Container>();
            ArrayList<Container> enterNodes = new ArrayList<Container>();
            FormField prevField = this.mPrevActiveField;
            if (prevField != null) {
                for (Element prevAncestor = prevField.getXFAParent(); prevAncestor != null; prevAncestor = prevAncestor.getXFAParent()) {
                    if (!(prevAncestor instanceof FormSubform) && !(prevAncestor instanceof FormExclGroup)) continue;
                    exitNodes.add((Container)prevAncestor);
                }
            }
            if (container.isSameClass(XFA.FIELDTAG)) {
                if (this.mActiveField != container) {
                    return bEventDispatched;
                }
                for (Element ancestor = container.getXFAParent(); ancestor != null; ancestor = ancestor.getXFAParent()) {
                    if (!ancestor.isSameClass(XFA.SUBFORMTAG) && !ancestor.isSameClass(XFA.EXCLGROUPTAG)) continue;
                    enterNodes.add((Container)ancestor);
                }
            }
            boolean bDone = false;
            while (0 < exitNodes.size() && 0 < enterNodes.size() && !bDone) {
                if (exitNodes.get(exitNodes.size() - 1) == enterNodes.get(enterNodes.size() - 1)) {
                    exitNodes.remove(exitNodes.size() - 1);
                    enterNodes.remove(exitNodes.size() - 1);
                    continue;
                }
                bDone = true;
            }
            String sExitEvent = EnumAttr.getString(4915202);
            int nExitEventId = em.getEventID(sExitEvent);
            this.mPrevActiveField = null;
            for (i = 0; i < exitNodes.size(); ++i) {
                EventPseudoModel.EventInfo eventInfo = null;
                if (this.mEventPseudoModel != null) {
                    eventInfo = this.mEventPseudoModel.getEventInfo();
                }
                try {
                    if (this.mEventPseudoModel != null) {
                        this.mEventPseudoModel.reset();
                        this.mEventPseudoModel.setTarget((Obj)exitNodes.get(i));
                        this.mEventPseudoModel.setName(24);
                    }
                }
                finally {
                    if (this.mEventPseudoModel != null) {
                        this.mEventPseudoModel.setEventInfo(eventInfo);
                    }
                }
                bEventDispatched |= this.eventOccurred(em, nExitEventId, 24, (Element)exitNodes.get(i), false);
            }
            if (0 < enterNodes.size()) {
                for (i = 0; i < enterNodes.size(); ++i) {
                    int nIndex = enterNodes.size() - 1 - i;
                    EventPseudoModel.EventInfo eventInfo = null;
                    if (this.mEventPseudoModel != null) {
                        eventInfo = this.mEventPseudoModel.getEventInfo();
                    }
                    try {
                        if (this.mEventPseudoModel == null) continue;
                        this.mEventPseudoModel.reset();
                        this.mEventPseudoModel.setTarget((Obj)enterNodes.get(nIndex));
                        this.mEventPseudoModel.setName(eReason);
                    }
                    finally {
                        if (this.mEventPseudoModel != null) {
                            this.mEventPseudoModel.setEventInfo(eventInfo);
                        }
                    }
                }
            }
        }
        return bEventDispatched;
    }

    private void preMerge(String sConnectionName) {
        DataWindow dataWindow;
        boolean bUseEmpty = false;
        if (this.mDataModel == null) {
            AppModel appModel = (AppModel)this.getXFAParent();
            this.mDataModel = DataModel.getDataModel(appModel, true, false);
            bUseEmpty = true;
        }
        if ((dataWindow = this.mDataModel.getDataWindow()) != null && dataWindow.isDefined()) {
            this.mStartNode = dataWindow.record(0);
        }
        this.mRootSubform = null;
        this.mRootFormSubform = null;
        this.setCurrentVersion(this.mTemplateModel.getCurrentVersion());
        this.mbIsXFAF = this.mTemplateModel.getEnum(XFA.BASEPROFILETAG) == 7602177;
        for (Node templateNode = this.mTemplateModel.getFirstXFAChild(); templateNode != null; templateNode = templateNode.getNextXFASibling()) {
            if (!templateNode.isSameClass(XFA.SUBFORMTAG)) continue;
            if (this.mRootSubform == null) {
                this.mRootSubform = (Subform)templateNode;
            }
            if (this.mStartNode == null || templateNode.getName() != this.mStartNode.getName()) continue;
            this.mRootSubform = (Subform)templateNode;
            break;
        }
        if (this.mRootSubform != null) {
            this.mDataDescription = this.mDataModel.getDataDescriptionRoot(this.mRootSubform.getName());
            this.mbGlobalConsumption = this.mRootSubform.getEnum(XFA.MERGEMODETAG) == 9175040;
        }
        boolean bAppendNewNode = false;
        if (this.mStartNode == null && this.mRootSubform != null) {
            bUseEmpty = true;
            if (this.mDataDescription != null) {
                this.mStartNode = this.mDataModel.createDataRootElement(this.mDataDescription);
                if (this.mStartNode != null) {
                    bAppendNewNode = true;
                    if (this.getAppModel().getDocument().isAllDataRootsEmpty()) {
                        this.getAppModel().getDocument().setAddedRootData((Element)this.mStartNode.getXmlPeer());
                    }
                }
            }
        }
        if (this.mRootSubform != null && bUseEmpty) {
            if (this.mStartNode == null) {
                this.mStartNode = (DataNode)this.mDataModel.createNode(XFA.DATAGROUPTAG, null, this.mRootSubform.getName(), "", true);
                bAppendNewNode = this.mbAdjustData;
                if (this.getAppModel().getDocument().isAllDataRootsEmpty()) {
                    this.getAppModel().getDocument().setAddedRootData((Element)this.mStartNode.getXmlPeer());
                }
            }
            if (bAppendNewNode) {
                Element data = this.mDataModel.getAliasNode();
                if (data.getFirstXFAChild() != null) {
                    Node ref = data.getFirstXFAChild();
                    data.insertChild(this.mStartNode, ref, true);
                } else {
                    data.appendChild(this.mStartNode, true);
                }
            }
            dataWindow.addRecordGroup(this.mStartNode);
            dataWindow.updateAfterLoad();
        }
        if (this.mRootSubform == null || this.mStartNode == null) {
            MsgFormatPos msg = new MsgFormatPos(ResId.RootSubformMergeFailure);
            throw new ExFull(msg);
        }
        if (this.mDataDescription != null) {
            this.setMatchDescendantsOnly(true);
        } else {
            this.setMatchDescendantsOnly(false);
        }
        FormModel.recursiveDeleteFormInfos(this.mRootSubform, this.moContainersWithFormInfo);
        this.mbEmptyMerge = bUseEmpty;
        this.msConnectionName = sConnectionName;
        this.mbConnectionMerge = !StringUtils.isEmpty(this.msConnectionName);
        this.loadDeltas();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public void preSave(boolean bSaveXMLScript) {
        boolean previousWillDirty = this.getWillDirty();
        this.setWillDirty(false);
        try {
            if (!bSaveXMLScript) {
                String sCheckSum = this.computeCheckSum();
                if (!StringUtils.isEmpty(sCheckSum)) {
                    this.setAttribute(new StringAttr("checksum", sCheckSum), XFA.CHECKSUMTAG);
                }
                this.preSave(this.mRootFormSubform, null);
            }
            this.normalizeNameSpaces();
        }
        finally {
            this.setWillDirty(previousWillDirty);
        }
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private void preSave(Node formNode, Element dataParent) {
        if (formNode == null) {
            return;
        }
        DataNode dataNode = FormModel.getDataNode(formNode);
        if (dataNode != null && dataNode.getXFAParent() != null && !dataNode.isDefault(false)) {
            if (formNode.isSameClass(XFA.FIELDTAG)) {
                Element value = ((Element)formNode).getElement(XFA.VALUETAG, 0);
                if (value.getEnum(XFA.OVERRIDETAG) == 1074003969) {
                    value.getOneOfChild().isTransient(true, false);
                    value.isTransient(false, false);
                    value.makeNonDefault(false);
                } else {
                    value.isTransient(true, false);
                }
            }
            dataParent = dataNode;
        }
        if (formNode.isSameClass(XFA.FIELDTAG)) {
            Node currentUI;
            Element fieldElement = (Element)formNode;
            Element value = fieldElement.getElement(XFA.VALUETAG, 0);
            Element ui = fieldElement.getElement(XFA.UITAG, true, 0, false, false);
            if (ui != null && (currentUI = ui.getOneOfChild(true, false)) != null && currentUI.isSameClass(XFA.PASSWORDEDITTAG)) {
                value.isTransient(true, false);
            }
        }
        if (formNode.isContainer()) {
            String sLocale;
            Element container = (Element)formNode;
            Attribute oLocale = container.getAttribute(XFA.LOCALETAG, true, false);
            if (oLocale != null && (sLocale = oLocale.toString()).equals("ambient")) {
                formNode.mute();
                container.setAttribute(new StringAttr("locale", this.getCachedLocale()), XFA.LOCALETAG);
                formNode.unMute();
            }
            ArrayList<Node> nameList = new ArrayList<Node>();
            for (Node child = formNode.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                this.preSave(child, dataParent);
                nameList.add(child);
            }
            if (formNode.isDefault(false)) return;
            boolean bClearDefault = false;
            int nFirst = 0;
            int nCount = nameList.size();
            Node[] nodes = nameList.toArray(new Node[nCount]);
            Arrays.sort(nodes, new Comparator<Node>(){

                @Override
                public int compare(Node node1, Node node2) {
                    int result = node1.getName().compareTo(node2.getName());
                    if (result != 0) {
                        return result;
                    }
                    return node1.getClassTag() < node2.getClassTag() ? -1 : (node1.getClassTag() > node2.getClassTag() ? 1 : 0);
                }
            });
            nameList = null;
            for (int i = 1; i < nCount; ++i) {
                Node node1 = nodes[i - 1];
                Node node2 = nodes[i];
                if (node1.getName() != node2.getName() || !node1.isSameClass(node2)) {
                    if (bClearDefault) {
                        while (nFirst < i) {
                            Node child2 = nodes[nFirst];
                            child2.makeNonDefault(false);
                            ++nFirst;
                        }
                        bClearDefault = false;
                    }
                    nFirst = i;
                    continue;
                }
                bClearDefault |= !node1.isDefault(false) || !node2.isDefault(false);
            }
            if (bClearDefault) {
                while (nFirst < nCount) {
                    Node child3 = nodes[nFirst];
                    child3.makeNonDefault(false);
                    ++nFirst;
                }
            }
            if (formNode.isSameClass(XFA.SUBFORMTAG)) {
                FormInstanceManager manager = ((FormSubform)formNode).getInstanceManager();
                if (manager == null) return;
                manager.makeNonDefault(false);
                return;
            } else {
                FormInstanceManager manager;
                if (!formNode.isSameClass(XFA.SUBFORMSETTAG) || (manager = ((FormSubformSet)formNode).getInstanceManager()) == null) return;
                manager.makeNonDefault(false);
            }
            return;
        } else {
            if (!formNode.isSameClass("border") && !formNode.isSameClass("rectangle") || formNode.isDefault(true)) return;
            Node formChild = formNode.getFirstXFAChild();
            while (formNode != null) {
                if (!formChild.isDefault(true) && (formChild.isSameClass(XFA.EDGETAG) || formChild.isSameClass(XFA.CORNERTAG))) {
                    formChild.makeNonDefault(false);
                }
                formNode = formNode.getNextXFASibling();
            }
        }
    }

    private void mergeFirstPass() {
        String name;
        Node node;
        Node connectData;
        this.allowNewNodes(true);
        Element connectDataRoot = null;
        if (this.mbConnectionMerge && (connectData = this.mDataModel.locateChildByName("connectionData", 0)) != null && (node = connectData.locateChildByName(name = this.msConnectionName.intern(), 0)) instanceof Element) {
            connectDataRoot = (Element)node;
        }
        if (this.mbEmptyMerge && this.mergeMode() == 9175040) {
            this.mRootFormSubform = (FormSubform)this.createEmptyFormNode(this.mRootSubform, this, connectDataRoot, null);
            this.bindNodes(this.mRootFormSubform, this.mStartNode, false);
            this.consumeDataNode(null, this.mStartNode, DatasetSelector.MAIN_DATASET);
        } else {
            this.mRootFormSubform = (FormSubform)this.createFormNode(this.mRootSubform, this, null);
            this.bindNodes(this.mRootFormSubform, this.mStartNode, false);
            this.consumeDataNode(null, this.mStartNode, DatasetSelector.MAIN_DATASET);
            this.createAndMatchChildren(this.mRootSubform, this.mStartNode, this.mRootFormSubform, connectDataRoot);
        }
        this.allowNewNodes(false);
    }

    private DataNode findNestedAttrMatch(Node field, Node dataParent, int eMergeType) {
        assert (eMergeType == 2031617 || eMergeType == 2031620);
        if (dataParent == null) {
            return null;
        }
        for (Node dvParent = dataParent.getFirstXFAChild(); dvParent != null; dvParent = dvParent.getNextXFASibling()) {
            if (dvParent.getClassTag() != XFA.DATAVALUETAG) continue;
            for (Node dataChild = dvParent.getFirstXFAChild(); dataChild != null; dataChild = dataChild.getNextXFASibling()) {
                DataNode value;
                if (dataChild.getClassTag() != XFA.DATAVALUETAG || (value = (DataNode)dataChild).isMapped() || !value.isAttribute() || value.getName() != field.getName()) continue;
                return value;
            }
        }
        return null;
    }

    boolean queueCalculate(Element node) {
        if (this.isActivityExcluded("calculate")) {
            return false;
        }
        List<Node> list = this.mPendingCalculateNodes;
        if (!this.canBeQueued(node, true)) {
            return false;
        }
        Element action = node.getElement(XFA.CALCULATETAG, true, 0, false, false);
        Element scriptNode = null;
        if (action != null) {
            scriptNode = action.getElement(XFA.SCRIPTTAG, true, 0, false, false);
        }
        if (scriptNode != null) {
            list.add(node);
            return true;
        }
        return false;
    }

    void queueCalculatesAndValidates(Element node, boolean bRecursive) {
        if (node instanceof FormField || node instanceof FormExclGroup) {
            this.queueCalculate(node);
            this.queueValidate(node);
        } else if (node.isContainer()) {
            if (bRecursive) {
                for (Node child = node.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                    if (!(child instanceof Element)) continue;
                    this.queueCalculatesAndValidates((Element)child, bRecursive);
                }
            }
            if (node instanceof FormSubform) {
                this.queueCalculate(node);
                this.queueValidate(node);
            }
        }
        if (node instanceof FormModel) {
            for (int i = 0; i < this.mLayoutContent.size(); ++i) {
                this.queueCalculatesAndValidates(this.mLayoutContent.get((int)i).mNode, bRecursive);
            }
        }
    }

    private boolean queueValidate(Element node) {
        Element ui;
        Node currentUI;
        if (this.isActivityExcluded("validate")) {
            return false;
        }
        boolean bValidateScriptTest = true;
        boolean bValidateFormatTest = true;
        boolean bValidateNullTest = true;
        boolean bValidateBarcode = false;
        List<Node> list = this.mPendingValidateNodes;
        if (!this.canBeQueued(node, false)) {
            return false;
        }
        Element action = node.getElement(XFA.VALIDATETAG, true, 0, false, false);
        Element scriptNode = null;
        Element pictureNode = null;
        boolean bNullTest = false;
        if (action != null) {
            int eNullTest;
            int eFormatTest;
            scriptNode = action.getElement(XFA.SCRIPTTAG, true, 0, false, false);
            int eScriptTest = action.getEnum(XFA.SCRIPTTESTTAG);
            if (eScriptTest == 3670016 || this.isActivityExcluded("scriptTest") || !bValidateScriptTest) {
                scriptNode = null;
            }
            if ((eFormatTest = action.getEnum(XFA.FORMATTESTTAG)) != 3670016 && !this.isActivityExcluded("formatTest") && bValidateFormatTest) {
                pictureNode = action.getElement(XFA.PICTURETAG, true, 0, false, false);
            }
            if ((eNullTest = action.getEnum(XFA.NULLTESTTAG)) != 3670016 && !this.isActivityExcluded("nullTest") && bValidateNullTest) {
                bNullTest = true;
            }
        }
        if (node instanceof FormField && (action == null || scriptNode == null && pictureNode == null && !bNullTest) && (ui = node.getElement(XFA.UITAG, true, 0, false, false)) != null && (currentUI = ui.getOneOfChild(true, false)) != null) {
            bValidateBarcode = currentUI.isSameClass(XFA.BARCODETAG);
        }
        if (scriptNode != null || pictureNode != null || bNullTest || bValidateBarcode) {
            list.add(node);
            return true;
        }
        return false;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public boolean recalculate(boolean bFullRecalculate, Validate validate, boolean bIgnoreCalcEnabledFlag) {
        if (this.mbIsCalculating) {
            return false;
        }
        this.mbIsCalculating = true;
        this.mbIgnoreCalcEnabledFlag = bIgnoreCalcEnabledFlag;
        this.mValidate = validate;
        ++this.mnValidationRecursionDepth;
        try {
            int i;
            boolean bCalcOrValidateFired;
            int bRet = 0;
            if (bFullRecalculate) {
                this.removeQueuedCalculates();
                this.removeQueuedValidates();
                this.removeQueuedNewValidates();
                boolean oBoolReset = this.mbSkipCyclicAndDuplicateCheck;
                try {
                    this.mbSkipCyclicAndDuplicateCheck = true;
                    this.queueCalculatesAndValidates(this, true);
                }
                finally {
                    this.mbSkipCyclicAndDuplicateCheck = oBoolReset;
                }
            }
            EventManager eventManager = this.getEventManager();
            this.preValidate(validate, this.mnValidationRecursionDepth > 1);
            do {
                Node node;
                boolean bFireEvent;
                bCalcOrValidateFired = false;
                do {
                    bFireEvent = false;
                    if (!this.getCalculationsEnabled()) continue;
                    for (i = this.mnNextPendingCalculateNode; i < this.mPendingCalculateNodes.size(); i += 1) {
                        node = this.mPendingCalculateNodes.get(i);
                        try {
                            if (eventManager.eventOccurred(this.mnCalcEventId, node)) {
                                bRet = 1;
                            }
                        }
                        catch (ExFull oEx) {
                            MsgFormatPos error = new MsgFormatPos(ResId.UnsupportedOperationException);
                            error.format("calculate").format(node.getSOMExpression());
                            error.format(". " + oEx.toString());
                            this.addErrorList(new ExFull(error), 3, null);
                        }
                        ++this.mnNextPendingCalculateNode;
                        bFireEvent = true;
                        bCalcOrValidateFired = true;
                    }
                } while (bFireEvent);
                if (this.getValidationsEnabled()) {
                    boolean bOldNullTest = false;
                    if (this.mValidate != null) {
                        bOldNullTest = this.mValidate.isNullTestEnabled();
                        this.mValidate.setNullTestEnabled(false);
                    }
                    for (Node node2 : this.mNewValidateNodes) {
                        if (!eventManager.eventOccurred(this.mnValidateEventId, node2)) continue;
                        bRet = 1;
                    }
                    if (this.mValidate != null) {
                        this.mValidate.setNullTestEnabled(bOldNullTest);
                    }
                    this.removeQueuedNewValidates();
                }
                do {
                    bFireEvent = false;
                    if (!this.getValidationsEnabled()) continue;
                    for (i = this.mnNextPendingValidateNode; i < this.mPendingValidateNodes.size(); i += 1) {
                        node = this.mPendingValidateNodes.get(i);
                        if (eventManager.eventOccurred(this.mnValidateEventId, node)) {
                            bRet = 1;
                        }
                        ++this.mnNextPendingValidateNode;
                        bFireEvent = true;
                        bCalcOrValidateFired = true;
                    }
                } while (bFireEvent);
            } while (bCalcOrValidateFired);
            this.postValidate(validate, this.mnValidationRecursionDepth > 1);
            if (this.getCalculationsEnabled()) {
                this.removeQueuedCalculates();
            }
            if (this.getValidationsEnabled()) {
                this.removeQueuedValidates();
            }
            this.mnNextPendingCalculateNode = 0;
            this.mnNextPendingValidateNode = 0;
            if (this.ready(bFullRecalculate)) {
                bRet = 1;
            }
            if (eventManager.eventOccurred(eventManager.getEventID("overlay"), this)) {
                bRet = 1;
            }
            i = bRet;
            return (boolean)i;
        }
        finally {
            this.mbIgnoreCalcEnabledFlag = false;
            this.mbIsCalculating = false;
            this.mValidate = null;
            --this.mnValidationRecursionDepth;
        }
    }

    private boolean getRegistered(Node node, int eActivity) {
        if (node instanceof FormField) {
            return ((FormField)node).getRegistered(eActivity);
        }
        if (node instanceof FormSubform) {
            return ((FormSubform)node).getRegistered(eActivity);
        }
        if (node instanceof FormExclGroup) {
            return ((FormExclGroup)node).getRegistered(eActivity);
        }
        return false;
    }

    private void setRegistered(Node node, int eActivity) {
        if (node instanceof FormField) {
            FormField oField = (FormField)node;
            oField.setRegistered(eActivity);
        } else if (node instanceof FormSubform) {
            FormSubform oSubform = (FormSubform)node;
            oSubform.setRegistered(eActivity);
        } else if (node instanceof FormExclGroup) {
            FormExclGroup oExclGroup = (FormExclGroup)node;
            oExclGroup.setRegistered(eActivity);
        }
    }

    void registerEvents(Element element, int nEventTypes) {
        boolean bValidate;
        assert (element != null);
        if (!this.mbRegisterNewEvents) {
            return;
        }
        EventManager eventManager = this.getEventManager();
        if (eventManager == null) {
            return;
        }
        boolean bEvents = (nEventTypes & 1) != 0;
        boolean bCalculate = (nEventTypes & 2) != 0 && !this.getRegistered(element, XFA.CALCULATETAG);
        boolean bl = bValidate = (nEventTypes & 4) != 0 && !this.getRegistered(element, XFA.VALIDATETAG);
        if (element.isSameClass(XFA.FIELDTAG) || element.isSameClass(XFA.SUBFORMTAG) || element.isSameClass(XFA.EXCLGROUPTAG)) {
            ScriptInfo calculateInfo;
            ValidateInfo validateInfo;
            ProtoableNode container = (ProtoableNode)element;
            if (bCalculate && !this.isActivityExcluded("calculate") && (calculateInfo = this.getCalculateInfo(container)) != null) {
                CalculateDispatcher cd = new CalculateDispatcher(calculateInfo.mScriptContextNode, calculateInfo.msEventContext, this.mnCalcEventId, eventManager, calculateInfo.msScript, calculateInfo.msScriptLanguage, calculateInfo.meRunAt);
                eventManager.registerEvents(cd);
                this.mPendingCalculateNodes.add(container);
                this.setRegistered(element, XFA.CALCULATETAG);
            }
            if (bValidate && !this.isActivityExcluded("validate") && (validateInfo = this.getValidateInfo(container)) != null) {
                ValidateDispatcher vd = new ValidateDispatcher(validateInfo.mScriptContextNode, validateInfo.msEventContext, this.mnValidateEventId, eventManager, validateInfo.msScript, validateInfo.msScriptLanguage, validateInfo.msBarcodeType, validateInfo.meRunAt);
                eventManager.registerEvents(vd);
                this.mNewValidateNodes.add(container);
                this.setRegistered(element, XFA.VALIDATETAG);
            }
            if (element.isSameClass(XFA.FIELDTAG)) {
                for (Node child = element.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                    if (!child.isSameClass(XFA.EVENTTAG)) continue;
                    this.registerEvents((Element)child, nEventTypes);
                }
            }
        } else if (bEvents && element.isSameClass(XFA.EVENTTAG)) {
            ExecuteInfo executeInfo;
            SubmitInfo submitInfo;
            Element eventOneOfChild = (Element)element.getOneOfChild();
            ProtoableNode parent = (ProtoableNode)element.getXFAParent();
            String sActivity = element.getAttribute(XFA.ACTIVITYTAG).toString();
            if (StringUtils.isEmpty(sActivity) || this.isActivityExcluded(sActivity)) {
                return;
            }
            int nEventId = eventManager.getEventID(sActivity);
            String sRef = element.getAttribute(XFA.REFTAG).toString();
            Dispatcher dispatcher = null;
            if (eventOneOfChild.isSameClass(XFA.SIGNDATATAG)) {
                dispatcher = new SignDispatcher(parent, eventOneOfChild, sRef, nEventId, eventManager);
            } else {
                ScriptInfo scriptInfo = this.getScriptInfo(parent, element);
                if (scriptInfo != null) {
                    dispatcher = new ScriptRunAtDispatcher(scriptInfo.mScriptContextNode, scriptInfo.msEventContext, nEventId, eventManager, scriptInfo.msScript, scriptInfo.msScriptLanguage, scriptInfo.meRunAt, scriptInfo.msTarget);
                }
            }
            if (dispatcher == null && (submitInfo = this.getSubmitInfo(parent, element)) != null) {
                dispatcher = new SubmitDispatcher(submitInfo.mSubmitContextNode, submitInfo.msEventContext, nEventId, eventManager, eventOneOfChild, this.mbValidateBeforeSubmit);
            }
            if (dispatcher == null && (executeInfo = this.getExecuteInfo(parent, element)) != null) {
                dispatcher = new ExecuteDispatcher(executeInfo.mExecuteContextNode, executeInfo.msEventContext, nEventId, eventManager, eventOneOfChild, this.mbValidateBeforeExecute);
            }
            if (dispatcher != null) {
                int eListen = element.getEnum(XFA.LISTENTAG);
                dispatcher.setListenToDescendents(eListen == 1082720257);
                eventManager.registerEvents(dispatcher);
            }
        }
    }

    public boolean registerNewEvents(boolean bAllow) {
        boolean bOldValue = this.mbRegisterNewEvents;
        this.mbRegisterNewEvents = bAllow;
        return bOldValue;
    }

    public void remerge() {
        if (this.mbDisableRemerge) {
            return;
        }
        Node context = this.getAppModel().getContext();
        if (context != null && context.getModel() == this) {
            this.getAppModel().setContext(this);
        }
        this.merge(this.mbEmptyMerge, this.mbAdjustData, true, false, false);
    }

    @Override
    public void remove() {
        this.reset();
        super.remove();
    }

    void removeDependency(Node node, boolean bForCalc) {
        List<FormListener> listenerTable = null;
        if (node instanceof FormField) {
            listenerTable = ((FormField)node).getFormListeners(false);
        } else if (node instanceof FormExclGroup) {
            listenerTable = ((FormExclGroup)node).getFormListeners(false);
        } else if (node instanceof FormSubform) {
            listenerTable = ((FormSubform)node).getFormListeners(false);
        }
        if (listenerTable != null) {
            for (int i = 0; i < listenerTable.size(); ++i) {
                FormListener formListener = listenerTable.get(i);
                assert (null != formListener);
                if (null == formListener || bForCalc != formListener.isCalculate()) continue;
                listenerTable.remove(i);
                --i;
            }
        }
    }

    private void removeQueuedCalculates() {
        this.mPendingCalculateNodes.clear();
        this.mnNextPendingCalculateNode = 0;
    }

    private void removeQueuedNewValidates() {
        this.mNewValidateNodes.clear();
    }

    private void removeQueuedValidates() {
        this.mPendingValidateNodes.clear();
        this.mnNextPendingValidateNode = 0;
    }

    @Override
    public void removeReferences(Node node) {
        this.removeReferencesImpl(node, true);
    }

    private void removeReferencesImpl(Node node, boolean bResetLayoutNode) {
        if (node != null) {
            boolean bCleanUpLayout = false;
            if (node instanceof FormField) {
                if (node == this.mActiveField) {
                    this.mActiveField = null;
                }
                if (node == this.mPrevActiveField) {
                    this.mPrevActiveField = null;
                }
                ((FormField)node).cleanupListeners();
            } else if (node instanceof FormSubform) {
                ((FormSubform)node).cleanupListeners();
                if (bResetLayoutNode && ((FormSubform)node).isLayoutNode()) {
                    bCleanUpLayout = true;
                }
            } else if (bResetLayoutNode && node instanceof FormSubformSet && ((FormSubformSet)node).isLayoutNode()) {
                bCleanUpLayout = true;
            } else if (bResetLayoutNode && node instanceof PageSet) {
                bCleanUpLayout = true;
            } else if (node instanceof FormExclGroup) {
                ((FormExclGroup)node).cleanupListeners();
            }
            if (bCleanUpLayout) {
                for (int i = this.mLayoutContent.size(); i > 0; --i) {
                    if (this.mLayoutContent.get((int)(i - 1)).mNode != node) continue;
                    this.mLayoutContent.remove(i - 1);
                    break;
                }
            }
            super.removeReferences(node);
        }
    }

    public void reset() {
        Obj event;
        Obj signature;
        DataWindow dataWindow;
        if (this.getXFAParent() != null && this.getEventManager() != null) {
            this.getEventManager().reset();
        }
        EventManager.resetEventTable(this.getEventTable(false));
        this.removeQueuedCalculates();
        this.removeQueuedValidates();
        this.removeQueuedNewValidates();
        this.mValidate = null;
        this.mbMergeComplete = false;
        this.mbWeightedData = false;
        this.mGlobalDataNodes.clear();
        this.mExplicitMatchNodes.clear();
        this.mLayoutContent.clear();
        this.mCurrentPageSet = null;
        int nChildren = this.getXFAChildCount();
        while (nChildren > 0) {
            Node child = this.getXFAChild(--nChildren);
            child.remove();
            this.removeReferencesImpl(child, false);
        }
        if (this.mStartNode != null && this.mStartNode.getXFAParent() == null && (dataWindow = this.mDataModel.getDataWindow()).removeRecordGroup(this.mStartNode)) {
            dataWindow.updateAfterLoad();
        }
        this.mStartNode = null;
        this.mRootSubform = null;
        this.mbConnectionMerge = false;
        this.msConnectionName = "";
        this.mActiveField = null;
        this.mPrevActiveField = null;
        this.mDataModel = null;
        this.mTemplateModel = null;
        this.mHostPseudoModel = null;
        this.mEventPseudoModel = null;
        AppModel appModel = (AppModel)this.getXFAParent();
        Obj host = appModel.lookupPseudoModel("$host");
        if (host != null) {
            this.mHostPseudoModel = (HostPseudoModel)host;
        }
        if ((event = appModel.lookupPseudoModel("$event")) != null) {
            this.mEventPseudoModel = (EventPseudoModel)event;
        }
        if ((signature = appModel.lookupPseudoModel("$signature")) != null) {
            throw new ExFull(ResId.UNSUPPORTED_OPERATION, "FormModel#reset - $signature");
        }
        this.mDataModel = DataModel.getDataModel(appModel, false, false);
        this.mTemplateModel = TemplateModel.getTemplateModel(appModel, false);
        EventManager em = this.getEventManager();
        this.mnCalcEventId = em.getEventID("calculate");
        this.mnValidateEventId = em.getEventID("validate");
        this.mnValidationStateEventId = em.getEventID("validationState");
    }

    public void resetData(Obj container) {
        if (container == null) {
            if (this.mRootFormSubform != null) {
                this.resetData(this.mRootFormSubform);
            }
            return;
        }
        if (!(container instanceof Container)) {
            return;
        }
        if (container instanceof FormField) {
            ((FormField)container).resetData();
            return;
        }
        for (Node child = ((Container)container).getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
            if (!(child instanceof Container)) continue;
            this.resetData(child);
        }
    }

    private DataNode resolveCreateDataRef(String sSom, Element dataParent, boolean bSearch, boolean bUseDV) {
        if (dataParent == null && !this.mbGlobalConsumption) {
            if (FormModel.somIsRelative(sSom)) {
                return null;
            }
            dataParent = this.mStartNode;
        }
        DataNode dataNode = null;
        if (bSearch) {
            if (dataParent == null) {
                dataParent = this.mStartNode;
            }
            boolean bMultiple = FormModel.isSomMultiple(sSom);
            if (this.mergeMode() == 9175040 || !bMultiple) {
                NodeList oNodes = dataParent.resolveNodes(sSom, true, false, true);
                int nLen = oNodes.length();
                for (int i = 0; i < nLen; ++i) {
                    DataNode dNode = (DataNode)oNodes.item(i);
                    if (bMultiple && dNode.isMapped()) continue;
                    dataNode = dNode;
                    break;
                }
            }
        }
        if (dataNode == null) {
            DataModel dataModel = DataModel.getDataModel(this.getAppModel(), false, false);
            int nFoundAt = sSom.indexOf(".[");
            int nTruncateLen = 0;
            if (nFoundAt != -1) {
                nTruncateLen = nFoundAt;
            }
            if ((nFoundAt = sSom.indexOf(".(")) != -1 && (nTruncateLen == 0 || nFoundAt < nTruncateLen)) {
                nTruncateLen = nFoundAt;
            }
            if (nTruncateLen > 0) {
                sSom = sSom.substring(0, nTruncateLen);
                sSom = sSom + "[*]";
            }
            dataNode = (DataNode)dataModel.resolveRef(sSom, dataParent, bUseDV, !this.mbAdjustData);
            assert (this.mTemplateModel != null);
            if (this.mTemplateModel.getLegacySetting(AppModel.XFA_PATCH_W_2393121)) {
                // empty if block
            }
            DataModel.removeDDPlaceholderFlags(dataNode, false);
        }
        return dataNode;
    }

    private DataNode resolveGlobal(Element formNode, boolean bUseDV) {
        DataNode node = null;
        for (DataNode global : this.mGlobalDataNodes) {
            if (!FormModel.isMappable(formNode, global, true, false)) continue;
            return global;
        }
        DataWindow dataWindow = this.mDataModel.getDataWindow();
        IntegerHolder nCount = new IntegerHolder();
        if (dataWindow.isDefined()) {
            DataNode parent = dataWindow.record(0);
            node = (DataNode)this.findGlobalNode(formNode, parent, nCount, null);
        }
        if (node == null) {
            Element parent = this.mDataModel.getAliasNode();
            node = (DataNode)this.findGlobalNode(formNode, parent, nCount, dataWindow);
        }
        if (node != null) {
            this.mGlobalDataNodes.add(node);
        }
        return node;
    }

    private Node resolveCreateGlobal(Element formNode, boolean bSearch, boolean bUseDV) {
        DataNode node = null;
        if (bSearch) {
            node = this.resolveGlobal(formNode, bUseDV);
        }
        if (node == null) {
            DataNode dataParent;
            DataModel dataModel;
            String aName = formNode.getName();
            DataNode global = null;
            if (this.mbAdjustData && (dataParent = this.mStartNode) != null && (dataModel = (DataModel)dataParent.getModel()) != null) {
                int nDot;
                StringBuilder sName = new StringBuilder(aName);
                int fromIndex = 0;
                while ((nDot = sName.indexOf(".", fromIndex)) != -1) {
                    sName.insert(nDot, '\\');
                    fromIndex = nDot + 2;
                }
                node = (DataNode)dataModel.resolveRef(sName.toString(), dataParent, bUseDV, !this.mbAdjustData);
            }
            if (node == null) {
                int eTag = XFA.DATAVALUETAG;
                if (!bUseDV) {
                    eTag = XFA.DATAGROUPTAG;
                }
                node = global = (DataNode)this.mDataModel.createNode(eTag, null, aName, "", true);
            }
            if (node != null) {
                this.mGlobalDataNodes.add(node);
            }
        } else if (node != null) {
            this.mGlobalDataNodes.add(node);
        }
        return node;
    }

    @Override
    public void resolveProtos(boolean bForceExternalProtoResolve) {
        if (this.isLoading() || this.mbAllowNewNodes) {
            return;
        }
        super.resolveProtos(false);
    }

    private Node resolveSetPropertyTarget(Container container, String sTarget, StringHolder sTargetProperty) {
        Element validate;
        SOMParser parser = new SOMParser(null);
        ArrayList<SOMParser.SomResultInfo> result = new ArrayList<SOMParser.SomResultInfo>();
        Node targetNode = null;
        sTargetProperty.value = "";
        if (parser.resolve(container, sTarget, result) && result.size() > 0) {
            SOMParser.SomResultInfo oResultInfo = result.get(0);
            if (oResultInfo.object instanceof Node) {
                sTargetProperty.value = oResultInfo.propertyName;
                targetNode = (Node)oResultInfo.object;
            }
            return targetNode;
        }
        String sPrefix = "";
        String sSuffix = "";
        for (int i = sTarget.length(); i > 0; --i) {
            if (sTarget.charAt(i - 1) != '.') continue;
            sPrefix = sTarget.substring(0, i - 1);
            sSuffix = sTarget.substring(i);
            break;
        }
        if (sPrefix.length() == 0 || sSuffix.length() == 0) {
            return targetNode;
        }
        ArrayList<SOMParser.SomResultInfo> tmpResult = new ArrayList<SOMParser.SomResultInfo>();
        if (!parser.resolve(container, sPrefix, tmpResult) || tmpResult.size() == 0) {
            return targetNode;
        }
        SOMParser.SomResultInfo checkResult = tmpResult.get(0);
        if (checkResult.object == null || !(checkResult.object instanceof Node)) {
            return targetNode;
        }
        if (checkResult.object.isSameClass(XFA.MESSAGETAG) && (validate = ((Node)checkResult.object).getXFAParent()) != null && validate.isSameClass(XFA.VALIDATETAG)) {
            Element message = (Element)checkResult.object;
            Element text = message.getModel().createElement("text", sSuffix, message);
            targetNode = text;
        }
        return targetNode;
    }

    public void restoreValidateDisableAll(Element formNode, Node delta) {
        Attribute disableAllDelta;
        Element deltaValidate;
        assert (this.isLoading() && (formNode instanceof FormSubform || formNode instanceof FormField || formNode instanceof FormExclGroup));
        if (this.isLoading() && formNode != null && delta != null && formNode.isSameClass(delta) && formNode.getName() == delta.getName() && (deltaValidate = ((Element)delta).getElement(XFA.VALIDATETAG, true, 0, false, false)) != null && (disableAllDelta = deltaValidate.getAttribute(XFA.DISABLEALLTAG, true, false)) != null) {
            Element validate = formNode.getElement(XFA.VALIDATETAG, 0);
            assert (validate != null);
            if (validate != null) {
                validate.setAttribute(disableAllDelta, XFA.DISABLEALLTAG);
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private void runExecEvents() {
        Node node = this.getAppModel().locateChildByName("execEvent", 0);
        if (!(node instanceof Element)) {
            return;
        }
        Element execEvent = (Element)node;
        execEvent.remove();
        String sContextNodeSOM = "";
        Node contextNode = null;
        int index = execEvent.findAttr("", "context");
        if (index != -1) {
            int nFoundAt;
            sContextNodeSOM = execEvent.getAttrVal(index);
            if (sContextNodeSOM.startsWith("xfa[0].form[") && (nFoundAt = sContextNodeSOM.indexOf(93, 12)) != -1) {
                sContextNodeSOM = "$" + sContextNodeSOM.substring(nFoundAt + 1);
            }
            contextNode = this.resolveNode(sContextNodeSOM);
        }
        String sActivity = "";
        index = execEvent.findAttr("", "activity");
        if (index != -1) {
            sActivity = execEvent.getAttrVal(index);
        }
        if (contextNode == null) {
            MsgFormatPos msg = new MsgFormatPos(ResId.ContextNodeNotFound);
            msg.format(sContextNodeSOM);
            msg.format(execEvent.getSOMExpression());
            if (sActivity.equals("preSubmit")) {
                this.addErrorList(new ExFull(msg), 3, null);
                return;
            }
            throw new ExFull(msg);
        }
        if (contextNode instanceof FormSubform || contextNode instanceof FormField || contextNode instanceof FormExclGroup || contextNode instanceof FormModel) {
            EventPseudoModel.EventInfo eventInfo = null;
            if (this.mEventPseudoModel != null) {
                eventInfo = this.mEventPseudoModel.getEventInfo();
            }
            try {
                int eReason = ScriptHandler.stringToExecuteReason(sActivity);
                if (this.mEventPseudoModel != null) {
                    this.mEventPseudoModel.reset();
                    this.mEventPseudoModel.setName(eReason);
                    this.mEventPseudoModel.setTarget(contextNode);
                }
                EventManager em = this.getEventManager();
                int nID = em.getEventID(sActivity);
                this.eventOccurred(em, nID, eReason, (Container)contextNode, false);
            }
            finally {
                if (this.mEventPseudoModel != null) {
                    this.mEventPseudoModel.setEventInfo(eventInfo);
                }
            }
        }
    }

    void serverExchange(Node contextNode, String sActivity) {
        block13 : {
            if (this.mServerExchange == null) {
                return;
            }
            if (this.mDataModel == null) {
                return;
            }
            if (!(sActivity.equals("enter") || sActivity.equals("exit") || sActivity.equals("mouseEnter") || sActivity.equals("mouseExit") || sActivity.equals("change") || sActivity.equals("click") || sActivity.equals("mouseUp") || sActivity.equals("mouseDown"))) {
                return;
            }
            if ((sActivity.equals("enter") || sActivity.equals("exit")) && !contextNode.isSameClass(XFA.FIELDTAG)) {
                return;
            }
            if (this.mbExchangingDataWithServer) {
                throw new ExFull(ResId.SOFTWARE_FAILURE, "Recursive call to FormModel.serverExchange unexpected.");
            }
            AppModel appModel = (AppModel)this.getXFAParent();
            Packet execEvent = (Packet)appModel.createNode(XFA.PACKETTAG, this, "execEvent", "", false);
            execEvent.setDOMProperties(null, "execEvent", "execEvent", null);
            appModel.appendChild(execEvent, false);
            execEvent.setAttribute(contextNode.getSOMExpression(this, false), "context");
            execEvent.setAttribute(sActivity, "activity");
            XMLStorage xml = new XMLStorage();
            ByteArrayOutputStream streamFileOut = new ByteArrayOutputStream();
            ArrayNodeList nodesToSave = new ArrayNodeList();
            nodesToSave.append(this.mDataModel);
            nodesToSave.append(execEvent);
            xml.saveAggregate("", streamFileOut, nodesToSave, "");
            byte[] request = streamFileOut.toByteArray();
            streamFileOut = null;
            byte[] response = this.mServerExchange.sendToServer(request);
            request = null;
            execEvent.remove();
            AppModel tempAppModel = new AppModel(new LogMessenger());
            xml.loadModel(tempAppModel, new ByteArrayInputStream(response), "", null);
            response = null;
            Element tempDatasets = (Element)tempAppModel.resolveNode("$.datasets");
            assert (tempDatasets != null);
            if (tempDatasets == null) break block13;
            ByteArrayOutputStream streamFileTemp = new ByteArrayOutputStream();
            tempDatasets.saveXML(streamFileTemp, null);
            assert (this.mDataModel.getAliasNode().getName() == "data");
            this.mDataModel.removeChild(this.mDataModel.getAliasNode());
            int nChildCountBeforeLoad = this.mDataModel.getXFAChildCount();
            byte[] bytes = streamFileTemp.toByteArray();
            streamFileTemp = null;
            this.mDataModel.loadXML((InputStream)new ByteArrayInputStream(bytes), true, false);
            bytes = null;
            for (int i = nChildCount = this.mDataModel.getXFAChildCount(); i > nChildCountBeforeLoad; --i) {
                Attribute aDDNameAttr;
                DataNode pDDRoot;
                Node pDataModelChild = this.mDataModel.getXFAChild(i - 1);
                if (!pDataModelChild.getName().equals("dataDescription") || (pDDRoot = this.mDataModel.getDataDescriptionRoot((aDDNameAttr = ((Element)pDataModelChild).getAttributeByName("name", false)).getAttrValue())) == pDataModelChild) continue;
                this.mDataModel.removeChild(pDataModelChild);
            }
            Element tempFormState = (Element)tempAppModel.resolveNode("$.formState");
            if (tempFormState != null) {
                ByteArrayOutputStream streamFormState = new ByteArrayOutputStream();
                tempFormState.saveXML(streamFormState, null);
                bytes = streamFormState.toByteArray();
                streamFormState = null;
                this.getAppModel().loadXML((InputStream)new ByteArrayInputStream(bytes), false, false);
            }
            this.mDataModel.getDataWindow().resetRecordDepth();
            this.mbExchangingDataWithServer = true;
            try {
                this.mServerExchange.remerge();
            }
            catch (ExFull ex) {
                this.mbExchangingDataWithServer = false;
                throw ex;
            }
        }
        this.mbExchangingDataWithServer = false;
    }

    public void setAdjustData(boolean bAdjustData) {
        this.mbAdjustData = bAdjustData;
    }

    void setAllowNewNodes(boolean bAllowNewNodes) {
        this.mbAllowNewNodes = bAllowNewNodes;
    }

    public void setAmbientLocale(String sLocale) {
        this.msLocale = sLocale;
    }

    void setConnectionDataContextInfo(Container formContainer, Element connectionDataNode) {
        assert (formContainer.getFormInfo() == null);
        Container.FormInfo formInfo = new Container.FormInfo(connectionDataNode);
        formContainer.setFormInfo(formInfo);
        this.moContainersWithFormInfo.add(formContainer);
    }

    public void setDefaultValidate(Validate validate) {
        this.mDefaultValidate = validate.clone();
    }

    void setMatchDescendantsOnly(boolean bDescendantsOnly) {
        this.mbMatchDescendantsOnly = bDescendantsOnly;
    }

    void setDynamicProperties(Container container, String sConnectionName, boolean bRecurse) {
        Container.FormInfo formInfo;
        if (container == null) {
            return;
        }
        boolean bSupportsBinding = false;
        if (container instanceof Field || container instanceof Subform || container instanceof ExclGroup || container instanceof Draw) {
            bSupportsBinding = true;
        }
        if (!bSupportsBinding && !bRecurse) {
            Container.FormInfo formInfo2 = container.getFormInfo();
            if (formInfo2 != null) {
                container.setFormInfo(null);
            }
            return;
        }
        Node parent = container;
        if (container instanceof Draw) {
            parent = container.getProto();
        }
        if (parent != null) {
            for (Node child = parent.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                if (bSupportsBinding) {
                    if (child.isSameClass(XFA.SETPROPERTYTAG)) {
                        Element childElement = (Element)child;
                        String sConnection = "";
                        Attribute attr = childElement.getAttribute(XFA.CONNECTIONTAG, true, false);
                        if (attr != null) {
                            sConnection = attr.toString();
                        }
                        if (sConnection.equals(sConnectionName)) {
                            this.doSetProperty(childElement, container, !StringUtils.isEmpty(sConnection));
                        }
                    } else if (child.isSameClass(XFA.BINDITEMSTAG) && container instanceof FormField) {
                        this.doBindItems((Element)child, (FormField)container, sConnectionName);
                    }
                }
                if (!bRecurse || !(child instanceof Container)) continue;
                this.setDynamicProperties((Container)child, sConnectionName, true);
            }
        }
        if (bRecurse && (formInfo = container.getFormInfo()) != null) {
            container.setFormInfo(null);
        }
    }

    public void setEmptyMerge(boolean bEmptyMerge) {
        this.mbEmptyMerge = bEmptyMerge;
    }

    public void setExcludedActivities(String sExclude) {
        this.mExcludeList = sExclude.split("\\s");
    }

    public void setExecute(Execute execute) {
        if (this.mExecute != null) {
            this.mExecute = null;
        }
        if (execute != null) {
            this.mExecute = (Execute)execute.clone();
        }
    }

    public void setFocus(FormField field) {
        if (this.mActiveField != null) {
            this.clearFocus();
        }
        this.mActiveField = field;
    }

    private void setFormInfo(Container templateContainerNode, Element dataParent, NodeList dataNodes, boolean bAssociation, int eMergeType, boolean bRemoveAfterUse, boolean bConnectDataRef, Element connectionDataParent, NodeList altDataNodes) {
        Container.FormInfo formInfo = templateContainerNode.getFormInfo();
        if (formInfo == null) {
            formInfo = new Container.FormInfo(templateContainerNode, eMergeType);
            templateContainerNode.setFormInfo(formInfo);
            this.moContainersWithFormInfo.add(templateContainerNode);
        } else assert (formInfo.eMergeType == eMergeType && formInfo.templateContainerNode == templateContainerNode && formInfo.connectionDataNode == null);
        if (dataNodes != null) {
            formInfo.dataNodes = dataNodes;
        }
        if (altDataNodes != null) {
            formInfo.altDataNodes = altDataNodes;
        }
        formInfo.dataParent = dataParent;
        formInfo.scopeData = dataParent;
        formInfo.bAssociation = bAssociation;
        formInfo.bRemoveAfterUse = bRemoveAfterUse;
        formInfo.bConnectDataRef = bConnectDataRef;
        formInfo.connectionDataParent = connectionDataParent;
    }

    void setFormStateUsage(boolean bFormStateUsage) {
        this.mbFormStateUsage = bFormStateUsage;
    }

    void setLayoutNodes(FormSubformSet ss) {
        if (ss != null) {
            ss.setLayoutNode();
            for (Node child = ss.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                if (child instanceof FormSubform) {
                    ((FormSubform)child).setLayoutNode();
                    continue;
                }
                if (!(child instanceof FormSubformSet)) continue;
                this.setLayoutNodes((FormSubformSet)child);
            }
        }
    }

    void setOverlayDataMergeUsage(boolean bOverlayDataMergeUsage, int nPanel) {
        this.mbOverlayDataMergeUsage = bOverlayDataMergeUsage;
        this.mnPanel = nPanel;
    }

    public void setPostMergeHandler(PostMergeHandler handler, Object clientData) {
        this.mPostMergeHandler = handler;
        this.mPostMergeHandlerClientData = clientData;
    }

    public void setRunScripts(int eRunAtSetting) {
        this.meRunAtSetting = eRunAtSetting;
    }

    public void setServerExchange(ServerExchange serverExchange) {
        this.mServerExchange = serverExchange;
    }

    public void setSubmit(Submit submit) {
        if (this.mSubmit != null) {
            this.mSubmit = null;
        }
        if (submit != null) {
            this.mSubmit = (Submit)submit.clone();
        }
    }

    public void setSubmitURL(String sSubmitURL) {
        this.msSubmitURL = sSubmitURL;
    }

    public void setValidateBeforeExecute(boolean bValidate) {
        this.mbValidateBeforeExecute = bValidate;
    }

    public void setValidateBeforeSubmit(boolean bValidate) {
        this.mbValidateBeforeSubmit = bValidate;
    }

    /*
     * Unable to fully structure code
     * Enabled aggressive block sorting
     * Lifted jumps to return sites
     */
    private void updateFromFormState() {
        formState = this.getAppModel().locateChildByName("formState", 0);
        if (formState == null) {
            return;
        }
        stateChild = formState.getFirstXMLChild();
        block0 : do {
            if (stateChild == null) return;
            if (!(stateChild instanceof Element)) ** GOTO lbl87
            if (stateChild.getName() != "state") {
                stateChild = stateChild.getNextXMLSibling();
                continue;
            }
            stateChildElement = (Element)stateChild;
            sContextNodeSOM = "";
            contextNode = null;
            index = stateChildElement.findAttr("", "ref");
            if (index == -1 || (contextNode = this.resolveNode(sContextNodeSOM = stateChildElement.getAttrVal(index))) == null) {
                msg = new MsgFormatPos(ResId.FormStateContextNodeNotFound);
                msg.format(sContextNodeSOM);
                msg.format(formState.getSOMExpression());
                this.addErrorList(new ExFull(msg), 3, stateChildElement);
                stateChild = stateChild.getNextXMLSibling();
                continue;
            }
            if (!(contextNode instanceof FormField)) {
                return;
            }
            contextFormField = (FormField)contextNode;
            ui = contextFormField.getElement(XFA.UITAG, true, 0, false, false);
            if (ui == null) ** GOTO lbl35
            currentUI = ui.getOneOfChild(true, false);
            if (currentUI != null) {
                if (!currentUI.isSameClass(XFA.CHOICELISTTAG)) {
                    stateChild = stateChild.getNextXMLSibling();
                    continue;
                }
            } else {
                stateChild = stateChild.getNextXMLSibling();
                continue;
lbl35: // 1 sources:
                stateChild = stateChild.getNextXMLSibling();
                continue;
            }
            contextFormField.clearItems();
            itemChild = stateChild.getFirstXMLChild();
            saveValuesList = new ArrayList<String>();
            displayValuesList = new ArrayList<String>();
            do {
                if (itemChild == null) ** GOTO lbl48
                if (!(itemChild instanceof Element)) ** GOTO lbl108
                if (((Element)itemChild).getName() != "items") {
                    itemChild = itemChild.getNextXMLSibling();
                    continue;
                }
                ** GOTO lbl89
lbl48: // 1 sources:
                nSaveValues = saveValuesList.size();
                nDisplayValues = displayValuesList.size();
                if (nSaveValues != 0 || nDisplayValues != 0) {
                    itemPair = new Field.ItemPair();
                    contextFormField.getItemLists(false, itemPair, true);
                    displayItems = itemPair.mDisplayItems;
                    saveItems = itemPair.mSaveItems;
                    if (displayItems != null) {
                        displayItems.clearItems(false);
                    }
                    if (saveItems != null) {
                        saveItems.clearItems(false);
                    }
                    if (nSaveValues != 0 && nDisplayValues != 0) {
                        if (nDisplayValues != nSaveValues) {
                            if (nSaveValues < nDisplayValues) {
                                nDisplayValues = nSaveValues;
                            } else {
                                nSaveValues = nDisplayValues;
                            }
                        }
                        for (k = 0; k < nSaveValues; ++k) {
                            if (displayItems != null) {
                                displayItems.addItem((String)displayValuesList.get(k), false);
                            }
                            if (saveItems == null || saveItems == displayItems) continue;
                            saveItems.addItem((String)saveValuesList.get(k), false);
                        }
                    } else if (nSaveValues != 0) {
                        for (k = 0; k < nSaveValues; ++k) {
                            if (displayItems != null) {
                                displayItems.addItem((String)saveValuesList.get(k), false);
                            }
                            if (saveItems == null || saveItems == displayItems) continue;
                            saveItems.addItem((String)saveValuesList.get(k), false);
                        }
                    } else if (nDisplayValues != 0) {
                        for (k = 0; k < nSaveValues; ++k) {
                            if (displayItems != null) {
                                displayItems.addItem((String)displayValuesList.get(k), false);
                            }
                            if (saveItems == null || saveItems == displayItems) continue;
                            saveItems.addItem((String)displayValuesList.get(k), false);
                        }
                    }
                }
lbl87: // 8 sources:
                stateChild = stateChild.getNextXMLSibling();
                continue block0;
lbl89: // 7 sources:
                for (child = itemChild.getFirstXMLChild(); child != null; child = child.getNextXMLSibling()) {
                    if (!(child instanceof Element)) continue;
                    aName = ((Element)child).getName();
                    if (aName == "save") {
                        domNode = child.getFirstXMLChild();
                        if (domNode instanceof TextNode) {
                            domText = (TextNode)domNode;
                            saveValuesList.add(domText.getText());
                            continue;
                        }
                        saveValuesList.add("");
                        continue;
                    }
                    if (aName != "display") continue;
                    domNode = child.getFirstXMLChild();
                    if (domNode instanceof TextNode) {
                        domText = (TextNode)domNode;
                        displayValuesList.add(domText.getText());
                        continue;
                    }
                    displayValuesList.add("");
                }
lbl108: // 2 sources:
                itemChild = itemChild.getNextXMLSibling();
            } while (true);
            break;
        } while (true);
    }

    private static boolean useDV(Node formNode) {
        boolean bUseDV = false;
        if (formNode instanceof Subform || formNode instanceof FormChoiceListField) {
            bUseDV = false;
        } else if (formNode instanceof ExclGroup || formNode instanceof Field) {
            bUseDV = true;
        }
        return bUseDV;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    boolean validate(Validate validate, Element node, boolean bRecursive, boolean bIgnoreValidationsEnabledFlag) {
        this.mbIgnoreValidationsEnabledFlag = bIgnoreValidationsEnabledFlag;
        ++this.mnValidationRecursionDepth;
        try {
            this.preValidate(validate, this.mnValidationRecursionDepth > 1);
            if (node == null) {
                node = this.mRootFormSubform;
            }
            boolean bRet = this.validateNode(validate, node, bRecursive);
            this.postValidate(validate, this.mnValidationRecursionDepth > 1);
            boolean bl = bRet;
            return bl;
        }
        finally {
            this.mbIgnoreValidationsEnabledFlag = false;
            --this.mnValidationRecursionDepth;
        }
    }

    private void preValidate(Validate validate, boolean bIsRecursiveEntry) {
        if (bIsRecursiveEntry) {
            return;
        }
        if (validate != null) {
            validate.resetFailCount();
            validate.onValidateStart();
        }
        this.moValidationStateChanges.clear();
    }

    private void postValidate(Validate validate, boolean bIsRecursiveEntry) {
        if (bIsRecursiveEntry) {
            return;
        }
        if (validate != null) {
            validate.onValidateEnd();
        }
        if (this.moValidationStateChanges.size() > 0) {
            for (int i = 0; i < this.moValidationStateChanges.size(); ++i) {
                Container container = this.moValidationStateChanges.get(i);
                this.fireValidationStateEvent(container);
            }
            this.moValidationStateChanges.clear();
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private boolean fireValidationStateEvent(Container container) {
        EventManager em = this.getEventManager();
        if (!em.getEventIDByIndex((int)this.mnValidationStateEventId).mbDispatcherOrCalloutRegistered) {
            return false;
        }
        EventPseudoModel.EventInfo eventInfo = null;
        if (this.mEventPseudoModel != null) {
            eventInfo = this.mEventPseudoModel.getEventInfo();
        }
        try {
            if (this.mEventPseudoModel != null) {
                this.mEventPseudoModel.reset();
                this.mEventPseudoModel.setTarget(container);
                this.mEventPseudoModel.setName(21);
            }
            boolean bl = em.eventOccurred(this.mnValidationStateEventId, container);
            return bl;
        }
        finally {
            if (this.mEventPseudoModel != null) {
                this.mEventPseudoModel.setEventInfo(eventInfo);
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private boolean validateNode(Validate validate, Node node, boolean bRecursive) {
        boolean bValidationDispatched;
        assert (node != null);
        if (!this.getValidationsEnabled()) {
            return false;
        }
        bValidationDispatched = false;
        this.mValidate = validate;
        try {
            if (node instanceof FormField) {
                if (this.getEventManager().eventOccurred(this.mnValidateEventId, node)) {
                    bValidationDispatched = true;
                }
            } else if (node instanceof Container) {
                if (bRecursive) {
                    for (Node child = node.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                        if (!this.validateNode(validate, child, bRecursive)) continue;
                        bValidationDispatched = true;
                    }
                }
                if (node instanceof FormSubform || node instanceof FormExclGroup) {
                    if (this.mValidate == null) {
                        this.mValidate = validate;
                    }
                    if (node instanceof ExclGroup && !this.mTemplateModel.getLegacySetting(AppModel.XFA_LEGACY_V32_SCRIPTING)) {
                        this.mValidate.setNullTestEnabled(false);
                    }
                    if (this.getEventManager().eventOccurred(this.mnValidateEventId, node)) {
                        bValidationDispatched = true;
                    }
                }
            }
        }
        finally {
            this.mValidate = null;
        }
        return bValidationDispatched;
    }

    public boolean wasIncrementalMerge() {
        return this.mbWasIncrementalMerge;
    }

    public void setDisableFormRemerge(boolean bDisable) {
        this.mbDisableRemerge = bDisable;
    }

    public boolean getDisableFormRemerge() {
        return this.mbDisableRemerge;
    }

    void consumeDataNode(Container.FormInfo formInfo, Node dataNode, DatasetSelector eDataset) {
        if (dataNode == null) {
            return;
        }
        if (this.mergeMode() == 9175041) {
            if (formInfo != null && formInfo.eMergeType != 2031618) {
                NodeList list = null;
                switch (eDataset) {
                    case MAIN_DATASET: {
                        list = formInfo.dataNodes;
                        break;
                    }
                    case ALT_DATASET: {
                        list = formInfo.altDataNodes;
                        break;
                    }
                    default: {
                        assert (false);
                        break;
                    }
                }
                list.remove(dataNode);
            }
        } else if (this.mergeMode() == 9175040) {
            dataNode.setMapped(true);
        }
    }

    public void setGlobalConsumption(Boolean bVal) {
        this.mbGlobalConsumption = bVal;
    }

    private static boolean getAssociation(Element dataParent, String aName, NodeList list) {
        BooleanHolder bFoundNullAssociation = new BooleanHolder(false);
        Obj association = DataModel.resolveAssociation(dataParent, aName, bFoundNullAssociation);
        if (association != null) {
            if (association instanceof Node) {
                Node dataChild = (Node)association;
                list.append(dataChild);
            } else if (association instanceof NodeList) {
                NodeList nodes = (NodeList)association;
                int nDataLen = nodes.length();
                for (int i = 0; i < nDataLen; ++i) {
                    Node dataChild = (Node)nodes.item(i);
                    list.append(dataChild);
                }
            }
            return true;
        }
        if (bFoundNullAssociation.value) {
            return true;
        }
        return false;
    }

    private static boolean somIsStar(String sSom) {
        int nLength = sSom.length();
        if (nLength > 3) {
            char cOpen = sSom.charAt(nLength - 3);
            char cStar = sSom.charAt(nLength - 2);
            char cClose = sSom.charAt(nLength - 1);
            return cOpen == '[' && cStar == '*' && cClose == ']';
        }
        return false;
    }

    private static boolean somIsRelative(String sSom) {
        char cFirst = sSom.charAt(0);
        char cSecond = sSom.charAt(1);
        if (cFirst == '!') {
            return false;
        }
        if (cFirst == '$' && cSecond == '.') {
            return true;
        }
        return cFirst != '$' && cFirst != '!';
    }

    private void findOrCreateMissingData() {
        boolean bDescendants = this.getMatchDescendantsOnly();
        this.setMatchDescendantsOnly(true);
        for (int i = 0; i < this.mExplicitMatchNodes.size(); ++i) {
            Element formNode = this.mExplicitMatchNodes.get(i);
            if (formNode.isMapped()) continue;
            int eMergeType = this.mergeType(formNode, "", null);
            Element mappedParent = FormModel.getMappedParent(formNode);
            if (mappedParent instanceof FormExclGroup) continue;
            DataNode dataParent = mappedParent != null ? FormModel.getDataNode(mappedParent) : this.mStartNode;
            if (eMergeType != 2031618 && eMergeType != 2031619 && eMergeType != 2031620) continue;
            DataNode dataNode = this.createDataNode(formNode, dataParent, eMergeType, true);
            this.bindNodes(formNode, dataNode, UPDATE_DATA);
            this.consumeDataNode(null, dataNode, DatasetSelector.MAIN_DATASET);
        }
        this.mExplicitMatchNodes.clear();
        this.setMatchDescendantsOnly(bDescendants);
    }

    private static void deleteFormInfo(Container container) {
        Container.FormInfo formInfo = container.getFormInfo();
        if (formInfo != null) {
            container.setFormInfo(null);
        }
    }

    private static boolean ancestorMatches(Node node, Node baseNode) {
        while (node != null) {
            if (node == baseNode) {
                return true;
            }
            node = node.getXFAParent();
        }
        return false;
    }

    private static void recursiveDeleteFormInfos(Node baseNode, List<Container> containersWithFormInfo) {
        for (int i = containersWithFormInfo.size(); i > 0; --i) {
            Container container = containersWithFormInfo.get(i - 1);
            if (!FormModel.ancestorMatches(container, baseNode)) continue;
            FormModel.deleteFormInfo(container);
            containersWithFormInfo.remove(i - 1);
        }
    }

    private void resetLocalConsumptionContext(Element templateNode) {
        if (this.mergeMode() == 9175041) {
            for (Node child = templateNode.getFirstXFAChild(); child != null; child = child.getNextXFASibling()) {
                if (!(child instanceof Element)) continue;
                FormModel.recursiveDeleteFormInfos((Element)child, this.moContainersWithFormInfo);
            }
        }
    }

    public boolean getIgnoreCheckSum() {
        return this.mbIgnoreChecksum;
    }

    public Node copyCat() {
        FormModel poFormModel = this;
        Element oDomNode = ((Element)poFormModel.getXmlPeer()).clone(null, false);
        Packet pNewFormModel = new Packet(this.getAppModel(), null);
        pNewFormModel.setXmlPeer(oDomNode);
        int numChildren = poFormModel.getXFAChildCount();
        int index = 0;
        for (index = 0; index < numChildren; ++index) {
            Document oDoc = oDomNode.getOwnerDocument();
            if (oDoc == null) {
                oDoc = this.getAppModel().getDocument();
                oDomNode.setDocument(oDoc);
            }
            FormModel.createFormCopy((Element)poFormModel.getXFAChild(index), oDomNode, oDoc, poFormModel.getAppModel());
        }
        Element poDomNodeImpl = oDomNode;
        poFormModel.normalizeNameSpaces(poDomNodeImpl, "http://www.xfa.org/schema/xfa-form/2.8/");
        pNewFormModel.removeAttribute("checksum");
        return pNewFormModel;
    }

    private static Node createFormCopy(Node poFormNode, Element oParentNode, Document oDoc, AppModel poAppModel) {
        Node oNewNode;
        DataNode oNode;
        FormField oField;
        if (poFormNode.isSameClass(XFA.FIELDTAG) && (oNode = (oField = (FormField)poFormNode).getDataNode()) != null) {
            String sDataNodeId = new Integer(oField.getDataNode().hashCode()).toString();
            FormModel.addOrGetFSExtras(oField, "FS_DATA_ID", sDataNodeId, poAppModel, true, "FS_EXTRAS");
        }
        if (poFormNode.isSameClass(XFA.TEXTNODETAG) || poFormNode.isSameClass(XFA.RICHTEXTNODETAG) || poFormNode.isSameClass(XFA.XMLMULTISELECTNODETAG)) {
            oNewNode = oDoc.importNode(poFormNode, true);
            oParentNode.appendChild(oNewNode);
            return oNewNode;
        }
        if (poFormNode instanceof Element) {
            Element poFormNodeElem = (Element)poFormNode;
            String oLocalName = poFormNodeElem.getLocalName();
            oNewNode = oDoc.createElementNS(poFormNodeElem.getNS(), oLocalName, null);
            oNewNode.setClass(poFormNodeElem.getClassName(), poFormNodeElem.getClassTag());
            SchemaPairs poAttrs = poFormNodeElem.getNodeSchema().getValidAttributes();
            if (poAttrs != null) {
                for (int i = 0; i < poAttrs.size(); ++i) {
                    Attribute oProperty;
                    int eTag;
                    if (poAttrs.key(i) == XFA.USETAG || poAttrs.key(i) == XFA.USEHREFTAG || (oProperty = poFormNodeElem.getAttribute(eTag = poAttrs.key(i), true, false)) == null || oProperty.isEmpty()) continue;
                    String value = oProperty.toString();
                    String propertyName = poFormNodeElem.getAtom(eTag);
                    ((Element)oNewNode).setAttribute("", propertyName, propertyName, value);
                }
            }
        } else {
            oNewNode = oDoc.importNode(poFormNode, false);
        }
        oParentNode.appendChild(oNewNode);
        if (poFormNode instanceof ProtoableNode) {
            ProtoableNode poProto = (ProtoableNode)poFormNode;
            NodeList children = poProto.resolveAndEnumerateChildren(false, false);
            boolean eLastChild = false;
            Object oFirstProp = null;
            boolean bRemoveDuplicate = false;
            ByteArrayOutputStream tempStream = new ByteArrayOutputStream();
            DOMSaveOptions oOptions = new DOMSaveOptions();
            oOptions.setSaveTransient(false);
            oOptions.setExcludePreamble(true);
            oOptions.setDisplayFormat(0);
            int numChildren = children.length();
            for (int i = 0; i < numChildren; ++i) {
                Node oFormChild = (Node)children.item(i);
                int eTag = oFormChild.getClassTag();
                Element oParent = oFormChild.getXFAParent();
                Node oNewChildNode = FormModel.createFormCopy(oFormChild, (Element)oNewNode, oDoc, poAppModel);
            }
        }
        return oNewNode;
    }

    private static void addOrGetFSExtras(Element oFormNode, String sName, String sValue, AppModel poAppModel, boolean bAllowMultiple, String sExtrasName) {
        FormModel poFormModel = FormModel.getFormModel(poAppModel, false);
        Element oExtra = oFormNode.getElement(XFA.EXTRASTAG, 0);
        boolean bVal = poFormModel.allowNewNodes(true);
        boolean bCreate = true;
        boolean bCreateExtra = !sExtrasName.equals("FS_EXTRAS");
        boolean bCreateFSExtra = true;
        Element poFSExtraNode = null;
        NodeList childList = oExtra.getNodes();
        block0 : for (int i = 0; i < childList.length(); ++i) {
            Element oChildNode = (Element)childList.item(i);
            if (!oChildNode.getName().equals("FS_EXTRAS")) continue;
            bCreateFSExtra = false;
            Element oFSExtras = oChildNode;
            NodeList childChildList = oChildNode.getNodes();
            for (int k = 0; k < childChildList.length() && !sExtrasName.equals("FS_EXTRAS"); ++k) {
                if (!((Element)childChildList.item(k)).getName().equals(sExtrasName)) continue;
                bCreateExtra = false;
                oFSExtras = (Element)childChildList.item(k);
                break;
            }
            NodeList FSExtraChildList = oFSExtras.getNodes();
            for (int j = 0; j < FSExtraChildList.length() && !bAllowMultiple; ++j) {
                Element oFSNode = (Element)FSExtraChildList.item(j);
                if (!(oFSNode instanceof TextValue) || !oFSNode.getName().equals(sName)) continue;
                TextValue oTextNode = (TextValue)oFSNode;
                if (sValue.isEmpty()) {
                    sValue = oTextNode.getValue();
                } else {
                    oTextNode.setValue(sValue);
                }
                bCreate = false;
                break block0;
            }
            break;
        }
        if (!sValue.isEmpty() && bCreate) {
            if (bCreateFSExtra) {
                poFSExtraNode = poFormModel.createElement("extras", sExtrasName, oExtra);
            }
            if (bCreateExtra) {
                poFSExtraNode = poFormModel.createElement("extras", sExtrasName, poFSExtraNode);
            }
            TextValue oTextNode = (TextValue)poFormModel.createElement("text", sName, poFSExtraNode);
            oTextNode.setValue(sValue);
        }
        poFormModel.setAllowNewNodes(bVal);
    }

    public boolean isMb_IsMergedXDP() {
        return this.mb_IsMergedXDP;
    }

    public static interface PostMergeHandler {
        public void handlePostMerge(Object var1);
    }

    public static enum DatasetSelector {
        MAIN_DATASET,
        ALT_DATASET;
        

        private DatasetSelector() {
        }
    }

    private static class LayoutContentInfo {
        public final Element mNode;
        public boolean mbInitializeOccurred;

        public LayoutContentInfo(Element node) {
            this.mNode = node;
        }
    }

    private static class ValidateInfo {
        public final String msScript;
        public final String msScriptLanguage;
        public final String msEventContext;
        public final String msBarcodeType;
        public final int meRunAt;
        public final ProtoableNode mScriptContextNode;

        public ValidateInfo(String sScript, String sScriptLanguage, String sEventContext, String sBarcodeType, int eRunAt, ProtoableNode scriptContextNode) {
            this.msScript = sScript;
            this.msScriptLanguage = sScriptLanguage;
            this.msEventContext = sEventContext;
            this.msBarcodeType = sBarcodeType;
            this.meRunAt = eRunAt;
            this.mScriptContextNode = scriptContextNode;
        }
    }

    private static class SubmitInfo {
        public final String msEventContext;
        public final ProtoableNode mSubmitContextNode;

        public SubmitInfo(String sEventContext, ProtoableNode submitContextNode) {
            this.msEventContext = sEventContext;
            this.mSubmitContextNode = submitContextNode;
        }
    }

    private static class ScriptInfo {
        public final String msScript;
        public final String msScriptLanguage;
        public final String msEventContext;
        public final int meRunAt;
        public final ProtoableNode mScriptContextNode;
        public String msTarget = null;

        public ScriptInfo(String sScript, String sScriptLanguage, String sEventContext, int eRunAt, ProtoableNode scriptContextNode) {
            this.msScript = sScript;
            this.msScriptLanguage = sScriptLanguage;
            this.msEventContext = sEventContext;
            this.meRunAt = eRunAt;
            this.mScriptContextNode = scriptContextNode;
        }
    }

    private static class ExecuteInfo {
        public final String msEventContext;
        public final ProtoableNode mExecuteContextNode;

        public ExecuteInfo(String sEventContext, ProtoableNode executeContextNode) {
            this.msEventContext = sEventContext;
            this.mExecuteContextNode = executeContextNode;
        }
    }

    public static class Validate {
        private boolean mbScriptTestEnabled;
        private boolean mbNullTestEnabled;
        private boolean mbFormatTestEnabled;
        private boolean mbBarcodeTestEnabled;
        protected int mnNumFailures;

        public Validate() {
            this.mbScriptTestEnabled = true;
            this.mbNullTestEnabled = true;
            this.mbFormatTestEnabled = true;
            this.mbBarcodeTestEnabled = true;
        }

        public Validate(boolean bScriptTestEnabled, boolean bNullTestEnabled, boolean bFormatTestEnabled, boolean bBarcodeTestEnabled) {
            this.mbScriptTestEnabled = bScriptTestEnabled;
            this.mbNullTestEnabled = bNullTestEnabled;
            this.mbFormatTestEnabled = bFormatTestEnabled;
            this.mbBarcodeTestEnabled = bBarcodeTestEnabled;
        }

        public void onValidateStart() {
        }

        public void onValidateEnd() {
        }

        public Validate clone() {
            return new Validate(this.mbScriptTestEnabled, this.mbNullTestEnabled, this.mbFormatTestEnabled, this.mbBarcodeTestEnabled);
        }

        public boolean isBarcodeTestEnabled() {
            return this.mbBarcodeTestEnabled;
        }

        public void setBarcodeTestEnabled(boolean bEnabled) {
            this.mbBarcodeTestEnabled = bEnabled;
        }

        public boolean isFormatTestEnabled() {
            return this.mbFormatTestEnabled;
        }

        public void setFormatTestEnabled(boolean bEnabled) {
            this.mbFormatTestEnabled = bEnabled;
        }

        public boolean isNullTestEnabled() {
            return this.mbNullTestEnabled;
        }

        public void setNullTestEnabled(boolean bEnabled) {
            this.mbNullTestEnabled = bEnabled;
        }

        public boolean isScriptTestEnabled() {
            return this.mbScriptTestEnabled;
        }

        public void setScriptTestEnabled(boolean bEnabled) {
            this.mbScriptTestEnabled = bEnabled;
        }

        public boolean onValidateBarcodeTestFailed(FormField field, String sValidationMessage) {
            ++this.mnNumFailures;
            return true;
        }

        public boolean onValidateFormatTestFailed(FormField field, String sValidationMessage, BooleanHolder bDisableValidate) {
            ++this.mnNumFailures;
            return true;
        }

        public boolean onValidateNullTestFailed(ProtoableNode node, String sValidationMessage, BooleanHolder bDisableValidate) {
            ++this.mnNumFailures;
            return true;
        }

        public boolean onValidateScriptFailed(ProtoableNode node, String sScript, String sLanguage, String sValidationMessage, BooleanHolder bDisableValidate) {
            ++this.mnNumFailures;
            return true;
        }

        public int getFailCount() {
            return this.mnNumFailures;
        }

        public void resetFailCount() {
            this.mnNumFailures = 0;
        }

        public boolean validateBarcode(Element element, String sBarcodeType, String sValue) {
            return true;
        }
    }

    public static abstract class Submit {
        public abstract Object clone();

        public abstract void submit(SubmitParams var1);

        public abstract void setPacketToIgnore(Node var1);

        public static class SubmitParams {
            private final String[] mPackets;
            private final String msSubmitUrl;
            private final int meFormat;
            private final boolean mbEmbedPDF;
            private String msTextEncoding;
            private String msCertificate;
            private List<SignDispatcher> mSignDispatchers;

            public SubmitParams(String[] packets, String sSubmitUrl, int eFormat, String sTextEncoding, boolean bEmbedPDF) {
                this.mPackets = packets;
                this.msSubmitUrl = sSubmitUrl;
                this.meFormat = eFormat;
                this.msTextEncoding = sTextEncoding;
                this.mbEmbedPDF = bEmbedPDF;
            }

            public String getCertificate() {
                return this.msCertificate;
            }

            public boolean getEmbedPDF() {
                return this.mbEmbedPDF;
            }

            public int getFormat() {
                return this.meFormat;
            }

            public String[] getPackets() {
                return this.mPackets;
            }

            public List<SignDispatcher> getSignDispatchers() {
                return this.mSignDispatchers;
            }

            public String getSubmitUrl() {
                return this.msSubmitUrl;
            }

            public String getTextEncoding() {
                return this.msTextEncoding;
            }

            public void setCertificate(String sCertificate) {
                this.msCertificate = sCertificate;
            }

            public void setSignDispatchers(List<SignDispatcher> poSD) {
                this.mSignDispatchers = poSD;
            }

            public void setTextEncoding(String sTextEncoding) {
                this.msTextEncoding = sTextEncoding;
            }
        }

    }

    public static abstract class ServerExchange {
        public void remerge() {
        }

        public abstract byte[] sendToServer(byte[] var1);
    }

    public static abstract class Execute {
        public abstract Object clone();

        public abstract void execute(String var1, int var2, int var3);
    }

    public static interface ConnectHandler {
        public boolean handleConnect(Node var1, String var2, String var3, String var4, Object var5, ObjectHolder<DataNode> var6);
    }

}