CodecComponent.java.html 132 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
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CodecComponent.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">MTAS</a> &gt; <a href="index.source.html" class="el_package">mtas.codec.util</a> &gt; <span class="el_source">CodecComponent.java</span></div><h1>CodecComponent.java</h1><pre class="source lang-java linenums">package mtas.codec.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Base64.Decoder;
import java.util.Base64.Encoder;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mtas.analysis.token.MtasToken;
import mtas.analysis.token.MtasTokenString;
import mtas.codec.util.CodecSearchTree.MtasTreeHit;
import mtas.codec.util.collector.MtasDataCollector;
import mtas.parser.function.MtasFunctionParser;
import mtas.parser.function.ParseException;
import mtas.parser.function.util.MtasFunctionParserFunction;
import mtas.parser.function.util.MtasFunctionParserFunctionDefault;
import mtas.search.spans.util.MtasSpanQuery;

import org.apache.commons.lang.ArrayUtils;
import org.apache.lucene.util.BytesRef;

/**
 * The Class CodecComponent.
 */
public class CodecComponent {

  /**
   * Instantiates a new codec component.
   */
<span class="nc" id="L45">  private CodecComponent() {</span>
<span class="nc" id="L46">  }</span>

  /**
   * The Class ComponentFields.
   */
  public static class ComponentFields {

    /** The list. */
    public Map&lt;String, ComponentField&gt; list;

    /** The join. */
    public ComponentJoin join;

    /** The do document. */
    public boolean doDocument;

    /** The do kwic. */
    public boolean doKwic;

    /** The do list. */
    public boolean doList;

    /** The do group. */
    public boolean doGroup;

    /** The do term vector. */
    public boolean doTermVector;

    /** The do stats. */
    public boolean doStats;

    /** The do stats spans. */
    public boolean doStatsSpans;

    /** The do stats positions. */
    public boolean doStatsPositions;

    /** The do stats tokens. */
    public boolean doStatsTokens;

    /** The do prefix. */
    public boolean doPrefix;

    /** The do facet. */
    public boolean doFacet;

    /** The do join. */
    public boolean doJoin;

    /**
     * Instantiates a new component fields.
     */
<span class="fc" id="L98">    public ComponentFields() {</span>
<span class="fc" id="L99">      list = new HashMap&lt;&gt;();</span>
<span class="fc" id="L100">      join = null;</span>
<span class="fc" id="L101">      doDocument = false;</span>
<span class="fc" id="L102">      doKwic = false;</span>
<span class="fc" id="L103">      doList = false;</span>
<span class="fc" id="L104">      doGroup = false;</span>
<span class="fc" id="L105">      doStats = false;</span>
<span class="fc" id="L106">      doTermVector = false;</span>
<span class="fc" id="L107">      doStatsSpans = false;</span>
<span class="fc" id="L108">      doStatsPositions = false;</span>
<span class="fc" id="L109">      doStatsTokens = false;</span>
<span class="fc" id="L110">      doPrefix = false;</span>
<span class="fc" id="L111">      doFacet = false;</span>
<span class="fc" id="L112">      doJoin = false;</span>
<span class="fc" id="L113">    }</span>
  }

  /**
   * The Interface BasicComponent.
   */
  public abstract static interface BasicComponent {
  }

  /**
   * The Class ComponentField.
   */
  public static class ComponentField implements BasicComponent {

    /** The unique key field. */
    public String uniqueKeyField;

    /** The document list. */
    public List&lt;ComponentDocument&gt; documentList;

    /** The kwic list. */
    public List&lt;ComponentKwic&gt; kwicList;

    /** The list list. */
    public List&lt;ComponentList&gt; listList;

    /** The group list. */
    public List&lt;ComponentGroup&gt; groupList;

    /** The facet list. */
    public List&lt;ComponentFacet&gt; facetList;

    /** The term vector list. */
    public List&lt;ComponentTermVector&gt; termVectorList;

    /** The stats position list. */
    public List&lt;ComponentPosition&gt; statsPositionList;

    /** The stats token list. */
    public List&lt;ComponentToken&gt; statsTokenList;

    /** The stats span list. */
    public List&lt;ComponentSpan&gt; statsSpanList;

    /** The span query list. */
    public List&lt;MtasSpanQuery&gt; spanQueryList;

    /** The prefix. */
    public ComponentPrefix prefix;

    /**
     * Instantiates a new component field.
     *
     * @param uniqueKeyField
     *          the unique key field
     */
<span class="fc" id="L169">    public ComponentField(String uniqueKeyField) {</span>
<span class="fc" id="L170">      this.uniqueKeyField = uniqueKeyField;</span>
      // initialise
<span class="fc" id="L172">      documentList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L173">      kwicList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L174">      listList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L175">      groupList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L176">      facetList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L177">      termVectorList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L178">      statsPositionList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L179">      statsTokenList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L180">      statsSpanList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L181">      spanQueryList = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L182">      prefix = null;</span>
<span class="fc" id="L183">    }</span>
  }

  /**
   * The Class ComponentPrefix.
   */
  public static class ComponentPrefix implements BasicComponent {

    /** The key. */
    public String key;

    /** The single position list. */
    public SortedSet&lt;String&gt; singlePositionList;

    /** The multiple position list. */
    public SortedSet&lt;String&gt; multiplePositionList;

    /** The set position list. */
    public SortedSet&lt;String&gt; setPositionList;

    /** The intersecting list. */
    public SortedSet&lt;String&gt; intersectingList;

    /**
     * Instantiates a new component prefix.
     *
     * @param key
     *          the key
     */
<span class="fc" id="L212">    public ComponentPrefix(String key) {</span>
<span class="fc" id="L213">      this.key = key;</span>
<span class="fc" id="L214">      singlePositionList = new TreeSet&lt;&gt;();</span>
<span class="fc" id="L215">      multiplePositionList = new TreeSet&lt;&gt;();</span>
<span class="fc" id="L216">      setPositionList = new TreeSet&lt;&gt;();</span>
<span class="fc" id="L217">      intersectingList = new TreeSet&lt;&gt;();</span>
<span class="fc" id="L218">    }</span>

    /**
     * Adds the single position.
     *
     * @param prefix
     *          the prefix
     */
    public void addSinglePosition(String prefix) {
<span class="pc bpc" id="L227" title="1 of 4 branches missed.">      if (!prefix.trim().isEmpty() &amp;&amp; !singlePositionList.contains(prefix)</span>
<span class="pc bpc" id="L228" title="1 of 2 branches missed.">          &amp;&amp; !multiplePositionList.contains(prefix)) {</span>
<span class="fc" id="L229">        singlePositionList.add(prefix);</span>
      }
<span class="fc" id="L231">    }</span>

    /**
     * Adds the multiple position.
     *
     * @param prefix
     *          the prefix
     */
    public void addMultiplePosition(String prefix) {
<span class="pc bpc" id="L240" title="1 of 2 branches missed.">      if (!prefix.trim().isEmpty()) {</span>
<span class="pc bpc" id="L241" title="1 of 2 branches missed.">        if (!singlePositionList.contains(prefix)) {</span>
<span class="fc bfc" id="L242" title="All 2 branches covered.">          if (!multiplePositionList.contains(prefix)) {</span>
<span class="fc" id="L243">            multiplePositionList.add(prefix);</span>
          }
        } else {
<span class="nc" id="L246">          singlePositionList.remove(prefix);</span>
<span class="nc" id="L247">          multiplePositionList.add(prefix);</span>
        }
      }
<span class="fc" id="L250">    }</span>

    /**
     * Adds the set position.
     *
     * @param prefix
     *          the prefix
     */
    public void addSetPosition(String prefix) {
<span class="pc bpc" id="L259" title="1 of 2 branches missed.">      if (!prefix.trim().isEmpty()) {</span>
<span class="pc bpc" id="L260" title="1 of 2 branches missed.">        if (!singlePositionList.contains(prefix)) {</span>
<span class="fc bfc" id="L261" title="All 2 branches covered.">          if (!setPositionList.contains(prefix)) {</span>
<span class="fc" id="L262">            setPositionList.add(prefix);</span>
          }
        } else {
<span class="nc" id="L265">          singlePositionList.remove(prefix);</span>
<span class="nc" id="L266">          setPositionList.add(prefix);</span>
        }
      }
<span class="fc" id="L269">    }</span>

    /**
     * Adds the intersecting.
     *
     * @param prefix
     *          the prefix
     */
    public void addIntersecting(String prefix) {
<span class="pc bpc" id="L278" title="1 of 2 branches missed.">      if (!prefix.trim().isEmpty()) {</span>
<span class="fc" id="L279">        intersectingList.add(prefix);</span>
      }
<span class="fc" id="L281">    }</span>

  }

  /**
   * The Class ComponentDocument.
   */
  public static class ComponentDocument implements BasicComponent {

    /** The key. */
    public String key;

    /** The prefix. */
    public String prefix;

    /** The regexp. */
    public String regexp;

    /** The ignore regexp. */
    public String ignoreRegexp;

    /** The list. */
    public Set&lt;String&gt; list;

    /** The ignore list. */
    public Set&lt;String&gt; ignoreList;

    /** The list regexp. */
    public boolean listRegexp;

    /** The list expand. */
    public boolean listExpand;

    /** The ignore list regexp. */
    public boolean ignoreListRegexp;

    /** The list expand number. */
    public int listExpandNumber;

    /** The data type. */
    public String dataType;

    /** The stats type. */
    public String statsType;

    /** The stats items. */
    public SortedSet&lt;String&gt; statsItems;

    /** The list number. */
    public int listNumber;

    /** The unique key. */
    public Map&lt;Integer, String&gt; uniqueKey;

    /** The stats data. */
    public Map&lt;Integer, MtasDataCollector&lt;?, ?&gt;&gt; statsData;

    /** The stats list. */
    public Map&lt;Integer, MtasDataCollector&lt;?, ?&gt;&gt; statsList;

    /**
     * Instantiates a new component document.
     *
     * @param key
     *          the key
     * @param prefix
     *          the prefix
     * @param statsType
     *          the stats type
     * @param regexp
     *          the regexp
     * @param list
     *          the list
     * @param listNumber
     *          the list number
     * @param listRegexp
     *          the list regexp
     * @param listExpand
     *          the list expand
     * @param listExpandNumber
     *          the list expand number
     * @param ignoreRegexp
     *          the ignore regexp
     * @param ignoreList
     *          the ignore list
     * @param ignoreListRegexp
     *          the ignore list regexp
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public ComponentDocument(String key, String prefix, String statsType,
        String regexp, String[] list, int listNumber, Boolean listRegexp,
        Boolean listExpand, int listExpandNumber, String ignoreRegexp,
<span class="nc" id="L374">        String[] ignoreList, Boolean ignoreListRegexp) throws IOException {</span>
<span class="nc" id="L375">      this.key = key;</span>
<span class="nc" id="L376">      this.prefix = prefix;</span>
<span class="nc" id="L377">      this.regexp = regexp;</span>
<span class="nc bnc" id="L378" title="All 4 branches missed.">      if (list != null &amp;&amp; list.length &gt; 0) {</span>
<span class="nc" id="L379">        this.list = new HashSet&lt;&gt;(Arrays.asList(list));</span>
<span class="nc bnc" id="L380" title="All 2 branches missed.">        this.listRegexp = listRegexp != null ? listRegexp : false;</span>
<span class="nc bnc" id="L381" title="All 4 branches missed.">        this.listExpand = (listExpand != null &amp;&amp; listExpandNumber &gt; 0)</span>
<span class="nc" id="L382">            ? listExpand : false;</span>
<span class="nc bnc" id="L383" title="All 2 branches missed.">        if (this.listExpand) {</span>
<span class="nc" id="L384">          this.listExpandNumber = listExpandNumber;</span>
        } else {
<span class="nc" id="L386">          this.listExpandNumber = 0;</span>
        }
      } else {
<span class="nc" id="L389">        this.list = null;</span>
<span class="nc" id="L390">        this.listRegexp = false;</span>
<span class="nc" id="L391">        this.listExpand = false;</span>
<span class="nc" id="L392">        this.listExpandNumber = 0;</span>
      }
<span class="nc" id="L394">      this.ignoreRegexp = ignoreRegexp;</span>
<span class="nc bnc" id="L395" title="All 4 branches missed.">      if (ignoreList != null &amp;&amp; ignoreList.length &gt; 0) {</span>
<span class="nc" id="L396">        this.ignoreList = new HashSet&lt;&gt;(Arrays.asList(ignoreList));</span>
<span class="nc bnc" id="L397" title="All 2 branches missed.">        this.ignoreListRegexp = ignoreListRegexp != null ? ignoreListRegexp</span>
            : false;
      } else {
<span class="nc" id="L400">        this.ignoreList = null;</span>
<span class="nc" id="L401">        this.ignoreListRegexp = false;</span>
      }
<span class="nc" id="L403">      this.listNumber = listNumber;</span>
<span class="nc" id="L404">      uniqueKey = new HashMap&lt;&gt;();</span>
<span class="nc" id="L405">      dataType = CodecUtil.DATA_TYPE_LONG;</span>
<span class="nc" id="L406">      statsItems = CodecUtil.createStatsItems(statsType);</span>
<span class="nc" id="L407">      this.statsType = CodecUtil.createStatsType(statsItems, null, null);</span>
<span class="nc" id="L408">      this.statsData = new HashMap&lt;&gt;();</span>
<span class="nc bnc" id="L409" title="All 2 branches missed.">      if (this.listNumber &gt; 0) {</span>
<span class="nc" id="L410">        this.statsList = new HashMap&lt;&gt;();</span>
      } else {
<span class="nc" id="L412">        this.statsList = null;</span>
      }
<span class="nc" id="L414">    }</span>
  }

  /**
   * The Class ComponentKwic.
   */
  public static class ComponentKwic implements BasicComponent {

    /** The query. */
    public MtasSpanQuery query;

    /** The key. */
    public String key;

    /** The tokens. */
    public Map&lt;Integer, List&lt;KwicToken&gt;&gt; tokens;

    /** The hits. */
    public Map&lt;Integer, List&lt;KwicHit&gt;&gt; hits;

    /** The unique key. */
    public Map&lt;Integer, String&gt; uniqueKey;

    /** The sub total. */
    public Map&lt;Integer, Integer&gt; subTotal;

    /** The min position. */
    public Map&lt;Integer, Integer&gt; minPosition;

    /** The max position. */
    public Map&lt;Integer, Integer&gt; maxPosition;

    /** The prefixes. */
    public List&lt;String&gt; prefixes;

    /** The left. */
    public int left;

    /** The right. */
    public int right;

    /** The start. */
    public int start;

    /** The number. */
    public Integer number;

    /** The output. */
    public String output;

    /** The Constant KWIC_OUTPUT_TOKEN. */
    public static final String KWIC_OUTPUT_TOKEN = &quot;token&quot;;

    /** The Constant KWIC_OUTPUT_HIT. */
    public static final String KWIC_OUTPUT_HIT = &quot;hit&quot;;

