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

Method expect

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

739 * @throws UncheckedIOException if an I/O exception is encountered
740 */
741 private void expect(JsonType type) {
742 if (peek() != type) {
743 throw new JsonException(
744 "Expected to read a " + type + " but instead have: " + peek() + ". " + input);
745 }
746
747 // The pending token is about to be consumed, so the memoized type is no longer valid.
748 peekedType = null;
749
750 // Special map handling. Woo!
751 byte top = topContainer();
752
753 if (type == JsonType.NAME) {
754 if (top == MAP_NAME) {
755 containerState[containerDepth - 1] = MAP_VALUE;
756 return;
757 } else if (top != NONE) {
758 throw new JsonException("Unexpected attempt to read name. " + input);
759 }
760
761 return; // End of Name handling
762 }
763
764 // Handle the case where we're reading a value.
765 if (type == JsonType.END_COLLECTION || type == JsonType.END_MAP) {
766 // Closing the container - don't treat as a new element in it.
767 return;
768 }
769 if (top == MAP_VALUE) {
770 containerState[containerDepth - 1] = MAP_NAME;
771 markElementRead();
772 } else if (top == COLLECTION) {
773 markElementRead();
774 }
775 }
776
777 private byte topContainer() {
778 return containerDepth == 0 ? NONE : containerState[containerDepth - 1];

Callers 10

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

Calls 3

peekMethod · 0.95
topContainerMethod · 0.95
markElementReadMethod · 0.95

Tested by

no test coverage detected