MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / expect

Method expect

java/src/org/openqa/selenium/json/JsonInput.java:512–538  ·  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

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

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 1

peekMethod · 0.95

Tested by

no test coverage detected