    /**
     * Instantiates a new component kwic.
     *
     * @param query
     *          the query
     * @param key
     *          the key
     * @param prefixes
     *          the prefixes
     * @param number
     *          the number
     * @param start
     *          the start
     * @param left
     *          the left
     * @param right
     *          the right
     * @param output
     *          the output
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public ComponentKwic(MtasSpanQuery query, String key, String prefixes,
        Integer number, int start, int left, int right, String output)
<span class="nc" id="L494">        throws IOException {</span>
<span class="nc" id="L495">      this.query = query;</span>
<span class="nc" id="L496">      this.key = key;</span>
<span class="nc bnc" id="L497" title="All 2 branches missed.">      this.left = (left &gt; 0) ? left : 0;</span>
<span class="nc bnc" id="L498" title="All 2 branches missed.">      this.right = (right &gt; 0) ? right : 0;</span>
<span class="nc bnc" id="L499" title="All 2 branches missed.">      this.start = (start &gt; 0) ? start : 0;</span>
<span class="nc bnc" id="L500" title="All 4 branches missed.">      this.number = (number != null &amp;&amp; number &gt;= 0) ? number : null;</span>
<span class="nc" id="L501">      this.output = output;</span>
<span class="nc" id="L502">      tokens = new HashMap&lt;&gt;();</span>
<span class="nc" id="L503">      hits = new HashMap&lt;&gt;();</span>
<span class="nc" id="L504">      uniqueKey = new HashMap&lt;&gt;();</span>
<span class="nc" id="L505">      subTotal = new HashMap&lt;&gt;();</span>
<span class="nc" id="L506">      minPosition = new HashMap&lt;&gt;();</span>
<span class="nc" id="L507">      maxPosition = new HashMap&lt;&gt;();</span>
<span class="nc" id="L508">      this.prefixes = new ArrayList&lt;&gt;();</span>
<span class="nc bnc" id="L509" title="All 4 branches missed.">      if ((prefixes != null) &amp;&amp; (prefixes.trim().length() &gt; 0)) {</span>
<span class="nc" id="L510">        List&lt;String&gt; l = Arrays.asList(prefixes.split(Pattern.quote(&quot;,&quot;)));</span>
<span class="nc bnc" id="L511" title="All 2 branches missed.">        for (String ls : l) {</span>
<span class="nc bnc" id="L512" title="All 2 branches missed.">          if (ls.trim().length() &gt; 0) {</span>
<span class="nc" id="L513">            this.prefixes.add(ls.trim());</span>
          }
<span class="nc" id="L515">        }</span>
      }
<span class="nc bnc" id="L517" title="All 2 branches missed.">      if (this.output == null) {</span>
<span class="nc bnc" id="L518" title="All 2 branches missed.">        if (!this.prefixes.isEmpty()) {</span>
<span class="nc" id="L519">          this.output = ComponentKwic.KWIC_OUTPUT_HIT;</span>
        } else {
<span class="nc" id="L521">          this.output = ComponentKwic.KWIC_OUTPUT_TOKEN;</span>
        }
<span class="nc bnc" id="L523" title="All 2 branches missed.">      } else if (!this.output.equals(ComponentKwic.KWIC_OUTPUT_HIT)</span>
<span class="nc bnc" id="L524" title="All 2 branches missed.">          &amp;&amp; !this.output.equals(ComponentKwic.KWIC_OUTPUT_TOKEN)) {</span>
<span class="nc" id="L525">        throw new IOException(&quot;unrecognized output '&quot; + this.output + &quot;'&quot;);</span>
      }
<span class="nc" id="L527">    }</span>
  }

  /**
   * The Class ComponentList.
   */
  public static class ComponentList implements BasicComponent {

    /** The span query. */
    public MtasSpanQuery spanQuery;

    /** The field. */
    public String field;

    /** The query value. */
    public String queryValue;

    /** The query type. */
    public String queryType;

    /** The query prefix. */
    public String queryPrefix;

    /** The query ignore. */
    public String queryIgnore;

    /** The query maximum ignore length. */
    public String queryMaximumIgnoreLength;

    /** The key. */
    public String key;

    /** The query variables. */
    public Map&lt;String, String[]&gt; queryVariables;

    /** The tokens. */
    public List&lt;ListToken&gt; tokens;

    /** The hits. */
    public List&lt;ListHit&gt; hits;

    /** The unique key. */
    public Map&lt;Integer, String&gt; uniqueKey;

    /** The sub total. */
    public Map&lt;Integer, Integer&gt; subTotal;

    /** The min position. */
    public Map&lt;Integer, Integer&gt; minPosition;

    /** The max position. */
    public Map&lt;Integer, Integer&gt; maxPosition;

    /** The prefixes. */
    public List&lt;String&gt; prefixes;

    /** The left. */
    public int left;

    /** The right. */
    public int right;

    /** The total. */
    public int total;

    /** The position. */
    public int position;

    /** The start. */
    public int start;

    /** The number. */
    public int number;

    /** The prefix. */
    public String prefix;

    /** The output. */
    public String output;

    /** The Constant LIST_OUTPUT_TOKEN. */
    public static final String LIST_OUTPUT_TOKEN = &quot;token&quot;;

    /** The Constant LIST_OUTPUT_HIT. */
    public static final String LIST_OUTPUT_HIT = &quot;hit&quot;;

    /**
     * Instantiates a new component list.
     *
     * @param spanQuery
     *          the span query
     * @param field
     *          the field
     * @param queryValue
     *          the query value
     * @param queryType
     *          the query type
     * @param queryPrefix
     *          the query prefix
     * @param queryVariables
     *          the query variables
     * @param queryIgnore
     *          the query ignore
     * @param queryMaximumIgnoreLength
     *          the query maximum ignore length
     * @param key
     *          the key
     * @param prefix
     *          the prefix
     * @param start
     *          the start
     * @param number
     *          the number
     * @param left
     *          the left
     * @param right
     *          the right
     * @param output
     *          the output
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public ComponentList(MtasSpanQuery spanQuery, String field,
        String queryValue, String queryType, String queryPrefix,
        Map&lt;String, String[]&gt; queryVariables, String queryIgnore,
        String queryMaximumIgnoreLength, String key, String prefix, int start,
<span class="nc" id="L653">        int number, int left, int right, String output) throws IOException {</span>
<span class="nc" id="L654">      this.spanQuery = spanQuery;</span>
<span class="nc" id="L655">      this.field = field;</span>
<span class="nc" id="L656">      this.queryValue = queryValue;</span>
<span class="nc" id="L657">      this.queryType = queryType;</span>
<span class="nc" id="L658">      this.queryPrefix = queryPrefix;</span>
<span class="nc" id="L659">      this.queryIgnore = queryIgnore;</span>
<span class="nc" id="L660">      this.queryMaximumIgnoreLength = queryMaximumIgnoreLength;</span>
<span class="nc" id="L661">      this.queryVariables = queryVariables;</span>
<span class="nc" id="L662">      this.key = key;</span>
<span class="nc" id="L663">      this.left = left;</span>
<span class="nc" id="L664">      this.right = right;</span>
<span class="nc" id="L665">      this.start = start;</span>
<span class="nc" id="L666">      this.number = number;</span>
<span class="nc" id="L667">      this.output = output;</span>
<span class="nc" id="L668">      this.prefix = prefix;</span>
<span class="nc" id="L669">      total = 0;</span>
<span class="nc" id="L670">      position = 0;</span>
<span class="nc" id="L671">      tokens = new ArrayList&lt;&gt;();</span>
<span class="nc" id="L672">      hits = new ArrayList&lt;&gt;();</span>
<span class="nc" id="L673">      uniqueKey = new HashMap&lt;&gt;();</span>
<span class="nc" id="L674">      subTotal = new HashMap&lt;&gt;();</span>
<span class="nc" id="L675">      minPosition = new HashMap&lt;&gt;();</span>
<span class="nc" id="L676">      maxPosition = new HashMap&lt;&gt;();</span>
<span class="nc" id="L677">      this.prefixes = new ArrayList&lt;&gt;();</span>
<span class="nc bnc" id="L678" title="All 4 branches missed.">      if ((prefix != null) &amp;&amp; (prefix.trim().length() &gt; 0)) {</span>
<span class="nc" id="L679">        List&lt;String&gt; l = Arrays.asList(prefix.split(Pattern.quote(&quot;,&quot;)));</span>
<span class="nc bnc" id="L680" title="All 2 branches missed.">        for (String ls : l) {</span>
<span class="nc bnc" id="L681" title="All 2 branches missed.">          if (ls.trim().length() &gt; 0) {</span>
<span class="nc" id="L682">            this.prefixes.add(ls.trim());</span>
          }
<span class="nc" id="L684">        }</span>
      }
      // check output
<span class="nc bnc" id="L687" title="All 2 branches missed.">      if (this.output == null) {</span>
<span class="nc bnc" id="L688" title="All 2 branches missed.">        if (!this.prefixes.isEmpty()) {</span>
<span class="nc" id="L689">          this.output = ComponentList.LIST_OUTPUT_HIT;</span>
        } else {
<span class="nc" id="L691">          this.output = ComponentList.LIST_OUTPUT_TOKEN;</span>
        }
<span class="nc bnc" id="L693" title="All 2 branches missed.">      } else if (!this.output.equals(ComponentList.LIST_OUTPUT_HIT)</span>
<span class="nc bnc" id="L694" title="All 2 branches missed.">          &amp;&amp; !this.output.equals(ComponentList.LIST_OUTPUT_TOKEN)) {</span>
<span class="nc" id="L695">        throw new IOException(&quot;unrecognized output '&quot; + this.output + &quot;'&quot;);</span>
      }
<span class="nc" id="L697">    }</span>
  }

  /**
   * The Class ComponentGroup.
   */
  public static class ComponentGroup implements BasicComponent {

    /** The span query. */
    public MtasSpanQuery spanQuery;

    /** The data type. */
    public String dataType;

    /** The stats type. */
    public String statsType;

    /** The sort type. */
    public String sortType;

    /** The sort direction. */
    public String sortDirection;

    /** The stats items. */
    public SortedSet&lt;String&gt; statsItems;

    /** The start. */
    public Integer start;

    /** The number. */
    public Integer number;

    /** The key. */
    public String key;

    /** The data collector. */
    public MtasDataCollector&lt;?, ?&gt; dataCollector;

    /** The prefixes. */
    ArrayList&lt;String&gt; prefixes;

    /** The hit inside. */
    HashSet&lt;String&gt; hitInside;

    /** The hit inside left. */
    HashSet&lt;String&gt;[] hitInsideLeft;

    /** The hit inside right. */
    HashSet&lt;String&gt;[] hitInsideRight;

    /** The hit left. */
    HashSet&lt;String&gt;[] hitLeft;

    /** The hit right. */
    HashSet&lt;String&gt;[] hitRight;

    /** The left. */
    HashSet&lt;String&gt;[] left;

    /** The right. */
    HashSet&lt;String&gt;[] right;

    /**
     * Instantiates a new component group.
     *
     * @param spanQuery
     *          the span query
     * @param key
     *          the key
     * @param number
     *          the number
     * @param groupingHitInsidePrefixes
     *          the grouping hit inside prefixes
     * @param groupingHitInsideLeftPosition
     *          the grouping hit inside left position
     * @param groupingHitInsideLeftPrefixes
     *          the grouping hit inside left prefixes
     * @param groupingHitInsideRightPosition
     *          the grouping hit inside right position
     * @param groupingHitInsideRightPrefixes
     *          the grouping hit inside right prefixes
     * @param groupingHitLeftPosition
     *          the grouping hit left position
     * @param groupingHitLeftPrefixes
     *          the grouping hit left prefixes
     * @param groupingHitRightPosition
     *          the grouping hit right position
     * @param groupingHitRightPrefixes
     *          the grouping hit right prefixes
     * @param groupingLeftPosition
     *          the grouping left position
     * @param groupingLeftPrefixes
     *          the grouping left prefixes
     * @param groupingRightPosition
     *          the grouping right position
     * @param groupingRightPrefixes
     *          the grouping right prefixes
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public ComponentGroup(MtasSpanQuery spanQuery, String key, int number,
        String groupingHitInsidePrefixes,
        String[] groupingHitInsideLeftPosition,
        String[] groupingHitInsideLeftPrefixes,
        String[] groupingHitInsideRightPosition,
        String[] groupingHitInsideRightPrefixes,
        String[] groupingHitLeftPosition, String[] groupingHitLeftPrefixes,
        String[] groupingHitRightPosition, String[] groupingHitRightPrefixes,
        String[] groupingLeftPosition, String[] groupingLeftPrefixes,
        String[] groupingRightPosition, String[] groupingRightPrefixes)
<span class="fc" id="L807">        throws IOException {</span>
<span class="fc" id="L808">      this.spanQuery = spanQuery;</span>
<span class="fc" id="L809">      this.key = key;</span>
<span class="fc" id="L810">      this.dataType = CodecUtil.DATA_TYPE_LONG;</span>
<span class="fc" id="L811">      this.sortType = CodecUtil.STATS_TYPE_SUM;</span>
<span class="fc" id="L812">      this.sortDirection = CodecUtil.SORT_DESC;</span>
<span class="fc" id="L813">      this.statsItems = CodecUtil.createStatsItems(&quot;n,sum,mean&quot;);</span>
<span class="fc" id="L814">      this.statsType = CodecUtil.createStatsType(this.statsItems, this.sortType,</span>
          null);
<span class="fc" id="L816">      this.start = 0;</span>
<span class="fc" id="L817">      this.number = number;</span>
<span class="fc" id="L818">      HashSet&lt;String&gt; tmpPrefixes = new HashSet&lt;&gt;();</span>
      // analyze grouping condition
<span class="pc bpc" id="L820" title="1 of 2 branches missed.">      if (groupingHitInsidePrefixes != null) {</span>
<span class="fc" id="L821">        hitInside = new HashSet&lt;&gt;();</span>
<span class="fc" id="L822">        String[] tmpList = groupingHitInsidePrefixes.split(&quot;,&quot;);</span>
<span class="fc bfc" id="L823" title="All 2 branches covered.">        for (String tmpItem : tmpList) {</span>
<span class="pc bpc" id="L824" title="1 of 2 branches missed.">          if (!tmpItem.trim().isEmpty()) {</span>
<span class="fc" id="L825">            hitInside.add(tmpItem.trim());</span>
          }
        }
<span class="fc" id="L828">        tmpPrefixes.addAll(hitInside);</span>
<span class="fc" id="L829">      } else {</span>
<span class="nc" id="L830">        hitInside = null;</span>
      }
<span class="fc" id="L832">      hitInsideLeft = createPositionedPrefixes(tmpPrefixes,</span>
          groupingHitInsideLeftPosition, groupingHitInsideLeftPrefixes);
<span class="fc" id="L834">      hitInsideRight = createPositionedPrefixes(tmpPrefixes,</span>
          groupingHitInsideRightPosition, groupingHitInsideRightPrefixes);
<span class="fc" id="L836">      hitLeft = createPositionedPrefixes(tmpPrefixes, groupingHitLeftPosition,</span>
          groupingHitLeftPrefixes);
<span class="fc" id="L838">      hitRight = createPositionedPrefixes(tmpPrefixes, groupingHitRightPosition,</span>
          groupingHitRightPrefixes);
<span class="fc" id="L840">      left = createPositionedPrefixes(tmpPrefixes, groupingLeftPosition,</span>
          groupingLeftPrefixes);
<span class="fc" id="L842">      right = createPositionedPrefixes(tmpPrefixes, groupingRightPosition,</span>
          groupingRightPrefixes);
<span class="fc" id="L844">      prefixes = new ArrayList&lt;&gt;(tmpPrefixes);</span>
      // datacollector
<span class="fc" id="L846">      dataCollector = DataCollector.getCollector(</span>
          DataCollector.COLLECTOR_TYPE_LIST, this.dataType, this.statsType,
          this.statsItems, this.sortType, this.sortDirection, this.start,
          this.number, null, null);
<span class="fc" id="L850">    }</span>

    /**
     * Creates the positioned prefixes.
     *
     * @param prefixList
     *          the prefix list
     * @param position
     *          the position
     * @param prefixes
     *          the prefixes
     * @return the hash set[]
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    private static HashSet&lt;String&gt;[] createPositionedPrefixes(
        HashSet&lt;String&gt; prefixList, String[] position, String[] prefixes)
        throws IOException {
<span class="fc" id="L868">      Pattern p = Pattern.compile(&quot;^([0-9]+)(\\-([0-9]+))?$&quot;);</span>
      Matcher m;
<span class="pc bpc" id="L870" title="2 of 4 branches missed.">      if (position == null &amp;&amp; prefixes == null) {</span>
<span class="fc" id="L871">        return null;</span>
<span class="nc bnc" id="L872" title="All 6 branches missed.">      } else if (prefixes == null || position == null</span>
          || position.length != prefixes.length) {
<span class="nc" id="L874">        throw new IOException(&quot;incorrect position/prefixes&quot;);</span>
<span class="nc bnc" id="L875" title="All 2 branches missed.">      } else if (position.length == 0) {</span>
<span class="nc" id="L876">        return null;</span>
      } else {
        // analyze positions
<span class="nc" id="L879">        int[][] tmpPosition = new int[position.length][];</span>
<span class="nc" id="L880">        int maxPosition = -1;</span>
<span class="nc bnc" id="L881" title="All 2 branches missed.">        for (int i = 0; i &lt; position.length; i++) {</span>
<span class="nc" id="L882">          m = p.matcher(position[i]);</span>
<span class="nc bnc" id="L883" title="All 2 branches missed.">          if (m.find()) {</span>
<span class="nc bnc" id="L884" title="All 2 branches missed.">            if (m.group(3) == null) {</span>
<span class="nc" id="L885">              int start = Integer.parseInt(m.group(1));</span>
<span class="nc" id="L886">              tmpPosition[i] = new int[] { start };</span>
<span class="nc" id="L887">              maxPosition = Math.max(maxPosition, start);</span>
<span class="nc" id="L888">            } else {</span>
<span class="nc" id="L889">              int start = Integer.parseInt(m.group(1));</span>
<span class="nc" id="L890">              int end = Integer.parseInt(m.group(3));</span>
<span class="nc bnc" id="L891" title="All 2 branches missed.">              if (start &gt; end) {</span>
<span class="nc" id="L892">                throw new IOException(&quot;incorrect position &quot; + position[i]);</span>
              } else {
<span class="nc" id="L894">                tmpPosition[i] = new int[end - start + 1];</span>
<span class="nc bnc" id="L895" title="All 2 branches missed.">                for (int t = start; t &lt;= end; t++)</span>
<span class="nc" id="L896">                  tmpPosition[i][t - start] = t;</span>
<span class="nc" id="L897">                maxPosition = Math.max(maxPosition, end);</span>
              }
<span class="nc" id="L899">            }</span>
          } else {
<span class="nc" id="L901">            throw new IOException(&quot;incorrect position &quot; + position[i]);</span>
          }
        }
        @SuppressWarnings(&quot;unchecked&quot;)
<span class="nc" id="L905">        HashSet&lt;String&gt;[] result = new HashSet[maxPosition + 1];</span>
<span class="nc" id="L906">        Arrays.fill(result, null);</span>
        List&lt;String&gt; tmpPrefixList;
        String[] tmpList;
<span class="nc bnc" id="L909" title="All 2 branches missed.">        for (int i = 0; i &lt; tmpPosition.length; i++) {</span>
<span class="nc" id="L910">          tmpList = prefixes[i].split(&quot;,&quot;);</span>
<span class="nc" id="L911">          tmpPrefixList = new ArrayList&lt;&gt;();</span>
<span class="nc bnc" id="L912" title="All 2 branches missed.">          for (String tmpItem : tmpList) {</span>
<span class="nc bnc" id="L913" title="All 2 branches missed.">            if (!tmpItem.trim().isEmpty()) {</span>
<span class="nc" id="L914">              tmpPrefixList.add(tmpItem.trim());</span>
            }
          }
<span class="nc bnc" id="L917" title="All 2 branches missed.">          if (tmpPrefixList.isEmpty()) {</span>
<span class="nc" id="L918">            throw new IOException(&quot;incorrect prefixes &quot; + prefixes[i]);</span>
          }
<span class="nc bnc" id="L920" title="All 2 branches missed.">          for (int t = 0; t &lt; tmpPosition[i].length; t++) {</span>
<span class="nc bnc" id="L921" title="All 2 branches missed.">            if (result[tmpPosition[i][t]] == null) {</span>
<span class="nc" id="L922">              result[tmpPosition[i][t]] = new HashSet&lt;&gt;();</span>
            }
<span class="nc" id="L924">            result[tmpPosition[i][t]].addAll(tmpPrefixList);</span>
          }
<span class="nc" id="L926">          prefixList.addAll(tmpPrefixList);</span>
        }
<span class="nc" id="L928">        return result;</span>
      }
    }

  }

  /**
   * The Class ComponentFacet.
   */
  public static class ComponentFacet implements BasicComponent {

