Verify that the type of the pending JSON element matches the specified type. @param type expected JSON element type @throws JsonException if the pending element is not of the expected type @throws UncheckedIOException if an I/O exception is encountered
(JsonType type)
| 510 | * @throws UncheckedIOException if an I/O exception is encountered |
| 511 | */ |
| 512 | private void expect(JsonType type) { |
| 513 | if (peek() != type) { |
| 514 | throw new JsonException( |
| 515 | "Expected to read a " + type + " but instead have: " + peek() + ". " + input); |
| 516 | } |
| 517 | |
| 518 | // Special map handling. Woo! |
| 519 | Container top = stack.peekFirst(); |
| 520 | |
| 521 | if (type == JsonType.NAME) { |
| 522 | if (top == Container.MAP_NAME) { |
| 523 | stack.removeFirst(); |
| 524 | stack.addFirst(Container.MAP_VALUE); |
| 525 | return; |
| 526 | } else if (top != null) { |
| 527 | throw new JsonException("Unexpected attempt to read name. " + input); |
| 528 | } |
| 529 | |
| 530 | return; // End of Name handling |
| 531 | } |
| 532 | |
| 533 | // Handle the case where we're reading a value |
| 534 | if (top == Container.MAP_VALUE) { |
| 535 | stack.removeFirst(); |
| 536 | stack.addFirst(Container.MAP_NAME); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Read the next element from the JSON input stream, converting with the supplied mapper if it's |
no test coverage detected