()
| 579 | } |
| 580 | |
| 581 | @SuppressWarnings("fallthrough") |
| 582 | int doPeek() throws IOException { |
| 583 | int peekStack = stack[stackSize - 1]; |
| 584 | if (peekStack == JsonScope.EMPTY_ARRAY) { |
| 585 | stack[stackSize - 1] = JsonScope.NONEMPTY_ARRAY; |
| 586 | } else if (peekStack == JsonScope.NONEMPTY_ARRAY) { |
| 587 | // Look for a comma before the next element. |
| 588 | int c = nextNonWhitespace(true); |
| 589 | switch (c) { |
| 590 | case ']': |
| 591 | peeked = PEEKED_END_ARRAY; |
| 592 | return peeked; |
| 593 | case ';': |
| 594 | checkLenient(); // fall-through |
| 595 | case ',': |
| 596 | break; |
| 597 | default: |
| 598 | throw syntaxError("Unterminated array"); |
| 599 | } |
| 600 | } else if (peekStack == JsonScope.EMPTY_OBJECT || peekStack == JsonScope.NONEMPTY_OBJECT) { |
| 601 | stack[stackSize - 1] = JsonScope.DANGLING_NAME; |
| 602 | // Look for a comma before the next element. |
| 603 | if (peekStack == JsonScope.NONEMPTY_OBJECT) { |
| 604 | int c = nextNonWhitespace(true); |
| 605 | switch (c) { |
| 606 | case '}': |
| 607 | peeked = PEEKED_END_OBJECT; |
| 608 | return peeked; |
| 609 | case ';': |
| 610 | checkLenient(); // fall-through |
| 611 | case ',': |
| 612 | break; |
| 613 | default: |
| 614 | throw syntaxError("Unterminated object"); |
| 615 | } |
| 616 | } |
| 617 | int c = nextNonWhitespace(true); |
| 618 | switch (c) { |
| 619 | case '"': |
| 620 | peeked = PEEKED_DOUBLE_QUOTED_NAME; |
| 621 | return peeked; |
| 622 | case '\'': |
| 623 | checkLenient(); |
| 624 | peeked = PEEKED_SINGLE_QUOTED_NAME; |
| 625 | return peeked; |
| 626 | case '}': |
| 627 | if (peekStack != JsonScope.NONEMPTY_OBJECT) { |
| 628 | peeked = PEEKED_END_OBJECT; |
| 629 | return peeked; |
| 630 | } else { |
| 631 | throw syntaxError("Expected name"); |
| 632 | } |
| 633 | default: |
| 634 | checkLenient(); |
| 635 | pos--; // Don't consume the first character in an unquoted string. |
| 636 | if (isLiteral((char) c)) { |
| 637 | peeked = PEEKED_UNQUOTED_NAME; |
| 638 | return peeked; |
no test coverage detected