    /** The span queries. */
    public MtasSpanQuery[] spanQueries;

    /** The base fields. */
    public String[] baseFields;

    /** The base field types. */
    public String[] baseFieldTypes;

    /** The base types. */
    public String[] baseTypes;

    /** The base sort types. */
    public String[] baseSortTypes;

    /** The base sort directions. */
    public String[] baseSortDirections;

    /** The base range sizes. */
    public Double[] baseRangeSizes;

    /** The base range bases. */
    public Double[] baseRangeBases;

    /** The base collector types. */
    public String[] baseCollectorTypes;

    /** The base data types. */
    public String[] baseDataTypes;

    /** The base stats types. */
    public String[] baseStatsTypes;

    /** The base stats items. */
    public SortedSet&lt;String&gt;[] baseStatsItems;

    /** The key. */
    public String key;

    /** The data collector. */
    public MtasDataCollector&lt;?, ?&gt; dataCollector;

    /** The base function list. */
    public HashMap&lt;MtasDataCollector&lt;?, ?&gt;, SubComponentFunction[]&gt;[] baseFunctionList;

    /** The base numbers. */
    public Integer[] baseNumbers;

    /** The base minimum longs. */
    public Long[] baseMinimumLongs;

    /** The base maximum longs. */
    public Long[] baseMaximumLongs;

    /** The base parsers. */
    public MtasFunctionParserFunction[] baseParsers;

    /** The base function keys. */
    public String[][] baseFunctionKeys;

    /** The base function expressions. */
    public String[][] baseFunctionExpressions;

    /** The base function types. */
    public String[][] baseFunctionTypes;

    /** The base function parser functions. */
    public MtasFunctionParserFunction[][] baseFunctionParserFunctions;

    /** The Constant TYPE_INTEGER. */
    public static final String TYPE_INTEGER = &quot;integer&quot;;

    /** The Constant TYPE_DOUBLE. */
    public static final String TYPE_DOUBLE = &quot;double&quot;;

    /** The Constant TYPE_LONG. */
    public static final String TYPE_LONG = &quot;long&quot;;

    /** The Constant TYPE_FLOAT. */
    public static final String TYPE_FLOAT = &quot;float&quot;;

    /** The Constant TYPE_STRING. */
    public static final String TYPE_STRING = &quot;string&quot;;

    /**
     * Instantiates a new component facet.
     *
     * @param spanQueries
     *          the span queries
     * @param field
     *          the field
     * @param key
     *          the key
     * @param baseFields
     *          the base fields
     * @param baseFieldTypes
     *          the base field types
     * @param baseTypes
     *          the base types
     * @param baseRangeSizes
     *          the base range sizes
     * @param baseRangeBases
     *          the base range bases
     * @param baseSortTypes
     *          the base sort types
     * @param baseSortDirections
     *          the base sort directions
     * @param baseNumbers
     *          the base numbers
     * @param baseMinimumDoubles
     *          the base minimum doubles
     * @param baseMaximumDoubles
     *          the base maximum doubles
     * @param baseFunctionKeys
     *          the base function keys
     * @param baseFunctionExpressions
     *          the base function expressions
     * @param baseFunctionTypes
     *          the base function types
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     * @throws ParseException
     *           the parse exception
     */
    @SuppressWarnings(&quot;unchecked&quot;)
    public ComponentFacet(MtasSpanQuery[] spanQueries, String field, String key,
        String[] baseFields, String[] baseFieldTypes, String[] baseTypes,
        Double[] baseRangeSizes, Double[] baseRangeBases,
        String[] baseSortTypes, String[] baseSortDirections,
        Integer[] baseNumbers, Double[] baseMinimumDoubles,
        Double[] baseMaximumDoubles, String[][] baseFunctionKeys,
        String[][] baseFunctionExpressions, String[][] baseFunctionTypes)
<span class="nc" id="L1071">        throws IOException, ParseException {</span>
<span class="nc" id="L1072">      this.spanQueries = (MtasSpanQuery[]) spanQueries.clone();</span>
<span class="nc" id="L1073">      this.key = key;</span>
<span class="nc" id="L1074">      this.baseFields = (String[]) baseFields.clone();</span>
<span class="nc" id="L1075">      this.baseFieldTypes = (String[]) baseFieldTypes.clone();</span>
<span class="nc" id="L1076">      this.baseTypes = (String[]) baseTypes.clone();</span>
<span class="nc" id="L1077">      this.baseRangeSizes = (Double[]) baseRangeSizes.clone();</span>
<span class="nc" id="L1078">      this.baseRangeBases = (Double[]) baseRangeBases.clone();</span>
<span class="nc" id="L1079">      this.baseSortTypes = (String[]) baseSortTypes.clone();</span>
<span class="nc" id="L1080">      this.baseSortDirections = (String[]) baseSortDirections.clone();</span>
<span class="nc" id="L1081">      this.baseNumbers = (Integer[]) baseNumbers.clone();</span>
      // compute types
<span class="nc" id="L1083">      this.baseMinimumLongs = new Long[baseFields.length];</span>
<span class="nc" id="L1084">      this.baseMaximumLongs = new Long[baseFields.length];</span>
<span class="nc" id="L1085">      this.baseCollectorTypes = new String[baseFields.length];</span>
<span class="nc" id="L1086">      this.baseStatsItems = new SortedSet[baseFields.length];</span>
<span class="nc" id="L1087">      this.baseStatsTypes = new String[baseFields.length];</span>
<span class="nc" id="L1088">      this.baseDataTypes = new String[baseFields.length];</span>
<span class="nc" id="L1089">      this.baseParsers = new MtasFunctionParserFunction[baseFields.length];</span>
<span class="nc" id="L1090">      this.baseFunctionList = new HashMap[baseFields.length];</span>
<span class="nc" id="L1091">      this.baseFunctionParserFunctions = new MtasFunctionParserFunction[baseFields.length][];</span>
<span class="nc bnc" id="L1092" title="All 2 branches missed.">      for (int i = 0; i &lt; baseFields.length; i++) {</span>
<span class="nc bnc" id="L1093" title="All 2 branches missed.">        if (baseMinimumDoubles[i] != null) {</span>
<span class="nc" id="L1094">          this.baseMinimumLongs[i] = baseMinimumDoubles[i].longValue();</span>
        } else {
<span class="nc" id="L1096">          this.baseMinimumLongs[i] = null;</span>
        }
<span class="nc bnc" id="L1098" title="All 2 branches missed.">        if (baseMaximumDoubles[i] != null) {</span>
<span class="nc" id="L1099">          this.baseMaximumLongs[i] = baseMaximumDoubles[i].longValue();</span>
        } else {
<span class="nc" id="L1101">          this.baseMaximumLongs[i] = null;</span>
        }
<span class="nc" id="L1103">        baseDataTypes[i] = CodecUtil.DATA_TYPE_LONG;</span>
<span class="nc" id="L1104">        baseFunctionList[i] = new HashMap&lt;&gt;();</span>
<span class="nc" id="L1105">        baseFunctionParserFunctions[i] = null;</span>
<span class="nc" id="L1106">        baseParsers[i] = new MtasFunctionParserFunctionDefault(</span>
            this.spanQueries.length);
<span class="nc bnc" id="L1108" title="All 2 branches missed.">        if (this.baseSortDirections[i] == null) {</span>
<span class="nc" id="L1109">          this.baseSortDirections[i] = CodecUtil.SORT_ASC;</span>
<span class="nc bnc" id="L1110" title="All 2 branches missed.">        } else if (!this.baseSortDirections[i].equals(CodecUtil.SORT_ASC)</span>
<span class="nc bnc" id="L1111" title="All 2 branches missed.">            &amp;&amp; !this.baseSortDirections[i].equals(CodecUtil.SORT_DESC)) {</span>
<span class="nc" id="L1112">          throw new IOException(</span>
              &quot;unrecognized sortDirection &quot; + this.baseSortDirections[i]);
        }
<span class="nc bnc" id="L1115" title="All 2 branches missed.">        if (this.baseSortTypes[i] == null) {</span>
<span class="nc" id="L1116">          this.baseSortTypes[i] = CodecUtil.SORT_TERM;</span>
<span class="nc bnc" id="L1117" title="All 2 branches missed.">        } else if (!this.baseSortTypes[i].equals(CodecUtil.SORT_TERM)</span>
<span class="nc bnc" id="L1118" title="All 2 branches missed.">            &amp;&amp; !CodecUtil.isStatsType(this.baseSortTypes[i])) {</span>
<span class="nc" id="L1119">          throw new IOException(</span>
              &quot;unrecognized sortType &quot; + this.baseSortTypes[i]);
        }
<span class="nc" id="L1122">        this.baseCollectorTypes[i] = DataCollector.COLLECTOR_TYPE_LIST;</span>
<span class="nc" id="L1123">        this.baseStatsItems[i] = CodecUtil.createStatsItems(this.baseTypes[i]);</span>
<span class="nc" id="L1124">        this.baseStatsTypes[i] = CodecUtil.createStatsType(baseStatsItems[i],</span>
            this.baseSortTypes[i], new MtasFunctionParserFunctionDefault(1));
      }
      boolean doFunctions;
<span class="nc bnc" id="L1128" title="All 6 branches missed.">      doFunctions = baseFunctionKeys != null &amp;&amp; baseFunctionExpressions != null</span>
          &amp;&amp; baseFunctionTypes != null;
<span class="nc bnc" id="L1130" title="All 4 branches missed.">      doFunctions = doFunctions ? baseFunctionKeys.length == baseFields.length</span>
          : false;
<span class="nc bnc" id="L1132" title="All 4 branches missed.">      doFunctions = doFunctions ? baseFunctionTypes.length == baseFields.length</span>
          : false;
<span class="nc bnc" id="L1134" title="All 2 branches missed.">      if (doFunctions) {</span>
<span class="nc" id="L1135">        this.baseFunctionKeys = new String[baseFields.length][];</span>
<span class="nc" id="L1136">        this.baseFunctionExpressions = new String[baseFields.length][];</span>
<span class="nc" id="L1137">        this.baseFunctionTypes = new String[baseFields.length][];</span>
<span class="nc bnc" id="L1138" title="All 2 branches missed.">        for (int i = 0; i &lt; baseFields.length; i++) {</span>
<span class="nc bnc" id="L1139" title="All 4 branches missed.">          if (baseFunctionKeys[i].length == baseFunctionExpressions[i].length</span>
              &amp;&amp; baseFunctionKeys[i].length == baseFunctionTypes[i].length) {
<span class="nc" id="L1141">            this.baseFunctionKeys[i] = new String[baseFunctionKeys[i].length];</span>
<span class="nc" id="L1142">            this.baseFunctionExpressions[i] = new String[baseFunctionExpressions[i].length];</span>
<span class="nc" id="L1143">            this.baseFunctionTypes[i] = new String[baseFunctionTypes[i].length];</span>
<span class="nc" id="L1144">            baseFunctionParserFunctions[i] = new MtasFunctionParserFunction[baseFunctionExpressions[i].length];</span>
<span class="nc bnc" id="L1145" title="All 2 branches missed.">            for (int j = 0; j &lt; baseFunctionKeys[i].length; j++) {</span>
<span class="nc" id="L1146">              this.baseFunctionKeys[i][j] = baseFunctionKeys[i][j];</span>
<span class="nc" id="L1147">              this.baseFunctionExpressions[i][j] = baseFunctionExpressions[i][j];</span>
<span class="nc" id="L1148">              this.baseFunctionTypes[i][j] = baseFunctionTypes[i][j];</span>
<span class="nc" id="L1149">              baseFunctionParserFunctions[i][j] = new MtasFunctionParser(</span>
                  new BufferedReader(
<span class="nc" id="L1151">                      new StringReader(baseFunctionExpressions[i][j]))).parse();</span>
            }
          } else {
<span class="nc" id="L1154">            this.baseFunctionKeys[i] = new String[0];</span>
<span class="nc" id="L1155">            this.baseFunctionExpressions[i] = new String[0];</span>
<span class="nc" id="L1156">            this.baseFunctionTypes[i] = new String[0];</span>
<span class="nc" id="L1157">            baseFunctionParserFunctions[i] = new MtasFunctionParserFunction[0];</span>
          }
        }
      }
<span class="nc bnc" id="L1161" title="All 2 branches missed.">      if (baseFields.length &gt; 0) {</span>
<span class="nc bnc" id="L1162" title="All 2 branches missed.">        if (baseFields.length == 1) {</span>
<span class="nc" id="L1163">          dataCollector = DataCollector.getCollector(this.baseCollectorTypes[0],</span>
              this.baseDataTypes[0], this.baseStatsTypes[0],
              this.baseStatsItems[0], this.baseSortTypes[0],
<span class="nc" id="L1166">              this.baseSortDirections[0], 0, this.baseNumbers[0], null, null);</span>
        } else {
<span class="nc" id="L1168">          String[] subBaseCollectorTypes = Arrays</span>
<span class="nc" id="L1169">              .copyOfRange(baseCollectorTypes, 1, baseDataTypes.length);</span>
<span class="nc" id="L1170">          String[] subBaseDataTypes = Arrays.copyOfRange(baseDataTypes, 1,</span>
              baseDataTypes.length);
<span class="nc" id="L1172">          String[] subBaseStatsTypes = Arrays.copyOfRange(baseStatsTypes, 1,</span>
              baseStatsTypes.length);
<span class="nc" id="L1174">          SortedSet&lt;String&gt;[] subBaseStatsItems = Arrays</span>
<span class="nc" id="L1175">              .copyOfRange(baseStatsItems, 1, baseStatsItems.length);</span>
<span class="nc" id="L1176">          String[] subBaseSortTypes = Arrays.copyOfRange(baseSortTypes, 1,</span>
              baseSortTypes.length);
<span class="nc" id="L1178">          String[] subBaseSortDirections = Arrays</span>
<span class="nc" id="L1179">              .copyOfRange(baseSortDirections, 1, baseSortDirections.length);</span>
<span class="nc" id="L1180">          Integer[] subNumbers = Arrays.copyOfRange(baseNumbers, 1,</span>
              baseNumbers.length);
<span class="nc" id="L1182">          Integer[] subStarts = ArrayUtils.toObject(new int[subNumbers.length]);</span>
<span class="nc" id="L1183">          dataCollector = DataCollector.getCollector(this.baseCollectorTypes[0],</span>
              this.baseDataTypes[0], this.baseStatsTypes[0],
              this.baseStatsItems[0], this.baseSortTypes[0],
<span class="nc" id="L1186">              this.baseSortDirections[0], 0, this.baseNumbers[0],</span>
              subBaseCollectorTypes, subBaseDataTypes, subBaseStatsTypes,
              subBaseStatsItems, subBaseSortTypes, subBaseSortDirections,
              subStarts, subNumbers, null, null);
<span class="nc" id="L1190">        }</span>
      } else {
<span class="nc" id="L1192">        throw new IOException(&quot;no baseFields&quot;);</span>
      }
<span class="nc" id="L1194">    }</span>

