1 38 39 40 package com.sun.xml.fastinfoset; 41 42 public class DecoderStateTables { 43 private static int RANGE_INDEX_END = 0; 44 private static int RANGE_INDEX_VALUE = 1; 45 46 public final static int STATE_ILLEGAL = 255; 47 public final static int STATE_UNSUPPORTED = 254; 48 49 public final static int EII_NO_AIIS_INDEX_SMALL = 0; 51 public final static int EII_AIIS_INDEX_SMALL = 1; 52 public final static int EII_INDEX_MEDIUM = 2; 53 public final static int EII_INDEX_LARGE = 3; 54 public final static int EII_NAMESPACES = 4; 55 public final static int EII_LITERAL = 5; 56 public final static int CII_UTF8_SMALL_LENGTH = 6; 57 public final static int CII_UTF8_MEDIUM_LENGTH = 7; 58 public final static int CII_UTF8_LARGE_LENGTH = 8; 59 public final static int CII_UTF16_SMALL_LENGTH = 9; 60 public final static int CII_UTF16_MEDIUM_LENGTH = 10; 61 public final static int CII_UTF16_LARGE_LENGTH = 11; 62 public final static int CII_RA = 12; 63 public final static int CII_EA = 13; 64 public final static int CII_INDEX_SMALL = 14; 65 public final static int CII_INDEX_MEDIUM = 15; 66 public final static int CII_INDEX_LARGE = 16; 67 public final static int CII_INDEX_LARGE_LARGE = 17; 68 public final static int COMMENT_II = 18; 69 public final static int PROCESSING_INSTRUCTION_II = 19; 70 public final static int DOCUMENT_TYPE_DECLARATION_II = 20; 71 public final static int UNEXPANDED_ENTITY_REFERENCE_II = 21; 72 public final static int TERMINATOR_SINGLE = 22; 73 public final static int TERMINATOR_DOUBLE = 23; 74 75 public static final int[] DII = new int[256]; 76 77 private static int[][] DII_RANGES = { 78 80 { 0x1F, EII_NO_AIIS_INDEX_SMALL }, 82 83 { 0x27, EII_INDEX_MEDIUM }, 85 86 { 0x30, EII_INDEX_LARGE }, 90 91 { 0x37, STATE_ILLEGAL }, 93 94 { 0x38, EII_NAMESPACES }, 96 97 { 0x3B, STATE_ILLEGAL }, 99 100 { 0x3C, EII_LITERAL }, 102 103 { 0x3D, EII_LITERAL }, 105 106 { 0x3E, STATE_ILLEGAL }, 108 109 { 0x3F, EII_LITERAL }, 111 112 { 0x5F, EII_AIIS_INDEX_SMALL }, 114 115 { 0x67, EII_INDEX_MEDIUM }, 117 118 { 0x70, EII_INDEX_LARGE }, 122 123 { 0x77, STATE_ILLEGAL }, 125 126 { 0x78, EII_NAMESPACES }, 128 129 { 0x7B, STATE_ILLEGAL }, 131 132 { 0x7C, EII_LITERAL }, 134 135 { 0x7D, EII_LITERAL }, 137 138 { 0x7E, STATE_ILLEGAL }, 140 141 { 0x7F, EII_LITERAL }, 143 144 { 0xC3, STATE_ILLEGAL }, 146 147 { 0xC7, DOCUMENT_TYPE_DECLARATION_II }, 149 150 { 0xE0, STATE_ILLEGAL }, 152 153 { 0xE1, PROCESSING_INSTRUCTION_II }, 155 156 { 0xE2, COMMENT_II}, 158 159 { 0xEF, STATE_ILLEGAL }, 161 162 164 { 0xF0, TERMINATOR_SINGLE }, 166 167 { 0xFE, STATE_ILLEGAL }, 169 170 { 0xFF, TERMINATOR_DOUBLE } 172 }; 173 174 public static final int[] EII = new int[256]; 175 176 private static int[][] EII_RANGES = { 177 179 { 0x1F, EII_NO_AIIS_INDEX_SMALL }, 181 182 { 0x27, EII_INDEX_MEDIUM }, 184 185 { 0x30, EII_INDEX_LARGE }, 189 190 { 0x37, STATE_ILLEGAL }, 192 193 { 0x38, EII_NAMESPACES }, 195 196 { 0x3B, STATE_ILLEGAL }, 198 199 { 0x3C, EII_LITERAL }, 201 202 { 0x3D, EII_LITERAL }, 204 205 { 0x3E, STATE_ILLEGAL }, 207 208 { 0x3F, EII_LITERAL }, 210 211 { 0x5F, EII_AIIS_INDEX_SMALL }, 213 214 { 0x67, EII_INDEX_MEDIUM }, 216 217 { 0x70, EII_INDEX_LARGE }, 221 222 { 0x77, STATE_ILLEGAL }, 224 225 { 0x78, EII_NAMESPACES }, 227 228 { 0x7B, STATE_ILLEGAL }, 230 231 { 0x7C, EII_LITERAL }, 233 234 { 0x7D, EII_LITERAL }, 236 237 { 0x7E, STATE_ILLEGAL }, 239 240 { 0x7F, EII_LITERAL }, 242 243 245 247 { 0x81, CII_UTF8_SMALL_LENGTH }, 249 250 { 0x82, CII_UTF8_MEDIUM_LENGTH }, 252 253 { 0x83, CII_UTF8_LARGE_LENGTH }, 255 256 258 { 0x85, CII_UTF16_SMALL_LENGTH }, 260 261 { 0x86, CII_UTF16_MEDIUM_LENGTH }, 263 264 { 0x87, CII_UTF16_LARGE_LENGTH }, 266 267 269 { 0x8B, CII_RA }, 271 272 274 { 0x8F, CII_EA }, 276 277 279 { 0x91, CII_UTF8_SMALL_LENGTH }, 281 282 { 0x92, CII_UTF8_MEDIUM_LENGTH }, 284 285 { 0x93, CII_UTF8_LARGE_LENGTH }, 287 288 290 { 0x95, CII_UTF16_SMALL_LENGTH }, 292 293 { 0x96, CII_UTF16_MEDIUM_LENGTH }, 295 296 { 0x97, CII_UTF16_LARGE_LENGTH }, 298 299 301 { 0x9B, CII_RA }, 303 304 306 { 0x9F, CII_EA }, 308 309 311 { 0xAF, CII_INDEX_SMALL }, 313 314 { 0xB3, CII_INDEX_MEDIUM }, 316 317 { 0xB7, CII_INDEX_LARGE }, 319 320 { 0xB8, CII_INDEX_LARGE_LARGE }, 322 323 { 0xC7, STATE_ILLEGAL }, 325 326 { 0xCB, UNEXPANDED_ENTITY_REFERENCE_II }, 328 329 { 0xE0, STATE_ILLEGAL }, 331 332 { 0xE1, PROCESSING_INSTRUCTION_II }, 334 335 { 0xE2, COMMENT_II}, 337 338 { 0xEF, STATE_ILLEGAL }, 340 341 343 { 0xF0, TERMINATOR_SINGLE }, 345 346 { 0xFE, STATE_ILLEGAL }, 348 349 { 0xFF, TERMINATOR_DOUBLE } 351 }; 352 353 354 public final static int AII_INDEX_SMALL = 0; 356 public final static int AII_INDEX_MEDIUM = 1; 357 public final static int AII_INDEX_LARGE = 2; 358 public final static int AII_LITERAL = 3; 359 public final static int AII_TERMINATOR_SINGLE = 4; 360 public final static int AII_TERMINATOR_DOUBLE = 5; 361 362 public static final int[] AII = new int[256]; 363 364 private static int[][] AII_RANGES = { 365 { 0x3F, AII_INDEX_SMALL }, 367 368 { 0x5F, AII_INDEX_MEDIUM }, 370 371 { 0x6F, AII_INDEX_LARGE }, 373 374 { 0x77, STATE_ILLEGAL }, 376 377 { 0x79, AII_LITERAL }, 380 381 { 0x7A, STATE_ILLEGAL }, 383 384 { 0x7B, AII_LITERAL }, 386 387 { 0xEF, STATE_ILLEGAL }, 389 390 392 { 0xF0, AII_TERMINATOR_SINGLE }, 394 395 { 0xFE, STATE_ILLEGAL }, 397 398 { 0xFF, AII_TERMINATOR_DOUBLE } 400 }; 401 402 403 public final static int NISTRING_UTF8_SMALL_LENGTH = 0; 405 public final static int NISTRING_UTF8_MEDIUM_LENGTH = 1; 406 public final static int NISTRING_UTF8_LARGE_LENGTH = 2; 407 public final static int NISTRING_UTF16_SMALL_LENGTH = 3; 408 public final static int NISTRING_UTF16_MEDIUM_LENGTH = 4; 409 public final static int NISTRING_UTF16_LARGE_LENGTH = 5; 410 public final static int NISTRING_RA = 6; 411 public final static int NISTRING_EA = 7; 412 public final static int NISTRING_INDEX_SMALL = 8; 413 public final static int NISTRING_INDEX_MEDIUM = 9; 414 public final static int NISTRING_INDEX_LARGE = 10; 415 public final static int NISTRING_EMPTY = 11; 416 417 public static final int[] NISTRING = new int[256]; 418 419 private static int[][] NISTRING_RANGES = { 420 422 { 0x07, NISTRING_UTF8_SMALL_LENGTH }, 424 425 { 0x08, NISTRING_UTF8_MEDIUM_LENGTH }, 427 428 { 0x0B, STATE_ILLEGAL }, 430 431 { 0x0C, NISTRING_UTF8_LARGE_LENGTH }, 433 434 { 0x0F, STATE_ILLEGAL }, 436 437 439 { 0x17, NISTRING_UTF16_SMALL_LENGTH }, 441 442 { 0x18, NISTRING_UTF16_MEDIUM_LENGTH }, 444 445 { 0x1B, STATE_ILLEGAL }, 447 448 { 0x1C, NISTRING_UTF16_LARGE_LENGTH }, 450 451 { 0x1F, STATE_ILLEGAL }, 453 454 456 { 0x2F, NISTRING_RA }, 458 459 461 { 0x3F, NISTRING_EA }, 463 464 466 { 0x47, NISTRING_UTF8_SMALL_LENGTH }, 468 469 { 0x48, NISTRING_UTF8_MEDIUM_LENGTH }, 471 472 { 0x4B, STATE_ILLEGAL }, 474 475 { 0x4C, NISTRING_UTF8_LARGE_LENGTH }, 477 478 { 0x4F, STATE_ILLEGAL }, 480 481 483 { 0x57, NISTRING_UTF16_SMALL_LENGTH }, 485 486 { 0x58, NISTRING_UTF16_MEDIUM_LENGTH }, 488 489 { 0x5B, STATE_ILLEGAL }, 491 492 { 0x5C, NISTRING_UTF16_LARGE_LENGTH }, 494 495 { 0x5F, STATE_ILLEGAL }, 497 498 500 { 0x6F, NISTRING_RA }, 502 503 505 { 0x7F, NISTRING_EA }, 507 508 510 { 0xBF, NISTRING_INDEX_SMALL }, 512 513 { 0xDF, NISTRING_INDEX_MEDIUM }, 515 516 { 0xEF, NISTRING_INDEX_LARGE }, 518 519 { 0xFE, STATE_ILLEGAL }, 521 522 { 0xFF, NISTRING_EMPTY }, 524 }; 525 526 527 public final static int ISTRING_SMALL_LENGTH = 0; 528 public final static int ISTRING_MEDIUM_LENGTH = 1; 529 public final static int ISTRING_LARGE_LENGTH = 2; 530 public final static int ISTRING_INDEX_SMALL = 3; 531 public final static int ISTRING_INDEX_MEDIUM = 4; 532 public final static int ISTRING_INDEX_LARGE = 5; 533 534 public static final int[] ISTRING = new int[256]; 535 536 private static int[][] ISTRING_RANGES = { 537 { 0x3F, ISTRING_SMALL_LENGTH }, 539 540 { 0x40, ISTRING_MEDIUM_LENGTH }, 542 543 { 0x5F, STATE_ILLEGAL }, 545 546 { 0x60, ISTRING_LARGE_LENGTH }, 548 549 { 0x7F, STATE_ILLEGAL }, 551 552 { 0xBF, ISTRING_INDEX_SMALL }, 554 555 { 0xDF, ISTRING_INDEX_MEDIUM }, 557 558 { 0xEF, ISTRING_INDEX_LARGE }, 560 561 { 0xFF, STATE_ILLEGAL }, 563 }; 564 565 566 public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_3 = 6; 567 public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_5 = 7; 568 public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_29 = 8; 569 public final static int ISTRING_PREFIX_NAMESPACE_LENGTH_36 = 9; 570 public final static int ISTRING_PREFIX_NAMESPACE_INDEX_ZERO = 10; 571 572 public static final int[] ISTRING_PREFIX_NAMESPACE = new int[256]; 573 574 private static int[][] ISTRING_PREFIX_NAMESPACE_RANGES = { 575 { 0x01, ISTRING_SMALL_LENGTH }, 577 578 { 0x02, ISTRING_PREFIX_NAMESPACE_LENGTH_3 }, 580 581 { 0x03, ISTRING_SMALL_LENGTH }, 583 584 { 0x04, ISTRING_PREFIX_NAMESPACE_LENGTH_5 }, 586 587 { 0x1B, ISTRING_SMALL_LENGTH }, 589 590 { 0x1C, ISTRING_PREFIX_NAMESPACE_LENGTH_29 }, 592 593 { 0x22, ISTRING_SMALL_LENGTH }, 595 596 { 0x23, ISTRING_PREFIX_NAMESPACE_LENGTH_36 }, 598 599 { 0x3F, ISTRING_SMALL_LENGTH }, 601 602 603 604 605 { 0x40, ISTRING_MEDIUM_LENGTH }, 607 608 { 0x5F, STATE_ILLEGAL }, 610 611 { 0x60, ISTRING_LARGE_LENGTH }, 613 614 { 0x7F, STATE_ILLEGAL }, 616 617 { 0x80, ISTRING_PREFIX_NAMESPACE_INDEX_ZERO }, 619 620 { 0xBF, ISTRING_INDEX_SMALL }, 622 623 { 0xDF, ISTRING_INDEX_MEDIUM }, 625 626 { 0xEF, ISTRING_INDEX_LARGE }, 628 629 { 0xFF, STATE_ILLEGAL }, 631 }; 632 633 public final static int UTF8_NCNAME_NCNAME = 0; 635 public final static int UTF8_NCNAME_NCNAME_CHAR = 1; 636 public final static int UTF8_TWO_BYTES = 2; 637 public final static int UTF8_THREE_BYTES = 3; 638 public final static int UTF8_FOUR_BYTES = 4; 639 640 public static final int[] UTF8_NCNAME = new int[256]; 641 642 private static int[][] UTF8_NCNAME_RANGES = { 643 644 646 { 0x2C, STATE_ILLEGAL }, 648 649 { 0x2E, UTF8_NCNAME_NCNAME_CHAR }, 652 653 { 0x2F, STATE_ILLEGAL }, 655 656 { 0x39, UTF8_NCNAME_NCNAME_CHAR }, 659 660 { 0x40, STATE_ILLEGAL }, 662 663 { 0x5A, UTF8_NCNAME_NCNAME }, 666 667 { 0x5E, STATE_ILLEGAL }, 669 670 { 0x5F, UTF8_NCNAME_NCNAME }, 673 674 { 0x60, STATE_ILLEGAL }, 676 677 { 0x7A, UTF8_NCNAME_NCNAME }, 680 681 { 0x7F, STATE_ILLEGAL }, 683 684 685 687 { 0xC1, STATE_ILLEGAL }, 689 690 { 0xDF, UTF8_TWO_BYTES }, 692 693 694 696 { 0xEF, UTF8_THREE_BYTES }, 698 699 700 702 { 0xF7, UTF8_FOUR_BYTES }, 704 705 706 { 0xFF, STATE_ILLEGAL } 708 }; 709 710 public final static int UTF8_ONE_BYTE = 1; 711 712 public static final int[] UTF8 = new int[256]; 713 714 private static int[][] UTF8_RANGES = { 715 716 718 { 0x08, STATE_ILLEGAL }, 720 721 { 0x0A, UTF8_ONE_BYTE }, 724 725 { 0x0C, STATE_ILLEGAL }, 727 728 { 0x0D, UTF8_ONE_BYTE }, 731 732 { 0x1F, STATE_ILLEGAL }, 734 735 { 0x7F, UTF8_ONE_BYTE }, 737 738 739 741 { 0xC1, STATE_ILLEGAL }, 743 744 { 0xDF, UTF8_TWO_BYTES }, 746 747 748 750 { 0xEF, UTF8_THREE_BYTES }, 752 753 754 756 { 0xF7, UTF8_FOUR_BYTES }, 758 759 760 { 0xFF, STATE_ILLEGAL } 762 }; 763 764 private static void constructTable(int[] table, int[][] ranges) { 765 int start = 0x00; 766 for (int range = 0; range < ranges.length; range++) { 767 int end = ranges[range][RANGE_INDEX_END]; 768 int value = ranges[range][RANGE_INDEX_VALUE]; 769 for (int i = start; i<= end; i++) { 770 table[i] = value; 771 } 772 start = end + 1; 773 } 774 } 775 776 static { 777 constructTable(DII, DII_RANGES); 779 780 constructTable(EII, EII_RANGES); 782 783 constructTable(AII, AII_RANGES); 785 786 constructTable(NISTRING, NISTRING_RANGES); 788 789 constructTable(ISTRING, ISTRING_RANGES); 791 792 constructTable(ISTRING_PREFIX_NAMESPACE, ISTRING_PREFIX_NAMESPACE_RANGES); 794 795 constructTable(UTF8_NCNAME, UTF8_NCNAME_RANGES); 797 798 constructTable(UTF8, UTF8_RANGES); 800 } 801 802 private DecoderStateTables() { 803 } 804 } 805 | Popular Tags |