MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / expect

Method expect

java/src/org/openqa/selenium/json/JsonInput.java:571–604  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

569 * @throws UncheckedIOException if an I/O exception is encountered
570 */
571 private void expect(JsonType type) {
572 if (peek() != type) {
573 throw new JsonException(
574 "Expected to read a " + type + " but instead have: " + peek() + ". " + input);
575 }
576
577 // Special map handling. Woo!
578 Container top = stack.peekFirst();
579
580 if (type == JsonType.NAME) {
581 if (top == Container.MAP_NAME) {
582 stack.removeFirst();
583 stack.addFirst(Container.MAP_VALUE);
584 return;
585 } else if (top != null) {
586 throw new JsonException("Unexpected attempt to read name. " + input);
587 }
588
589 return; // End of Name handling
590 }
591
592 // Handle the case where we're reading a value.
593 if (type == JsonType.END_COLLECTION || type == JsonType.END_MAP) {
594 // Closing the container - don't treat as a new element in it.
595 return;
596 }
597 if (top == Container.MAP_VALUE) {
598 stack.removeFirst();
599 stack.addFirst(Container.MAP_NAME);
600 markElementRead();
601 } else if (top == Container.COLLECTION) {
602 markElementRead();
603 }
604 }
605
606 private void markElementRead() {
607 if (!containerHasElement.isEmpty()) {

Callers 10

nextBooleanMethod · 0.95
nextNameMethod · 0.95
nextNullMethod · 0.95
nextNumberMethod · 0.95
nextStringMethod · 0.95
nextEndMethod · 0.95
beginArrayMethod · 0.95
endArrayMethod · 0.95
beginObjectMethod · 0.95
endObjectMethod · 0.95

Calls 2

peekMethod · 0.95
markElementReadMethod · 0.95

Tested by

no test coverage detected