    /**
     * Function sum rule.
     *
     * @return true, if successful
     */
    public boolean functionSumRule() {
<span class="nc bnc" id="L1202" title="All 2 branches missed.">      if (baseFunctionParserFunctions != null) {</span>
<span class="nc bnc" id="L1203" title="All 2 branches missed.">        for (int i = 0; i &lt; baseFields.length; i++) {</span>
<span class="nc bnc" id="L1204" title="All 2 branches missed.">          for (MtasFunctionParserFunction function : baseFunctionParserFunctions[i]) {</span>
<span class="nc bnc" id="L1205" title="All 2 branches missed.">            if (!function.sumRule()) {</span>
<span class="nc" id="L1206">              return false;</span>
            }
          }
        }
      }
<span class="nc" id="L1211">      return true;</span>
    }

    /**
     * Function need positions.
     *
     * @return true, if successful
     */
    public boolean functionNeedPositions() {
<span class="nc bnc" id="L1220" title="All 2 branches missed.">      if (baseFunctionParserFunctions != null) {</span>
<span class="nc bnc" id="L1221" title="All 2 branches missed.">        for (int i = 0; i &lt; baseFields.length; i++) {</span>
<span class="nc bnc" id="L1222" title="All 2 branches missed.">          for (MtasFunctionParserFunction function : baseFunctionParserFunctions[i]) {</span>
<span class="nc bnc" id="L1223" title="All 2 branches missed.">            if (function.needPositions()) {</span>
<span class="nc" id="L1224">              return true;</span>
            }
          }
        }
      }
<span class="nc" id="L1229">      return false;</span>
    }

    /**
     * Base parser sum rule.
     *
     * @return true, if successful
     */
    public boolean baseParserSumRule() {
<span class="nc bnc" id="L1238" title="All 2 branches missed.">      for (int i = 0; i &lt; baseFields.length; i++) {</span>
<span class="nc bnc" id="L1239" title="All 2 branches missed.">        if (!baseParsers[i].sumRule()) {</span>
<span class="nc" id="L1240">          return false;</span>
        }
      }
<span class="nc" id="L1243">      return true;</span>
    }

    /**
     * Base parser need positions.
     *
     * @return true, if successful
     */
    public boolean baseParserNeedPositions() {
<span class="nc bnc" id="L1252" title="All 2 branches missed.">      for (int i = 0; i &lt; baseFields.length; i++) {</span>
<span class="nc bnc" id="L1253" title="All 2 branches missed.">        if (baseParsers[i].needPositions()) {</span>
<span class="nc" id="L1254">          return true;</span>
        }
      }
<span class="nc" id="L1257">      return false;</span>
    }

  }

  /**
   * The Class ComponentTermVector.
   */
  public static class ComponentTermVector implements BasicComponent {

    /** The key. */
    public String key;

    /** The prefix. */
    public String prefix;

    /** The regexp. */
    public String regexp;

    /** The ignore regexp. */
    public String ignoreRegexp;

    /** The boundary. */
    public String boundary;

    /** The full. */
    public boolean full;

    /** The list. */
    public Set&lt;String&gt; list;

    /** The ignore list. */
    public Set&lt;String&gt; ignoreList;

    /** The list regexp. */
    public boolean listRegexp;

    /** The ignore list regexp. */
    public boolean ignoreListRegexp;

    /** The functions. */
    public List&lt;SubComponentFunction&gt; functions;

    /** The number. */
    public int number;

    /** The start value. */
    public BytesRef startValue;

    /** The sub component function. */
    public SubComponentFunction subComponentFunction;

    /** The boundary registration. */
    public boolean boundaryRegistration;

    /** The sort type. */
    public String sortType;

    /** The sort direction. */
    public String sortDirection;

    /**
     * Instantiates a new component term vector.
     *
     * @param key
     *          the key
     * @param prefix
     *          the prefix
     * @param regexp
     *          the regexp
     * @param full
     *          the full
     * @param type
     *          the type
     * @param sortType
     *          the sort type
     * @param sortDirection
     *          the sort direction
     * @param startValue
     *          the start value
     * @param number
     *          the number
     * @param functionKey
     *          the function key
     * @param functionExpression
     *          the function expression
     * @param functionType
     *          the function type
     * @param boundary
     *          the boundary
     * @param list
     *          the list
     * @param listRegexp
     *          the list regexp
     * @param ignoreRegexp
     *          the ignore regexp
     * @param ignoreList
     *          the ignore list
     * @param ignoreListRegexp
     *          the ignore list regexp
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     * @throws ParseException
     *           the parse exception
     */
    @SuppressWarnings({ &quot;unchecked&quot;, &quot;rawtypes&quot; })
    public ComponentTermVector(String key, String prefix, String regexp,
        Boolean full, String type, String sortType, String sortDirection,
        String startValue, int number, String[] functionKey,
        String[] functionExpression, String[] functionType, String boundary,
        String[] list, Boolean listRegexp, String ignoreRegexp,
        String[] ignoreList, Boolean ignoreListRegexp)
<span class="fc" id="L1369">        throws IOException, ParseException {</span>
<span class="fc" id="L1370">      this.key = key;</span>
<span class="fc" id="L1371">      this.prefix = prefix;</span>
<span class="fc" id="L1372">      this.regexp = regexp;</span>
<span class="pc bpc" id="L1373" title="1 of 4 branches missed.">      this.full = (full != null &amp;&amp; full) ? true : false;</span>
<span class="fc bfc" id="L1374" title="All 2 branches covered.">      if (sortType == null) {</span>
<span class="fc" id="L1375">        this.sortType = CodecUtil.SORT_TERM;</span>
      } else {
<span class="fc" id="L1377">        this.sortType = sortType;</span>
      }
<span class="fc bfc" id="L1379" title="All 2 branches covered.">      if (sortDirection == null) {</span>
<span class="pc bpc" id="L1380" title="1 of 2 branches missed.">        if (this.sortType.equals(CodecUtil.SORT_TERM)) {</span>
<span class="fc" id="L1381">          this.sortDirection = CodecUtil.SORT_ASC;</span>
        } else {
<span class="nc" id="L1383">          this.sortDirection = CodecUtil.SORT_DESC;</span>
        }
      } else {
<span class="fc" id="L1386">        this.sortDirection = sortDirection;</span>
      }
<span class="pc bpc" id="L1388" title="1 of 4 branches missed.">      if (list != null &amp;&amp; list.length &gt; 0) {</span>
<span class="fc" id="L1389">        this.list = new HashSet(Arrays.asList(list));</span>
<span class="pc bpc" id="L1390" title="1 of 2 branches missed.">        this.listRegexp = listRegexp != null ? listRegexp : false;</span>
<span class="fc" id="L1391">        this.boundary = null;</span>
<span class="fc" id="L1392">        this.number = Integer.MAX_VALUE;</span>
<span class="pc bpc" id="L1393" title="1 of 2 branches missed.">        if (!this.full) {</span>
<span class="fc" id="L1394">          this.sortType = CodecUtil.SORT_TERM;</span>
<span class="fc" id="L1395">          this.sortDirection = CodecUtil.SORT_ASC;</span>
        }
      } else {
<span class="fc" id="L1398">        this.list = null;</span>
<span class="fc" id="L1399">        this.listRegexp = false;</span>
<span class="pc bpc" id="L1400" title="1 of 2 branches missed.">        this.startValue = (startValue != null)</span>
            ? new BytesRef(prefix + MtasToken.DELIMITER + startValue) : null;
<span class="pc bpc" id="L1402" title="1 of 2 branches missed.">        if (boundary == null) {</span>
<span class="fc" id="L1403">          this.boundary = null;</span>
<span class="pc bpc" id="L1404" title="1 of 2 branches missed.">          if (number &lt; -1) {</span>
<span class="nc" id="L1405">            throw new IOException(&quot;number should not be &quot; + number);</span>
<span class="fc bfc" id="L1406" title="All 2 branches covered.">          } else if (number &gt;= 0) {</span>
<span class="fc" id="L1407">            this.number = number;</span>
          } else {
<span class="pc bpc" id="L1409" title="1 of 2 branches missed.">            if (!full) {</span>
<span class="nc" id="L1410">              throw new IOException(</span>
                  &quot;number &quot; + number + &quot; only supported for full termvector&quot;);
            } else {
<span class="fc" id="L1413">              this.number = Integer.MAX_VALUE;</span>
            }
          }
        } else {
<span class="nc" id="L1417">          this.boundary = boundary;</span>
<span class="nc" id="L1418">          this.number = Integer.MAX_VALUE;</span>
        }
      }
<span class="fc" id="L1421">      this.ignoreRegexp = ignoreRegexp;</span>
<span class="pc bpc" id="L1422" title="1 of 4 branches missed.">      if (ignoreList != null &amp;&amp; ignoreList.length &gt; 0) {</span>
<span class="fc" id="L1423">        this.ignoreList = new HashSet(Arrays.asList(ignoreList));</span>
<span class="pc bpc" id="L1424" title="1 of 2 branches missed.">        this.ignoreListRegexp = ignoreListRegexp != null ? ignoreListRegexp</span>
            : false;
      } else {
<span class="fc" id="L1427">        this.ignoreList = null;</span>
<span class="fc" id="L1428">        this.ignoreListRegexp = false;</span>
      }
<span class="fc" id="L1430">      functions = new ArrayList&lt;&gt;();</span>
<span class="pc bpc" id="L1431" title="2 of 6 branches missed.">      if (functionKey != null &amp;&amp; functionExpression != null</span>
          &amp;&amp; functionType != null) {
<span class="pc bpc" id="L1433" title="2 of 4 branches missed.">        if (functionKey.length == functionExpression.length</span>
            &amp;&amp; functionKey.length == functionType.length) {
<span class="pc bpc" id="L1435" title="1 of 2 branches missed.">          for (int i = 0; i &lt; functionKey.length; i++) {</span>
<span class="nc" id="L1436">            functions</span>
<span class="nc" id="L1437">                .add(new SubComponentFunction(DataCollector.COLLECTOR_TYPE_LIST,</span>
                    functionKey[i], functionExpression[i], functionType[i]));
          }
        }
      }
<span class="fc bfc" id="L1442" title="All 2 branches covered.">      if (!this.sortType.equals(CodecUtil.SORT_TERM)</span>
<span class="pc bpc" id="L1443" title="1 of 2 branches missed.">          &amp;&amp; !CodecUtil.isStatsType(this.sortType)) {</span>
<span class="nc" id="L1444">        throw new IOException(&quot;unknown sortType '&quot; + this.sortType + &quot;'&quot;);</span>
<span class="fc bfc" id="L1445" title="All 4 branches covered.">      } else if (!full &amp;&amp; !this.sortType.equals(CodecUtil.SORT_TERM)) {</span>
<span class="pc bpc" id="L1446" title="1 of 2 branches missed.">        if (!(this.sortType.equals(CodecUtil.STATS_TYPE_SUM)</span>
<span class="nc bnc" id="L1447" title="All 2 branches missed.">            || this.sortType.equals(CodecUtil.STATS_TYPE_N))) {</span>
<span class="nc" id="L1448">          throw new IOException(&quot;sortType '&quot; + this.sortType</span>
              + &quot;' only supported with full termVector&quot;);
        }
      }
<span class="fc bfc" id="L1452" title="All 2 branches covered.">      if (!this.sortType.equals(CodecUtil.SORT_TERM)) {</span>
<span class="pc bpc" id="L1453" title="1 of 2 branches missed.">        if (startValue != null) {</span>
<span class="nc" id="L1454">          throw new IOException(&quot;startValue '&quot; + startValue</span>
              + &quot;' only supported with termVector sorted on &quot;
              + CodecUtil.SORT_TERM);
        }
      }
<span class="fc bfc" id="L1459" title="All 2 branches covered.">      if (!this.sortDirection.equals(CodecUtil.SORT_ASC)</span>
<span class="pc bpc" id="L1460" title="1 of 2 branches missed.">          &amp;&amp; !this.sortDirection.equals(CodecUtil.SORT_DESC)) {</span>
<span class="nc" id="L1461">        throw new IOException(</span>
            &quot;unrecognized sortDirection '&quot; + this.sortDirection + &quot;'&quot;);
      }
<span class="pc bpc" id="L1464" title="1 of 2 branches missed.">      boundaryRegistration = this.boundary != null;</span>
<span class="fc" id="L1465">      String segmentRegistration = null;</span>
<span class="fc bfc" id="L1466" title="All 2 branches covered.">      if (this.full) {</span>
<span class="fc" id="L1467">        this.boundary = null;</span>
<span class="fc" id="L1468">        segmentRegistration = null;</span>
<span class="pc bpc" id="L1469" title="1 of 2 branches missed.">      } else if (this.boundary != null) {</span>
<span class="nc bnc" id="L1470" title="All 2 branches missed.">        if (this.sortDirection.equals(CodecUtil.SORT_ASC)) {</span>
<span class="nc" id="L1471">          segmentRegistration = MtasDataCollector.SEGMENT_BOUNDARY_ASC;</span>
<span class="nc bnc" id="L1472" title="All 2 branches missed.">        } else if (this.sortDirection.equals(CodecUtil.SORT_DESC)) {</span>
<span class="nc" id="L1473">          segmentRegistration = MtasDataCollector.SEGMENT_BOUNDARY_DESC;</span>
        }
<span class="fc bfc" id="L1475" title="All 2 branches covered.">      } else if (!this.sortType.equals(CodecUtil.SORT_TERM)) {</span>
<span class="fc bfc" id="L1476" title="All 2 branches covered.">        if (this.sortDirection.equals(CodecUtil.SORT_ASC)) {</span>
<span class="fc" id="L1477">          segmentRegistration = MtasDataCollector.SEGMENT_SORT_ASC;</span>
<span class="pc bpc" id="L1478" title="1 of 2 branches missed.">        } else if (this.sortDirection.equals(CodecUtil.SORT_DESC)) {</span>
<span class="fc" id="L1479">          segmentRegistration = MtasDataCollector.SEGMENT_SORT_DESC;</span>
        }
      }
      // create main subComponentFunction
<span class="fc" id="L1483">      this.subComponentFunction = new SubComponentFunction(</span>
          DataCollector.COLLECTOR_TYPE_LIST, key, type,
          new MtasFunctionParserFunctionDefault(1), this.sortType,
<span class="fc" id="L1486">          this.sortDirection, 0, this.number, segmentRegistration, boundary);</span>
<span class="fc" id="L1487">    }</span>

    /**
     * Function sum rule.
     *
     * @return true, if successful
     */
    public boolean functionSumRule() {
<span class="nc bnc" id="L1495" title="All 2 branches missed.">      if (functions != null) {</span>
<span class="nc bnc" id="L1496" title="All 2 branches missed.">        for (SubComponentFunction function : functions) {</span>
<span class="nc bnc" id="L1497" title="All 2 branches missed.">          if (!function.parserFunction.sumRule()) {</span>
<span class="nc" id="L1498">            return false;</span>
          }
<span class="nc" id="L1500">        }</span>
      }
<span class="nc" id="L1502">      return true;</span>
    }

    /**
     * Function need positions.
     *
     * @return true, if successful
     */
    public boolean functionNeedPositions() {
<span class="pc bpc" id="L1511" title="1 of 2 branches missed.">      if (functions != null) {</span>
<span class="pc bpc" id="L1512" title="1 of 2 branches missed.">        for (SubComponentFunction function : functions) {</span>
<span class="nc bnc" id="L1513" title="All 2 branches missed.">          if (function.parserFunction.needPositions()) {</span>
<span class="nc" id="L1514">            return true;</span>
          }
<span class="nc" id="L1516">        }</span>
      }
<span class="fc" id="L1518">      return false;</span>
    }

  }

  /**
   * The Interface ComponentStats.
   */
  public abstract static interface ComponentStats extends BasicComponent {
  }

  /**
   * The Class ComponentSpan.
   */
  public static class ComponentSpan implements ComponentStats {

    /** The queries. */
    public MtasSpanQuery[] queries;

    /** The key. */
    public String key;

    /** The data type. */
    public String dataType;

    /** The stats type. */
    public String statsType;

    /** The stats items. */
    public SortedSet&lt;String&gt; statsItems;

    /** The minimum long. */
    public Long minimumLong;

    /** The maximum long. */
    public Long maximumLong;

    /** The data collector. */
    public MtasDataCollector&lt;?, ?&gt; dataCollector;

    /** The functions. */
    public List&lt;SubComponentFunction&gt; functions;

    /** The parser. */
    public MtasFunctionParserFunction parser;

    /**
     * Instantiates a new component span.
     *
     * @param queries
     *          the queries
     * @param key
     *          the key
     * @param minimumDouble
     *          the minimum double
     * @param maximumDouble
     *          the maximum double
     * @param type
     *          the type
     * @param functionKey
     *          the function key
     * @param functionExpression
     *          the function expression
     * @param functionType
     *          the function type
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     * @throws ParseException
     *           the parse exception
     */
    public ComponentSpan(MtasSpanQuery[] queries, String key,
        Double minimumDouble, Double maximumDouble, String type,
        String[] functionKey, String[] functionExpression,
<span class="fc" id="L1591">        String[] functionType) throws IOException, ParseException {</span>
<span class="fc" id="L1592">      this.queries = (MtasSpanQuery[]) queries.clone();</span>
<span class="fc" id="L1593">      this.key = key;</span>
<span class="fc" id="L1594">      functions = new ArrayList&lt;&gt;();</span>
<span class="pc bpc" id="L1595" title="2 of 6 branches missed.">      if (functionKey != null &amp;&amp; functionExpression != null</span>
          &amp;&amp; functionType != null) {
<span class="pc bpc" id="L1597" title="2 of 4 branches missed.">        if (functionKey.length == functionExpression.length</span>
            &amp;&amp; functionKey.length == functionType.length) {
<span class="fc bfc" id="L1599" title="All 2 branches covered.">          for (int i = 0; i &lt; functionKey.length; i++) {</span>
<span class="fc" id="L1600">            functions</span>
<span class="fc" id="L1601">                .add(new SubComponentFunction(DataCollector.COLLECTOR_TYPE_DATA,</span>
                    functionKey[i], functionExpression[i], functionType[i]));
          }
        }
      }
<span class="fc" id="L1606">      parser = new MtasFunctionParserFunctionDefault(queries.length);</span>
<span class="fc" id="L1607">      dataType = parser.getType();</span>
<span class="fc" id="L1608">      statsItems = CodecUtil.createStatsItems(type);</span>
<span class="fc" id="L1609">      statsType = CodecUtil.createStatsType(this.statsItems, null, parser);</span>
<span class="fc bfc" id="L1610" title="All 2 branches covered.">      if (minimumDouble != null) {</span>
<span class="fc" id="L1611">        this.minimumLong = minimumDouble.longValue();</span>
      } else {
<span class="fc" id="L1613">        this.minimumLong = null;</span>
      }
<span class="fc bfc" id="L1615" title="All 2 branches covered.">      if (maximumDouble != null) {</span>
<span class="fc" id="L1616">        this.maximumLong = maximumDouble.longValue();</span>
      } else {
<span class="fc" id="L1618">        this.maximumLong = null;</span>
      }
<span class="fc" id="L1620">      dataCollector = DataCollector.getCollector(</span>
          DataCollector.COLLECTOR_TYPE_DATA, dataType, this.statsType,
          this.statsItems, null, null, null, null, null, null);
<span class="fc" id="L1623">    }</span>

    /**
     * Function sum rule.
     *
     * @return true, if successful
     */
    public boolean functionSumRule() {
<span class="pc bpc" id="L1631" title="1 of 2 branches missed.">      if (functions != null) {</span>
<span class="fc bfc" id="L1632" title="All 2 branches covered.">        for (SubComponentFunction function : functions) {</span>
<span class="pc bpc" id="L1633" title="1 of 2 branches missed.">          if (!function.parserFunction.sumRule()) {</span>
<span class="nc" id="L1634">            return false;</span>
          }
<span class="fc" id="L1636">        }</span>
      }
<span class="fc" id="L1638">      return true;</span>
    }

    /**
     * Function basic.
     *
     * @return true, if successful
     */
    public boolean functionBasic() {
<span class="pc bpc" id="L1647" title="1 of 2 branches missed.">      if (functions != null) {</span>
<span class="fc bfc" id="L1648" title="All 2 branches covered.">        for (SubComponentFunction function : functions) {</span>
<span class="pc bpc" id="L1649" title="1 of 2 branches missed.">          if (!function.statsType.equals(CodecUtil.STATS_BASIC)) {</span>
<span class="nc" id="L1650">            return false;</span>
          }
<span class="fc" id="L1652">        }</span>
      }
<span class="fc" id="L1654">      return true;</span>
    }

    /**
     * Function need positions.
     *
     * @return true, if successful
     */
    public boolean functionNeedPositions() {
<span class="pc bpc" id="L1663" title="1 of 2 branches missed.">      if (functions != null) {</span>
<span class="fc bfc" id="L1664" title="All 2 branches covered.">        for (SubComponentFunction function : functions) {</span>
<span class="pc bpc" id="L1665" title="1 of 2 branches missed.">          if (function.parserFunction.needPositions()) {</span>
<span class="nc" id="L1666">            return true;</span>
          }
<span class="fc" id="L1668">        }</span>
      }
<span class="fc" id="L1670">      return false;</span>
    }

    /**
     * Function need arguments.
     *
     * @return the sets the
     */
    public Set&lt;Integer&gt; functionNeedArguments() {
<span class="fc" id="L1679">      Set&lt;Integer&gt; list = new HashSet&lt;&gt;();</span>
<span class="pc bpc" id="L1680" title="1 of 2 branches missed.">      if (functions != null) {</span>
<span class="fc bfc" id="L1681" title="All 2 branches covered.">        for (SubComponentFunction function : functions) {</span>
<span class="fc" id="L1682">          list.addAll(function.parserFunction.needArgument());</span>
<span class="fc" id="L1683">        }</span>
      }
<span class="fc" id="L1685">      return list;</span>
    }

  }

  /**
   * The Class ComponentPosition.
   */
  public static class ComponentPosition implements ComponentStats {

    /** The key. */
    public String key;

    /** The data type. */
    public String dataType;

    /** The stats type. */
    public String statsType;

    /** The stats items. */
    public SortedSet&lt;String&gt; statsItems;

    /** The minimum long. */
    public Long minimumLong;

    /** The maximum long. */
    public Long maximumLong;

    /** The data collector. */
    public MtasDataCollector&lt;?, ?&gt; dataCollector;

    /**
     * Instantiates a new component position.
     *
     * @param key
     *          the key
     * @param minimumDouble
     *          the minimum double
     * @param maximumDouble
     *          the maximum double
     * @param statsType
     *          the stats type
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     * @throws ParseException
     *           the parse exception
     */
    public ComponentPosition(String key, Double minimumDouble,
        Double maximumDouble, String statsType)
<span class="fc" id="L1734">        throws IOException, ParseException {</span>
<span class="fc" id="L1735">      this.key = key;</span>
<span class="fc" id="L1736">      dataType = CodecUtil.DATA_TYPE_LONG;</span>
<span class="fc" id="L1737">      this.statsItems = CodecUtil.createStatsItems(statsType);</span>
<span class="fc" id="L1738">      this.statsType = CodecUtil.createStatsType(this.statsItems, null, null);</span>
<span class="fc bfc" id="L1739" title="All 2 branches covered.">      if (minimumDouble != null) {</span>
<span class="fc" id="L1740">        this.minimumLong = minimumDouble.longValue();</span>
      } else {
<span class="fc" id="L1742">        this.minimumLong = null;</span>
      }
<span class="fc bfc" id="L1744" title="All 2 branches covered.">      if (maximumDouble != null) {</span>
<span class="fc" id="L1745">        this.maximumLong = maximumDouble.longValue();</span>
      } else {
<span class="fc" id="L1747">        this.maximumLong = null;</span>
      }
<span class="fc" id="L1749">      dataCollector = DataCollector.getCollector(</span>
          DataCollector.COLLECTOR_TYPE_DATA, dataType, this.statsType,
          this.statsItems, null, null, null, null, null, null);
<span class="fc" id="L1752">    }</span>
  }

  /**
   * The Class ComponentToken.
   */
  public static class ComponentToken implements ComponentStats {

    /** The key. */
    public String key;

    /** The data type. */
    public String dataType;

    /** The stats type. */
    public String statsType;

    /** The stats items. */
    public SortedSet&lt;String&gt; statsItems;

    /** The minimum long. */
    public Long minimumLong;

    /** The maximum long. */
    public Long maximumLong;

    /** The data collector. */
    public MtasDataCollector&lt;?, ?&gt; dataCollector;

    /**
     * Instantiates a new component token.
     *
     * @param key
     *          the key
     * @param minimumDouble
     *          the minimum double
     * @param maximumDouble
     *          the maximum double
     * @param statsType
     *          the stats type
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     * @throws ParseException
     *           the parse exception
     */
    public ComponentToken(String key, Double minimumDouble,
        Double maximumDouble, String statsType)
<span class="fc" id="L1799">        throws IOException, ParseException {</span>
<span class="fc" id="L1800">      this.key = key;</span>
<span class="fc" id="L1801">      dataType = CodecUtil.DATA_TYPE_LONG;</span>
<span class="fc" id="L1802">      this.statsItems = CodecUtil.createStatsItems(statsType);</span>
<span class="fc" id="L1803">      this.statsType = CodecUtil.createStatsType(this.statsItems, null, null);</span>
<span class="fc bfc" id="L1804" title="All 2 branches covered.">      if (minimumDouble != null) {</span>
<span class="fc" id="L1805">        this.minimumLong = minimumDouble.longValue();</span>
      } else {
<span class="fc" id="L1807">        this.minimumLong = null;</span>
      }
<span class="fc bfc" id="L1809" title="All 2 branches covered.">      if (maximumDouble != null) {</span>
<span class="fc" id="L1810">        this.maximumLong = maximumDouble.longValue();</span>
      } else {
<span class="fc" id="L1812">        this.maximumLong = null;</span>
      }
<span class="fc" id="L1814">      dataCollector = DataCollector.getCollector(</span>
          DataCollector.COLLECTOR_TYPE_DATA, dataType, this.statsType,
          this.statsItems, null, null, null, null, null, null);
<span class="fc" id="L1817">    }</span>
  }

  /**
   * The Class ComponentJoin.
   */
  public static class ComponentJoin implements BasicComponent {

    /** The fields. */
    private Set&lt;String&gt; fields;

    /** The values. */
    private Set&lt;String&gt; values;

    /** The key. */
    private String key;

    /**
     * Instantiates a new component join.
     *
     * @param fields
     *          the fields
     * @param key
     *          the key
     */
<span class="nc" id="L1842">    public ComponentJoin(Set&lt;String&gt; fields, String key) {</span>
<span class="nc" id="L1843">      this.fields = fields;</span>
<span class="nc" id="L1844">      this.key = key;</span>
<span class="nc" id="L1845">      this.values = new HashSet&lt;&gt;();</span>
<span class="nc" id="L1846">    }</span>

    /**
     * Adds the.
     *
     * @param value
     *          the value
     */
    public void add(String value) {
<span class="nc" id="L1855">      values.add(value);</span>
<span class="nc" id="L1856">    }</span>

    /**
     * Adds the.
     *
     * @param values
     *          the values
     */
    public void add(Set&lt;String&gt; values) {
<span class="nc" id="L1865">      this.values.addAll(values);</span>
<span class="nc" id="L1866">    }</span>

    /**
     * Values.
     *
     * @return the sets the
     */
    public Set&lt;String&gt; values() {
<span class="nc" id="L1874">      return values;</span>
    }

    /**
     * Key.
     *
     * @return the string
     */
    public String key() {
<span class="nc" id="L1883">      return key;</span>
    }

    /**
     * Fields.
     *
     * @return the sets the
     */
    public Set&lt;String&gt; fields() {
<span class="nc" id="L1892">      return fields;</span>
    }

  }

  /**
   * The Class SubComponentFunction.
   */
  public static class SubComponentFunction {

    /** The key. */
    public String key;

    /** The expression. */
    public String expression;

    /** The type. */
    public String type;

    /** The parser function. */
    public MtasFunctionParserFunction parserFunction;

    /** The stats type. */
    public String statsType;

    /** The data type. */
    public String dataType;

    /** The sort type. */
    public String sortType;

    /** The sort direction. */
    public String sortDirection;

    /** The stats items. */
    public SortedSet&lt;String&gt; statsItems;

    /** The data collector. */
    public MtasDataCollector&lt;?, ?&gt; dataCollector;

    /**
     * Instantiates a new sub component function.
     *
     * @param collectorType
     *          the collector type
     * @param key
     *          the key
     * @param type
     *          the type
     * @param parserFunction
     *          the parser function
     * @param sortType
     *          the sort type
     * @param sortDirection
     *          the sort direction
     * @param start
     *          the start
     * @param number
     *          the number
     * @param segmentRegistration
     *          the segment registration
     * @param boundary
     *          the boundary
     * @throws ParseException
     *           the parse exception
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public SubComponentFunction(String collectorType, String key, String type,
        MtasFunctionParserFunction parserFunction, String sortType,
        String sortDirection, Integer start, Integer number,
        String segmentRegistration, String boundary)
<span class="fc" id="L1964">        throws ParseException, IOException {</span>
<span class="fc" id="L1965">      this.key = key;</span>
<span class="fc" id="L1966">      this.expression = null;</span>
<span class="fc" id="L1967">      this.type = type;</span>
<span class="fc" id="L1968">      this.parserFunction = parserFunction;</span>
<span class="fc" id="L1969">      this.sortType = sortType;</span>
<span class="fc" id="L1970">      this.sortDirection = sortDirection;</span>
<span class="fc" id="L1971">      this.dataType = parserFunction.getType();</span>
<span class="fc" id="L1972">      this.statsItems = CodecUtil.createStatsItems(this.type);</span>
<span class="fc" id="L1973">      this.statsType = CodecUtil.createStatsType(statsItems, sortType,</span>
          parserFunction);
<span class="pc bpc" id="L1975" title="1 of 2 branches missed.">      if (collectorType.equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
<span class="fc" id="L1976">        dataCollector = DataCollector.getCollector(</span>
            DataCollector.COLLECTOR_TYPE_LIST, dataType, statsType, statsItems,
            sortType, sortDirection, start, number, null, null, null, null,
            null, null, null, null, segmentRegistration, boundary);
<span class="nc bnc" id="L1980" title="All 2 branches missed.">      } else if (collectorType.equals(DataCollector.COLLECTOR_TYPE_DATA)) {</span>
<span class="nc" id="L1981">        dataCollector = DataCollector.getCollector(</span>
            DataCollector.COLLECTOR_TYPE_DATA, dataType, statsType, statsItems,
            sortType, sortDirection, start, number, segmentRegistration,
            boundary);
      }
<span class="fc" id="L1986">    }</span>

    /**
     * Instantiates a new sub component function.
     *
     * @param collectorType
     *          the collector type
     * @param key
     *          the key
     * @param expression
     *          the expression
     * @param type
     *          the type
     * @throws ParseException
     *           the parse exception
     * @throws IOException
     *           Signals that an I/O exception has occurred.
     */
    public SubComponentFunction(String collectorType, String key,
<span class="fc" id="L2005">        String expression, String type) throws ParseException, IOException {</span>
<span class="fc" id="L2006">      this.key = key;</span>
<span class="fc" id="L2007">      this.expression = expression;</span>
<span class="fc" id="L2008">      this.type = type;</span>
<span class="fc" id="L2009">      this.sortType = null;</span>
<span class="fc" id="L2010">      this.sortDirection = null;</span>
<span class="fc" id="L2011">      parserFunction = new MtasFunctionParser(</span>
<span class="fc" id="L2012">          new BufferedReader(new StringReader(this.expression))).parse();</span>
<span class="fc" id="L2013">      dataType = parserFunction.getType();</span>
<span class="fc" id="L2014">      statsItems = CodecUtil.createStatsItems(this.type);</span>
<span class="fc" id="L2015">      statsType = CodecUtil.createStatsType(statsItems, null, parserFunction);</span>
<span class="pc bpc" id="L2016" title="1 of 2 branches missed.">      if (collectorType.equals(DataCollector.COLLECTOR_TYPE_LIST)) {</span>
<span class="nc" id="L2017">        dataCollector = DataCollector.getCollector(</span>
            DataCollector.COLLECTOR_TYPE_LIST, dataType, statsType, statsItems,
<span class="nc" id="L2019">            sortType, sortDirection, 0, Integer.MAX_VALUE, null, null);</span>
<span class="pc bpc" id="L2020" title="1 of 2 branches missed.">      } else if (collectorType.equals(DataCollector.COLLECTOR_TYPE_DATA)) {</span>
<span class="fc" id="L2021">        dataCollector = DataCollector.getCollector(</span>
            DataCollector.COLLECTOR_TYPE_DATA, dataType, statsType, statsItems,
            sortType, sortDirection, null, null, null, null);
      }
<span class="fc" id="L2025">    }</span>
  }

  /**
   * The Class KwicToken.
   */
  public static class KwicToken {

    /** The start position. */
    public int startPosition;

    /** The end position. */
    public int endPosition;

    /** The tokens. */
    public List&lt;MtasTokenString&gt; tokens;

    /**
     * Instantiates a new kwic token.
     *
     * @param match
     *          the match
     * @param tokens
     *          the tokens
     */
<span class="nc" id="L2050">    public KwicToken(Match match, List&lt;MtasTokenString&gt; tokens) {</span>
<span class="nc" id="L2051">      startPosition = match.startPosition;</span>
<span class="nc" id="L2052">      endPosition = match.endPosition - 1;</span>
<span class="nc" id="L2053">      this.tokens = tokens;</span>
<span class="nc" id="L2054">    }</span>

  }

  /**
   * The Class KwicHit.
   */
  public static class KwicHit {

    /** The start position. */
    public int startPosition;

    /** The end position. */
    public int endPosition;

    /** The hits. */
    public Map&lt;Integer, List&lt;String&gt;&gt; hits;

    /**
     * Instantiates a new kwic hit.
     *
     * @param match
     *          the match
     * @param hits
     *          the hits
     */
<span class="nc" id="L2080">    public KwicHit(Match match, Map&lt;Integer, List&lt;String&gt;&gt; hits) {</span>
<span class="nc" id="L2081">      startPosition = match.startPosition;</span>
<span class="nc" id="L2082">      endPosition = match.endPosition - 1;</span>
<span class="nc" id="L2083">      this.hits = hits;</span>
<span class="nc" id="L2084">    }</span>
  }

  /**
   * The Class GroupHit.
   */
  public static class GroupHit {

    /** The hash. */
    private int hash;

    /** The hash left. */
    private int hashLeft;

    /** The hash hit. */
    private int hashHit;

    /** The hash right. */
    private int hashRight;

    /** The key. */
    private String key;

    /** The key left. */
    private String keyLeft;

    /** The key hit. */
    private String keyHit;

    /** The key right. */
    private String keyRight;

    /** The data hit. */
    public List&lt;String&gt;[] dataHit;

    /** The data left. */
    public List&lt;String&gt;[] dataLeft;

    /** The data right. */
    public List&lt;String&gt;[] dataRight;

    /** The missing hit. */
    public Set&lt;String&gt;[] missingHit;

    /** The missing left. */
    public Set&lt;String&gt;[] missingLeft;

    /** The missing right. */
    public Set&lt;String&gt;[] missingRight;

    /** The unknown hit. */
    public Set&lt;String&gt;[] unknownHit;

    /** The unknown left. */
    public Set&lt;String&gt;[] unknownLeft;

    /** The unknown right. */
    public Set&lt;String&gt;[] unknownRight;

    /** The Constant KEY_START. */
    public static final String KEY_START = MtasToken.DELIMITER + &quot;grouphit&quot;
        + MtasToken.DELIMITER;

    /**
     * Sort.
     *
     * @param data
     *          the data
     * @return the list
     */
    private List&lt;MtasTreeHit&lt;String&gt;&gt; sort(List&lt;MtasTreeHit&lt;String&gt;&gt; data) {
<span class="fc" id="L2155">      Collections.sort(data, new Comparator&lt;MtasTreeHit&lt;String&gt;&gt;() {</span>
        @Override
        public int compare(MtasTreeHit&lt;String&gt; hit1, MtasTreeHit&lt;String&gt; hit2) {
<span class="nc" id="L2158">          int compare = Integer.compare(hit1.additionalId, hit2.additionalId);</span>
<span class="nc bnc" id="L2159" title="All 2 branches missed.">          compare = (compare == 0)</span>
<span class="nc" id="L2160">              ? Long.compare(hit1.additionalRef, hit2.additionalRef) : compare;</span>
<span class="nc" id="L2161">          return compare;</span>
        }
      });
<span class="fc" id="L2164">      return data;</span>
    }

    /**
     * Instantiates a new group hit.
     *
     * @param list
     *          the list
     * @param start
     *          the start
     * @param end
     *          the end
     * @param hitStart
     *          the hit start
     * @param hitEnd
     *          the hit end
     * @param group
     *          the group
     * @param knownPrefixes
     *          the known prefixes
     * @throws UnsupportedEncodingException
     *           the unsupported encoding exception
     */
    @SuppressWarnings(&quot;unchecked&quot;)
    public GroupHit(List&lt;MtasTreeHit&lt;String&gt;&gt; list, int start, int end,
        int hitStart, int hitEnd, ComponentGroup group,
<span class="fc" id="L2190">        Set&lt;String&gt; knownPrefixes) throws UnsupportedEncodingException {</span>
      // System.out.println(&quot;init: &quot;+start+&quot;-&quot;+end+&quot;\t&quot;+hitStart+&quot;-&quot;+hitEnd);
      // compute dimensions
<span class="fc" id="L2193">      int leftRangeStart = start;</span>
<span class="fc" id="L2194">      int leftRangeEnd = Math.min(end - 1, hitStart - 1);</span>
<span class="fc" id="L2195">      int leftRangeLength = Math.max(0, 1 + leftRangeEnd - leftRangeStart);</span>
<span class="fc" id="L2196">      int hitLength = 1 + hitEnd - hitStart;</span>
<span class="fc" id="L2197">      int rightRangeStart = Math.max(start, hitEnd + 1);</span>
<span class="fc" id="L2198">      int rightRangeEnd = end;</span>
<span class="fc" id="L2199">      int rightRangeLength = Math.max(0, 1 + rightRangeEnd - rightRangeStart);</span>
      // System.out.println(leftRangeStart+&quot;\t&quot;+leftRangeEnd+&quot;\t&quot;+leftRangeLength+&quot;
      // - &quot;+rightRangeStart+&quot;\t&quot;+rightRangeEnd+&quot;\t&quot;+rightRangeLength);
      // create initial arrays
<span class="pc bpc" id="L2203" title="1 of 2 branches missed.">      if (leftRangeLength &gt; 0) {</span>
<span class="nc" id="L2204">        keyLeft = &quot;&quot;;</span>
<span class="nc" id="L2205">        dataLeft = (ArrayList&lt;String&gt;[]) new ArrayList[leftRangeLength];</span>
<span class="nc" id="L2206">        missingLeft = (HashSet&lt;String&gt;[]) new HashSet[leftRangeLength];</span>
<span class="nc" id="L2207">        unknownLeft = (HashSet&lt;String&gt;[]) new HashSet[leftRangeLength];</span>
<span class="nc bnc" id="L2208" title="All 2 branches missed.">        for (int p = 0; p &lt; leftRangeLength; p++) {</span>
<span class="nc" id="L2209">          dataLeft[p] = new ArrayList&lt;&gt;();</span>
<span class="nc" id="L2210">          missingLeft[p] = new HashSet&lt;&gt;();</span>
<span class="nc" id="L2211">          unknownLeft[p] = new HashSet&lt;&gt;();</span>
        }
      } else {
<span class="fc" id="L2214">        keyLeft = null;</span>
<span class="fc" id="L2215">        dataLeft = null;</span>
<span class="fc" id="L2216">        missingLeft = null;</span>
<span class="fc" id="L2217">        unknownLeft = null;</span>
      }
<span class="pc bpc" id="L2219" title="1 of 2 branches missed.">      if (hitLength &gt; 0) {</span>
<span class="fc" id="L2220">        keyHit = &quot;&quot;;</span>
<span class="fc" id="L2221">        dataHit = (ArrayList&lt;String&gt;[]) new ArrayList[hitLength];</span>
<span class="fc" id="L2222">        missingHit = (HashSet&lt;String&gt;[]) new HashSet[hitLength];</span>
<span class="fc" id="L2223">        unknownHit = (HashSet&lt;String&gt;[]) new HashSet[hitLength];</span>
<span class="fc bfc" id="L2224" title="All 2 branches covered.">        for (int p = 0; p &lt; hitLength; p++) {</span>
<span class="fc" id="L2225">          dataHit[p] = new ArrayList&lt;&gt;();</span>
<span class="fc" id="L2226">          missingHit[p] = new HashSet&lt;&gt;();</span>
<span class="fc" id="L2227">          unknownHit[p] = new HashSet&lt;&gt;();</span>
        }
      } else {
<span class="nc" id="L2230">        keyHit = null;</span>
<span class="nc" id="L2231">        dataHit = null;</span>
<span class="nc" id="L2232">        missingHit = null;</span>
<span class="nc" id="L2233">        unknownHit = null;</span>
      }
<span class="pc bpc" id="L2235" title="1 of 2 branches missed.">      if (rightRangeLength &gt; 0) {</span>
<span class="nc" id="L2236">        keyRight = &quot;&quot;;</span>
<span class="nc" id="L2237">        dataRight = (ArrayList&lt;String&gt;[]) new ArrayList[rightRangeLength];</span>
<span class="nc" id="L2238">        missingRight = (HashSet&lt;String&gt;[]) new HashSet[rightRangeLength];</span>
<span class="nc" id="L2239">        unknownRight = (HashSet&lt;String&gt;[]) new HashSet[rightRangeLength];</span>
<span class="nc bnc" id="L2240" title="All 2 branches missed.">        for (int p = 0; p &lt; rightRangeLength; p++) {</span>
<span class="nc" id="L2241">          dataRight[p] = new ArrayList&lt;&gt;();</span>
<span class="nc" id="L2242">          missingRight[p] = new HashSet&lt;&gt;();</span>
<span class="nc" id="L2243">          unknownRight[p] = new HashSet&lt;&gt;();</span>
        }
      } else {
<span class="fc" id="L2246">        keyRight = null;</span>
<span class="fc" id="L2247">        dataRight = null;</span>
<span class="fc" id="L2248">        missingRight = null;</span>
<span class="fc" id="L2249">        unknownRight = null;</span>
      }

      // construct missing sets
<span class="pc bpc" id="L2253" title="1 of 2 branches missed.">      if (group.hitInside != null) {</span>
<span class="fc bfc" id="L2254" title="All 2 branches covered.">        for (int p = hitStart; p &lt;= hitEnd; p++) {</span>
<span class="fc" id="L2255">          missingHit[p - hitStart].addAll(group.hitInside);</span>
        }
      }
<span class="pc bpc" id="L2258" title="1 of 2 branches missed.">      if (group.hitInsideLeft != null) {</span>
<span class="nc bnc" id="L2259" title="All 2 branches missed.">        for (int p = hitStart; p &lt;= Math.min(hitEnd,</span>
<span class="nc" id="L2260">            hitStart + group.hitInsideLeft.length - 1); p++) {</span>
<span class="nc bnc" id="L2261" title="All 2 branches missed.">          if (group.hitInsideLeft[p - hitStart] != null) {</span>
<span class="nc" id="L2262">            missingHit[p - hitStart].addAll(group.hitInsideLeft[p - hitStart]);</span>
          }
        }
      }
<span class="pc bpc" id="L2266" title="1 of 2 branches missed.">      if (group.hitLeft != null) {</span>
<span class="nc bnc" id="L2267" title="All 2 branches missed.">        for (int p = hitStart; p &lt;= Math.min(hitEnd,</span>
<span class="nc" id="L2268">            hitStart + group.hitLeft.length - 1); p++) {</span>
<span class="nc bnc" id="L2269" title="All 2 branches missed.">          if (group.hitLeft[p - hitStart] != null) {</span>
<span class="nc" id="L2270">            missingHit[p - hitStart].addAll(group.hitLeft[p - hitStart]);</span>
          }
        }
      }
<span class="pc bpc" id="L2274" title="1 of 2 branches missed.">      if (group.hitInsideRight != null) {</span>
        // System.out.println(missingHit.length + &quot; items in missingHit&quot;);
        // System.out.println(
        // group.hitInsideRight.length + &quot; items in group.hitInsideRight&quot;);
<span class="nc bnc" id="L2278" title="All 2 branches missed.">        for (int p = 0; p &lt; group.hitInsideRight.length; p++) {</span>
          // System.out.println(&quot; - &quot; + group.hitInsideRight[p]);
        }
<span class="nc" id="L2281">        for (int p = Math.max(hitStart,</span>
<span class="nc bnc" id="L2282" title="All 2 branches missed.">            hitEnd - group.hitInsideRight.length + 1); p &lt;= hitEnd; p++) {</span>
          // System.out.println(&quot;Test voor p is &quot; + (p - hitStart));
<span class="nc bnc" id="L2284" title="All 2 branches missed.">          if (group.hitInsideRight[hitEnd - p] != null) {</span>
<span class="nc" id="L2285">            missingHit[p - hitStart].addAll(group.hitInsideRight[hitEnd - p]);</span>
          }
        }
      }
<span class="pc bpc" id="L2289" title="1 of 2 branches missed.">      if (group.hitRight != null) {</span>
<span class="nc bnc" id="L2290" title="All 2 branches missed.">        for (int p = hitStart; p &lt;= Math.min(hitEnd,</span>
<span class="nc" id="L2291">            hitStart + group.hitRight.length - 1); p++) {</span>
<span class="nc bnc" id="L2292" title="All 2 branches missed.">          if (group.hitRight[p - hitStart] != null) {</span>
<span class="nc" id="L2293">            missingHit[p - hitStart].addAll(group.hitRight[p - hitStart]);</span>
          }
        }
      }
<span class="pc bpc" id="L2297" title="1 of 2 branches missed.">      if (group.left != null) {</span>
<span class="nc bnc" id="L2298" title="All 2 branches missed.">        for (int p = 0; p &lt; Math.min(leftRangeLength, group.left.length); p++) {</span>
<span class="nc bnc" id="L2299" title="All 2 branches missed.">          if (group.left[p] != null) {</span>
<span class="nc" id="L2300">            missingLeft[p].addAll(group.left[p]);</span>
          }
        }
      }
<span class="pc bpc" id="L2304" title="1 of 2 branches missed.">      if (group.hitRight != null) {</span>
<span class="nc bnc" id="L2305" title="All 2 branches missed.">        for (int p = 0; p &lt;= Math.min(leftRangeLength,</span>
<span class="nc" id="L2306">            group.hitRight.length - dataHit.length); p++) {</span>
<span class="nc bnc" id="L2307" title="All 2 branches missed.">          if (group.hitRight[p + dataHit.length] != null) {</span>
<span class="nc" id="L2308">            missingLeft[p].addAll(group.hitRight[p + dataHit.length]);</span>
          }
        }
      }
<span class="pc bpc" id="L2312" title="1 of 2 branches missed.">      if (group.right != null) {</span>
<span class="nc bnc" id="L2313" title="All 2 branches missed.">        for (int p = 0; p &lt; Math.min(rightRangeLength,</span>
<span class="nc" id="L2314">            group.right.length); p++) {</span>
<span class="nc" id="L2315">          missingRight[p].addAll(group.right[p]);</span>
        }
      }
<span class="pc bpc" id="L2318" title="1 of 2 branches missed.">      if (group.hitRight != null) {</span>
<span class="nc bnc" id="L2319" title="All 2 branches missed.">        for (int p = 0; p &lt;= Math.min(rightRangeLength,</span>
<span class="nc" id="L2320">            group.hitLeft.length - dataHit.length); p++) {</span>
<span class="nc" id="L2321">          missingRight[p].addAll(group.hitLeft[p + dataHit.length]);</span>
        }
      }

      // fill arrays and update missing administration
<span class="fc" id="L2326">      List&lt;MtasTreeHit&lt;String&gt;&gt; sortedList = sort(list);</span>
<span class="fc bfc" id="L2327" title="All 2 branches covered.">      for (MtasTreeHit&lt;String&gt; hit : sortedList) {</span>
        // inside hit
<span class="pc bpc" id="L2329" title="2 of 4 branches missed.">        if (group.hitInside != null &amp;&amp; hit.idData != null</span>
<span class="pc bpc" id="L2330" title="1 of 2 branches missed.">            &amp;&amp; group.hitInside.contains(hit.idData)) {</span>
<span class="fc" id="L2331">          for (int p = Math.max(hitStart, hit.startPosition); p &lt;= Math</span>
<span class="fc bfc" id="L2332" title="All 2 branches covered.">              .min(hitEnd, hit.endPosition); p++) {</span>
            // keyHit += hit.refData;
<span class="fc" id="L2334">            dataHit[p - hitStart].add(hit.refData);</span>
<span class="fc" id="L2335">            missingHit[p - hitStart]</span>
<span class="fc" id="L2336">                .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
            // System.out.print(p + &quot;.&quot; + hit.idData + &quot;:&quot; + hit.refData +
            // &quot;\t&quot;);
          }
<span class="nc bnc" id="L2340" title="All 10 branches missed.">        } else if ((group.hitInsideLeft != null || group.hitLeft != null</span>
            || group.hitInsideRight != null || group.hitRight != null)
            &amp;&amp; hit.idData != null) {
<span class="nc" id="L2343">          for (int p = Math.max(hitStart, hit.startPosition); p &lt;= Math</span>
<span class="nc bnc" id="L2344" title="All 2 branches missed.">              .min(hitEnd, hit.endPosition); p++) {</span>
<span class="nc" id="L2345">            int pHitLeft = p - hitStart;</span>
<span class="nc" id="L2346">            int pHitRight = hitEnd - p;</span>
<span class="nc bnc" id="L2347" title="All 6 branches missed.">            if (group.hitInsideLeft != null</span>
                &amp;&amp; pHitLeft &lt;= (group.hitInsideLeft.length - 1)
                &amp;&amp; group.hitInsideLeft[pHitLeft] != null
<span class="nc bnc" id="L2350" title="All 2 branches missed.">                &amp;&amp; group.hitInsideLeft[pHitLeft].contains(hit.idData)) {</span>
              // keyHit += hit.refData;
<span class="nc" id="L2352">              dataHit[p - hitStart].add(hit.refData);</span>
<span class="nc" id="L2353">              missingHit[p - hitStart]</span>
<span class="nc" id="L2354">                  .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
              // System.out.print(p+&quot;.&quot;+hit.idData + &quot;:&quot; + hit.additionalRef +
              // &quot;\t&quot;);
<span class="nc bnc" id="L2357" title="All 6 branches missed.">            } else if (group.hitLeft != null</span>
                &amp;&amp; pHitLeft &lt;= (group.hitLeft.length - 1)
                &amp;&amp; group.hitLeft[pHitLeft] != null
<span class="nc bnc" id="L2360" title="All 2 branches missed.">                &amp;&amp; group.hitLeft[pHitLeft].contains(hit.idData)) {</span>
              // keyHit += hit.refData;
<span class="nc" id="L2362">              dataHit[p - hitStart].add(hit.refData);</span>
<span class="nc" id="L2363">              missingHit[p - hitStart]</span>
<span class="nc" id="L2364">                  .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
              // System.out.print(p+&quot;.&quot;+hit.idData + &quot;:&quot; + hit.additionalRef +
              // &quot;\t&quot;);
<span class="nc bnc" id="L2367" title="All 6 branches missed.">            } else if (group.hitInsideRight != null</span>
                &amp;&amp; pHitRight &lt;= (group.hitInsideRight.length - 1)
                &amp;&amp; group.hitInsideRight[pHitRight] != null
<span class="nc bnc" id="L2370" title="All 2 branches missed.">                &amp;&amp; group.hitInsideRight[pHitRight].contains(hit.idData)) {</span>
              // keyHit += hit.refData;
<span class="nc" id="L2372">              dataHit[p - hitStart].add(hit.refData);</span>
<span class="nc" id="L2373">              missingHit[p - hitStart]</span>
<span class="nc" id="L2374">                  .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
              // System.out.print(p+&quot;.&quot;+hit.idData + &quot;:&quot; + hit.additionalRef +
              // &quot;\t&quot;);
<span class="nc bnc" id="L2377" title="All 6 branches missed.">            } else if (group.hitRight != null</span>
                &amp;&amp; pHitRight &lt;= (group.hitRight.length - 1)
                &amp;&amp; group.hitRight[pHitRight] != null
<span class="nc bnc" id="L2380" title="All 2 branches missed.">                &amp;&amp; group.hitRight[pHitRight].contains(hit.idData)) {</span>
              // keyHit += hit.refData;
<span class="nc" id="L2382">              dataHit[p - hitStart].add(hit.refData);</span>
<span class="nc" id="L2383">              missingHit[p - hitStart]</span>
<span class="nc" id="L2384">                  .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
              // System.out.print(p+&quot;.&quot;+hit.idData + &quot;:&quot; + hit.additionalRef +
              // &quot;\t&quot;);
            }
          }
        }
        // left
<span class="pc bpc" id="L2391" title="1 of 2 branches missed.">        if (hit.startPosition &lt; hitStart) {</span>
<span class="nc bnc" id="L2392" title="All 8 branches missed.">          if ((group.left != null || (group.hitRight != null</span>
              &amp;&amp; group.hitRight.length &gt; (1 + hitEnd - hitStart)))
              &amp;&amp; hit.idData != null) {
<span class="nc" id="L2395">            for (int p = Math.min(hit.endPosition,</span>
<span class="nc bnc" id="L2396" title="All 2 branches missed.">                hitStart - 1); p &gt;= hit.startPosition; p--) {</span>
<span class="nc" id="L2397">              int pLeft = hitStart - 1 - p;</span>
<span class="nc" id="L2398">              int pHitRight = hitEnd - p;</span>
<span class="nc bnc" id="L2399" title="All 6 branches missed.">              if (group.left != null &amp;&amp; pLeft &lt;= (group.left.length - 1)</span>
                  &amp;&amp; group.left[pLeft] != null
<span class="nc bnc" id="L2401" title="All 2 branches missed.">                  &amp;&amp; group.left[pLeft].contains(hit.idData)) {</span>
<span class="nc" id="L2402">                dataLeft[p - leftRangeStart].add(hit.refData);</span>
<span class="nc" id="L2403">                missingLeft[p - leftRangeStart]</span>
<span class="nc" id="L2404">                    .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
                // System.out.print(&quot;L&quot;+p+&quot;.&quot;+prefix + &quot;:&quot; + value + &quot;\t&quot;);
<span class="nc bnc" id="L2406" title="All 6 branches missed.">              } else if (group.hitRight != null</span>
                  &amp;&amp; pHitRight &lt;= (group.hitRight.length - 1)
                  &amp;&amp; group.hitRight[pHitRight] != null
<span class="nc bnc" id="L2409" title="All 2 branches missed.">                  &amp;&amp; group.hitRight[pHitRight].contains(hit.idData)) {</span>
<span class="nc" id="L2410">                dataLeft[p - leftRangeStart].add(hit.refData);</span>
<span class="nc" id="L2411">                missingLeft[p - leftRangeStart]</span>
<span class="nc" id="L2412">                    .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
                // System.out.print(&quot;L&quot;+p+&quot;.&quot;+prefix + &quot;:&quot; + value + &quot;\t&quot;);
              }
            }
          }
        }
        // right
<span class="pc bpc" id="L2419" title="1 of 2 branches missed.">        if (hit.endPosition &gt; hitEnd) {</span>
<span class="nc bnc" id="L2420" title="All 8 branches missed.">          if ((group.right != null || (group.hitLeft != null</span>
              &amp;&amp; group.hitLeft.length &gt; (1 + hitEnd - hitStart)))
              &amp;&amp; hit.idData != null) {
<span class="nc" id="L2423">            for (int p = Math.max(hit.startPosition,</span>
<span class="nc bnc" id="L2424" title="All 2 branches missed.">                hitEnd + 1); p &lt;= hit.endPosition; p++) {</span>
<span class="nc" id="L2425">              int pRight = p - hitEnd - 1;</span>
<span class="nc" id="L2426">              int pHitLeft = p - hitStart;</span>
<span class="nc bnc" id="L2427" title="All 6 branches missed.">              if (group.right != null &amp;&amp; pRight &lt;= (group.right.length - 1)</span>
                  &amp;&amp; group.right[pRight] != null
<span class="nc bnc" id="L2429" title="All 2 branches missed.">                  &amp;&amp; group.right[pRight].contains(hit.idData)) {</span>
<span class="nc" id="L2430">                dataRight[p - rightRangeStart].add(hit.refData);</span>
<span class="nc" id="L2431">                missingRight[p - rightRangeStart]</span>
<span class="nc" id="L2432">                    .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
                // System.out.print(&quot;R&quot;+p+&quot;.&quot;+prefix + &quot;:&quot; + value + &quot;\t&quot;);
<span class="nc bnc" id="L2434" title="All 6 branches missed.">              } else if (group.hitLeft != null</span>
                  &amp;&amp; pHitLeft &lt;= (group.hitLeft.length - 1)
                  &amp;&amp; group.hitLeft[pHitLeft] != null
<span class="nc bnc" id="L2437" title="All 2 branches missed.">                  &amp;&amp; group.hitLeft[pHitLeft].contains(hit.idData)) {</span>
<span class="nc" id="L2438">                dataRight[p - rightRangeStart].add(hit.refData);</span>
<span class="nc" id="L2439">                missingRight[p - rightRangeStart]</span>
<span class="nc" id="L2440">                    .remove(MtasToken.getPrefixFromValue(hit.refData));</span>
                // System.out.print(&quot;R&quot;+p+&quot;.&quot;+prefix + &quot;:&quot; + value + &quot;\t&quot;);
              }
            }
          }
        }
<span class="fc" id="L2446">      }</span>
      // register unknown
<span class="pc bpc" id="L2448" title="1 of 2 branches missed.">      if (missingLeft != null) {</span>
<span class="nc bnc" id="L2449" title="All 2 branches missed.">        for (int i = 0; i &lt; missingLeft.length; i++) {</span>
<span class="nc bnc" id="L2450" title="All 2 branches missed.">          for (String prefix : missingLeft[i]) {</span>
<span class="nc bnc" id="L2451" title="All 2 branches missed.">            if (!knownPrefixes.contains(prefix)) {</span>
<span class="nc" id="L2452">              unknownLeft[i].add(prefix);</span>
            }
<span class="nc" id="L2454">          }</span>
        }
      }
<span class="pc bpc" id="L2457" title="1 of 2 branches missed.">      if (missingHit != null) {</span>
<span class="fc bfc" id="L2458" title="All 2 branches covered.">        for (int i = 0; i &lt; missingHit.length; i++) {</span>
<span class="pc bpc" id="L2459" title="1 of 2 branches missed.">          for (String prefix : missingHit[i]) {</span>
<span class="nc bnc" id="L2460" title="All 2 branches missed.">            if (!knownPrefixes.contains(prefix)) {</span>
<span class="nc" id="L2461">              unknownHit[i].add(prefix);</span>
            }
<span class="nc" id="L2463">          }</span>
        }
      }
<span class="pc bpc" id="L2466" title="1 of 2 branches missed.">      if (missingRight != null) {</span>
<span class="nc bnc" id="L2467" title="All 2 branches missed.">        for (int i = 0; i &lt; missingRight.length; i++) {</span>
<span class="nc bnc" id="L2468" title="All 2 branches missed.">          for (String prefix : missingRight[i]) {</span>
<span class="nc bnc" id="L2469" title="All 2 branches missed.">            if (!knownPrefixes.contains(prefix)) {</span>
<span class="nc" id="L2470">              unknownRight[i].add(prefix);</span>
            }
<span class="nc" id="L2472">          }</span>
        }
      }
      // construct keys
<span class="fc" id="L2476">      keyLeft = dataToString(dataLeft, missingLeft);</span>
<span class="fc" id="L2477">      keyHit = dataToString(dataHit, missingHit);</span>
<span class="fc" id="L2478">      keyRight = dataToString(dataRight, missingRight);</span>
<span class="fc" id="L2479">      key = KEY_START;</span>
<span class="pc bpc" id="L2480" title="1 of 2 branches missed.">      if (keyLeft != null) {</span>
<span class="nc" id="L2481">        key += keyLeft;</span>
<span class="nc" id="L2482">        hashLeft = keyLeft.hashCode();</span>
      } else {
<span class="fc" id="L2484">        hashLeft = 1;</span>
      }
<span class="fc" id="L2486">      key += &quot;|&quot;;</span>
<span class="pc bpc" id="L2487" title="1 of 2 branches missed.">      if (keyHit != null) {</span>
<span class="fc" id="L2488">        key += keyHit;</span>
<span class="fc" id="L2489">        hashHit = keyHit.hashCode();</span>
      } else {
<span class="nc" id="L2491">        hashHit = 1;</span>
      }
<span class="fc" id="L2493">      key += &quot;|&quot;;</span>
<span class="pc bpc" id="L2494" title="1 of 2 branches missed.">      if (keyRight != null) {</span>
<span class="nc" id="L2495">        key += keyRight;</span>
<span class="nc" id="L2496">        hashRight = keyRight.hashCode();</span>
      } else {
<span class="fc" id="L2498">        hashRight = 1;</span>
      }
      // compute hash
<span class="fc" id="L2501">      hash = hashHit * (hashLeft ^ 3) * (hashRight ^ 5);</span>
<span class="fc" id="L2502">    }</span>

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
<span class="fc" id="L2511">      return hash;</span>
    }

    /**
     * Data equals.
     *
     * @param d1
     *          the d 1
     * @param d2
     *          the d 2
     * @return true, if successful
     */
    private boolean dataEquals(List&lt;String&gt;[] d1, List&lt;String&gt;[] d2) {
      List&lt;String&gt; a1;
      List&lt;String&gt; a2;
<span class="pc bpc" id="L2526" title="1 of 4 branches missed.">      if (d1 == null &amp;&amp; d2 == null) {</span>
<span class="fc" id="L2527">        return true;</span>
<span class="pc bpc" id="L2528" title="2 of 4 branches missed.">      } else if (d1 == null || d2 == null) {</span>
<span class="nc" id="L2529">        return false;</span>
      } else {
<span class="pc bpc" id="L2531" title="1 of 2 branches missed.">        if (d1.length == d2.length) {</span>
<span class="fc bfc" id="L2532" title="All 2 branches covered.">          for (int i = 0; i &lt; d1.length; i++) {</span>
<span class="fc" id="L2533">            a1 = d1[i];</span>
<span class="fc" id="L2534">            a2 = d2[i];</span>
<span class="pc bpc" id="L2535" title="3 of 6 branches missed.">            if (a1 != null &amp;&amp; a2 != null &amp;&amp; a1.size() == a2.size()) {</span>
<span class="fc bfc" id="L2536" title="All 2 branches covered.">              for (int j = 0; j &lt; a1.size(); j++) {</span>
<span class="pc bpc" id="L2537" title="1 of 2 branches missed.">                if (!a1.get(j).equals(a2.get(j))) {</span>
<span class="nc" id="L2538">                  return false;</span>
                }
              }
            } else {
<span class="nc" id="L2542">              return false;</span>
            }
          }
<span class="fc" id="L2545">          return true;</span>
        } else {
<span class="nc" id="L2547">          return false;</span>
        }
      }
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
<span class="pc bpc" id="L2559" title="1 of 2 branches missed.">      if (this == obj)</span>
<span class="nc" id="L2560">        return true;</span>
<span class="pc bpc" id="L2561" title="1 of 2 branches missed.">      if (obj == null)</span>
<span class="nc" id="L2562">        return false;</span>
<span class="pc bpc" id="L2563" title="1 of 2 branches missed.">      if (getClass() != obj.getClass())</span>
<span class="nc" id="L2564">        return false;</span>
<span class="fc" id="L2565">      GroupHit other = (GroupHit) obj;</span>
<span class="fc bfc" id="L2566" title="All 2 branches covered.">      if (hashCode() != other.hashCode())</span>
<span class="fc" id="L2567">        return false;</span>
<span class="pc bpc" id="L2568" title="1 of 2 branches missed.">      if (!dataEquals(dataHit, other.dataHit))</span>
<span class="nc" id="L2569">        return false;</span>
<span class="pc bpc" id="L2570" title="1 of 2 branches missed.">      if (!dataEquals(dataLeft, other.dataLeft))</span>
<span class="nc" id="L2571">        return false;</span>
<span class="pc bpc" id="L2572" title="1 of 2 branches missed.">      if (!dataEquals(dataRight, other.dataRight))</span>
<span class="nc" id="L2573">        return false;</span>
<span class="fc" id="L2574">      return true;</span>
    }

    /**
     * Data to string.
     *
     * @param data
     *          the data
     * @param missing
     *          the missing
     * @return the string
     * @throws UnsupportedEncodingException
     *           the unsupported encoding exception
     */
    private String dataToString(List&lt;String&gt;[] data, Set&lt;String&gt;[] missing)
        throws UnsupportedEncodingException {
<span class="fc" id="L2590">      StringBuilder text = null;</span>
<span class="fc" id="L2591">      Encoder encoder = Base64.getEncoder();</span>
      String prefix;
      String postfix;
<span class="pc bpc" id="L2594" title="2 of 6 branches missed.">      if (data != null &amp;&amp; missing != null &amp;&amp; data.length == missing.length) {</span>
<span class="fc bfc" id="L2595" title="All 2 branches covered.">        for (int i = 0; i &lt; data.length; i++) {</span>
<span class="pc bpc" id="L2596" title="1 of 2 branches missed.">          if (i &gt; 0) {</span>
<span class="nc" id="L2597">            text.append(&quot;,&quot;);</span>
          } else {
<span class="fc" id="L2599">            text = new StringBuilder();</span>
          }
<span class="fc bfc" id="L2601" title="All 2 branches covered.">          for (int j = 0; j &lt; data[i].size(); j++) {</span>
<span class="pc bpc" id="L2602" title="1 of 2 branches missed.">            if (j &gt; 0) {</span>
<span class="nc" id="L2603">              text.append(&quot;&amp;&quot;);</span>
            }
<span class="fc" id="L2605">            prefix = MtasToken.getPrefixFromValue(data[i].get(j));</span>
<span class="fc" id="L2606">            postfix = MtasToken.getPostfixFromValue(data[i].get(j));</span>
<span class="fc" id="L2607">            text.append(encoder</span>
<span class="fc" id="L2608">                .encodeToString(prefix.getBytes(StandardCharsets.UTF_8)));</span>
<span class="pc bpc" id="L2609" title="1 of 2 branches missed.">            if (!postfix.isEmpty()) {</span>
<span class="fc" id="L2610">              text.append(&quot;.&quot;);</span>
<span class="fc" id="L2611">              text.append(encoder</span>
<span class="fc" id="L2612">                  .encodeToString(postfix.getBytes(StandardCharsets.UTF_8)));</span>
            }
          }
<span class="pc bpc" id="L2615" title="1 of 2 branches missed.">          if (missing[i] != null) {</span>
<span class="fc" id="L2616">            String[] tmpMissing = missing[i]</span>
<span class="fc" id="L2617">                .toArray(new String[missing[i].size()]);</span>
<span class="pc bpc" id="L2618" title="1 of 2 branches missed.">            for (int j = 0; j &lt; tmpMissing.length; j++) {</span>
<span class="nc bnc" id="L2619" title="All 4 branches missed.">              if (j &gt; 0 || !data[i].isEmpty()) {</span>
<span class="nc" id="L2620">                text.append(&quot;&amp;&quot;);</span>
              }
<span class="nc" id="L2622">              text.append(encoder.encodeToString(</span>
<span class="nc" id="L2623">                  (&quot;!&quot; + tmpMissing[j]).getBytes(StandardCharsets.UTF_8)));</span>
            }
          }
        }
      }
<span class="fc bfc" id="L2628" title="All 2 branches covered.">      return text != null ? text.toString() : null;</span>
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    public String toString() {
<span class="fc" id="L2637">      return key;</span>
    }

    /**
     * Key to sub sub object.
     *
     * @param key
     *          the key
     * @param newKey
     *          the new key
     * @return the map[]
     */
    private static Map&lt;String, String&gt;[] keyToSubSubObject(String key,
        StringBuilder newKey) {
<span class="pc bpc" id="L2651" title="1 of 2 branches missed.">      if (!key.isEmpty()) {</span>
<span class="fc" id="L2652">        newKey.append(&quot; [&quot;);</span>
        String prefix;
        String postfix;
<span class="fc" id="L2655">        String[] parts = key.split(Pattern.quote(&quot;&amp;&quot;));</span>
<span class="fc" id="L2656">        Map&lt;String, String&gt;[] result = new HashMap[parts.length];</span>
<span class="fc" id="L2657">        Pattern pattern = Pattern.compile(&quot;^([^\\.]*)\\.([^\\.]*)$&quot;);</span>
<span class="fc" id="L2658">        Decoder decoder = Base64.getDecoder();</span>
        Matcher matcher;
<span class="fc" id="L2660">        StringBuilder tmpNewKey = null;</span>
<span class="fc bfc" id="L2661" title="All 2 branches covered.">        for (int i = 0; i &lt; parts.length; i++) {</span>
<span class="pc bpc" id="L2662" title="1 of 2 branches missed.">          if (parts[i].isEmpty()) {</span>
<span class="nc" id="L2663">            result[i] = null;</span>
          } else {
<span class="fc" id="L2665">            HashMap&lt;String, String&gt; subResult = new HashMap&lt;&gt;();</span>
<span class="fc" id="L2666">            matcher = pattern.matcher(parts[i]);</span>
<span class="pc bpc" id="L2667" title="1 of 2 branches missed.">            if (tmpNewKey != null) {</span>
<span class="nc" id="L2668">              tmpNewKey.append(&quot; &amp; &quot;);</span>
            } else {
<span class="fc" id="L2670">              tmpNewKey = new StringBuilder();</span>
            }
<span class="pc bpc" id="L2672" title="1 of 2 branches missed.">            if (matcher.matches()) {</span>
<span class="fc" id="L2673">              prefix = new String(</span>
<span class="fc" id="L2674">                  decoder.decode(</span>
<span class="fc" id="L2675">                      matcher.group(1).getBytes(StandardCharsets.UTF_8)),</span>
                  StandardCharsets.UTF_8);
<span class="fc" id="L2677">              postfix = new String(</span>
<span class="fc" id="L2678">                  decoder.decode(</span>
<span class="fc" id="L2679">                      matcher.group(2).getBytes(StandardCharsets.UTF_8)),</span>
                  StandardCharsets.UTF_8);
<span class="fc" id="L2681">              tmpNewKey.append(prefix.replace(&quot;=&quot;, &quot;\\=&quot;));</span>
<span class="fc" id="L2682">              tmpNewKey.append(&quot;=\&quot;&quot; + postfix.replace(&quot;\&quot;&quot;, &quot;\\\&quot;&quot;) + &quot;\&quot;&quot;);</span>
<span class="fc" id="L2683">              subResult.put(&quot;prefix&quot;, prefix);</span>
<span class="fc" id="L2684">              subResult.put(&quot;value&quot;, postfix);</span>
            } else {
<span class="nc" id="L2686">              prefix = new String(</span>
<span class="nc" id="L2687">                  decoder.decode(parts[i].getBytes(StandardCharsets.UTF_8)),</span>
                  StandardCharsets.UTF_8);
<span class="nc" id="L2689">              tmpNewKey.append(prefix.replace(&quot;=&quot;, &quot;\\=&quot;));</span>
<span class="nc bnc" id="L2690" title="All 2 branches missed.">              if (prefix.startsWith(&quot;!&quot;)) {</span>
<span class="nc" id="L2691">                subResult.put(&quot;missing&quot;, prefix.substring(1));</span>
              } else {
<span class="nc" id="L2693">                subResult.put(&quot;prefix&quot;, prefix);</span>
              }
            }
<span class="fc" id="L2696">            result[i] = subResult;</span>
          }
        }
<span class="pc bpc" id="L2699" title="1 of 2 branches missed.">        if (tmpNewKey != null) {</span>
<span class="fc" id="L2700">          newKey.append(tmpNewKey);</span>
        }
<span class="fc" id="L2702">        newKey.append(&quot;]&quot;);</span>
<span class="fc" id="L2703">        return result;</span>
      } else {
<span class="nc" id="L2705">        newKey.append(&quot; []&quot;);</span>
<span class="nc" id="L2706">        return null;</span>
      }
    }

    /**
     * Key to sub object.
     *
     * @param key
     *          the key
     * @param newKey
     *          the new key
     * @return the map
     */
    private static Map&lt;Integer, Map&lt;String, String&gt;[]&gt; keyToSubObject(
        String key, StringBuilder newKey) {
<span class="fc" id="L2721">      Map&lt;Integer, Map&lt;String, String&gt;[]&gt; result = new HashMap&lt;&gt;();</span>
<span class="pc bpc" id="L2722" title="1 of 4 branches missed.">      if (key == null || key.trim().isEmpty()) {</span>
<span class="fc" id="L2723">        return null;</span>
      } else {
<span class="fc" id="L2725">        String[] parts = key.split(Pattern.quote(&quot;,&quot;), -1);</span>
<span class="pc bpc" id="L2726" title="1 of 2 branches missed.">        if (parts.length &gt; 0) {</span>
<span class="fc bfc" id="L2727" title="All 2 branches covered.">          for (int i = 0; i &lt; parts.length; i++) {</span>
<span class="fc" id="L2728">            result.put(i, keyToSubSubObject(parts[i].trim(), newKey));</span>
          }
<span class="fc" id="L2730">          return result;</span>
        } else {
<span class="nc" id="L2732">          return null;</span>
        }
      }
    }

    /**
     * Key to object.
     *
     * @param key
     *          the key
     * @param newKey
     *          the new key
     * @return the map
     */
    public static Map&lt;String, Map&lt;Integer, Map&lt;String, String&gt;[]&gt;&gt; keyToObject(
        String key, StringBuilder newKey) {
<span class="pc bpc" id="L2748" title="1 of 2 branches missed.">      if (key.startsWith(KEY_START)) {</span>
<span class="fc" id="L2749">        String content = key.substring(KEY_START.length());</span>
<span class="fc" id="L2750">        StringBuilder keyLeft = new StringBuilder(&quot;&quot;);</span>
<span class="fc" id="L2751">        StringBuilder keyHit = new StringBuilder(&quot;&quot;);</span>
<span class="fc" id="L2752">        StringBuilder keyRight = new StringBuilder(&quot;&quot;);</span>
<span class="fc" id="L2753">        Map&lt;String, Map&lt;Integer, Map&lt;String, String&gt;[]&gt;&gt; result = new HashMap&lt;&gt;();</span>
<span class="fc" id="L2754">        Map&lt;Integer, Map&lt;String, String&gt;[]&gt; resultLeft = null;</span>
<span class="fc" id="L2755">        Map&lt;Integer, Map&lt;String, String&gt;[]&gt; resultHit = null;</span>
<span class="fc" id="L2756">        Map&lt;Integer, Map&lt;String, String&gt;[]&gt; resultRight = null;</span>
<span class="fc" id="L2757">        String[] parts = content.split(Pattern.quote(&quot;|&quot;), -1);</span>
<span class="pc bpc" id="L2758" title="1 of 2 branches missed.">        if (parts.length == 3) {</span>
<span class="fc" id="L2759">          resultLeft = keyToSubObject(parts[0].trim(), keyLeft);</span>
<span class="fc" id="L2760">          resultHit = keyToSubObject(parts[1].trim(), keyHit);</span>
<span class="fc" id="L2761">          resultRight = keyToSubObject(parts[2].trim(), keyRight);</span>
<span class="nc bnc" id="L2762" title="All 2 branches missed.">        } else if (parts.length == 1) {</span>
<span class="nc" id="L2763">          resultHit = keyToSubObject(parts[0].trim(), keyHit);</span>
        }
<span class="pc bpc" id="L2765" title="1 of 2 branches missed.">        if (resultLeft != null) {</span>
<span class="nc" id="L2766">          result.put(&quot;left&quot;, resultLeft);</span>
        }
<span class="fc" id="L2768">        result.put(&quot;hit&quot;, resultHit);</span>
<span class="pc bpc" id="L2769" title="1 of 2 branches missed.">        if (resultRight != null) {</span>
<span class="nc" id="L2770">          result.put(&quot;right&quot;, resultRight);</span>
        }
<span class="fc" id="L2772">        newKey.append(keyLeft);</span>
<span class="fc" id="L2773">        newKey.append(&quot; |&quot;);</span>
<span class="fc" id="L2774">        newKey.append(keyHit);</span>
<span class="fc" id="L2775">        newKey.append(&quot; |&quot;);</span>
<span class="fc" id="L2776">        newKey.append(keyRight);</span>
<span class="fc" id="L2777">        return result;</span>
      } else {
<span class="nc" id="L2779">        return null;</span>
      }
    }

  }

  /**
   * The Class ListToken.
   */
  public static class ListToken {

    /** The doc id. */
    public Integer docId;

    /** The doc position. */
    public Integer docPosition;

    /** The start position. */
    public int startPosition;

    /** The end position. */
    public int endPosition;

    /** The tokens. */
    public List&lt;MtasTokenString&gt; tokens;

    /**
     * Instantiates a new list token.
     *
     * @param docId
     *          the doc id
     * @param docPosition
     *          the doc position
     * @param match
     *          the match
     * @param tokens
     *          the tokens
     */
    public ListToken(Integer docId, Integer docPosition, Match match,
<span class="nc" id="L2818">        List&lt;MtasTokenString&gt; tokens) {</span>
<span class="nc" id="L2819">      this.docId = docId;</span>
<span class="nc" id="L2820">      this.docPosition = docPosition;</span>
<span class="nc" id="L2821">      startPosition = match.startPosition;</span>
<span class="nc" id="L2822">      endPosition = match.endPosition - 1;</span>
<span class="nc" id="L2823">      this.tokens = tokens;</span>
<span class="nc" id="L2824">    }</span>
  }

  /**
   * The Class ListHit.
   */
  public static class ListHit {

    /** The doc id. */
    public Integer docId;

    /** The doc position. */
    public Integer docPosition;

    /** The start position. */
    public int startPosition;

    /** The end position. */
    public int endPosition;

    /** The hits. */
    public Map&lt;Integer, List&lt;String&gt;&gt; hits;

    /**
     * Instantiates a new list hit.
     *
     * @param docId
     *          the doc id
     * @param docPosition
     *          the doc position
     * @param match
     *          the match
     * @param hits
     *          the hits
     */
    public ListHit(Integer docId, Integer docPosition, Match match,
<span class="nc" id="L2860">        Map&lt;Integer, List&lt;String&gt;&gt; hits) {</span>
<span class="nc" id="L2861">      this.docId = docId;</span>
<span class="nc" id="L2862">      this.docPosition = docPosition;</span>
<span class="nc" id="L2863">      startPosition = match.startPosition;</span>
<span class="nc" id="L2864">      endPosition = match.endPosition - 1;</span>
<span class="nc" id="L2865">      this.hits = hits;</span>
<span class="nc" id="L2866">    }</span>
  }

  /**
   * The Class Match.
   */
  public static class Match {

    /** The start position. */
    public int startPosition;

    /** The end position. */
    public int endPosition;

    /**
     * Instantiates a new match.
     *
     * @param startPosition
     *          the start position
     * @param endPosition
     *          the end position
     */
<span class="fc" id="L2888">    public Match(int startPosition, int endPosition) {</span>
<span class="fc" id="L2889">      this.startPosition = startPosition;</span>
<span class="fc" id="L2890">      this.endPosition = endPosition;</span>
<span class="fc" id="L2891">    }</span>

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
<span class="nc bnc" id="L2900" title="All 2 branches missed.">      if (this == obj)</span>
<span class="nc" id="L2901">        return true;</span>
<span class="nc bnc" id="L2902" title="All 2 branches missed.">      if (obj == null)</span>
<span class="nc" id="L2903">        return false;</span>
<span class="nc bnc" id="L2904" title="All 2 branches missed.">      if (getClass() != obj.getClass())</span>
<span class="nc" id="L2905">        return false;</span>
<span class="nc" id="L2906">      final Match that = (Match) obj;</span>
<span class="nc bnc" id="L2907" title="All 4 branches missed.">      return startPosition == that.startPosition</span>
          &amp;&amp; endPosition == that.endPosition;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
<span class="nc" id="L2918">      int h = this.getClass().getSimpleName().hashCode();</span>
<span class="nc" id="L2919">      h = (h * 5) ^ startPosition;</span>
<span class="nc" id="L2920">      h = (h * 7) ^ endPosition;</span>
<span class="nc" id="L2921">      return h;</span>
    }

  }

}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>