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

Method readString

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

Read the next element from the JSON input stream as a string, converting escaped characters. @return String object @throws JsonException if input stream ends without finding a closing quote @throws UncheckedIOException if an I/O exception is encountered

()

Source from the content-addressed store, hash-verified

651 * @throws UncheckedIOException if an I/O exception is encountered
652 */
653 private String readString() {
654 input.read(); // Skip leading quote
655
656 StringBuilder builder = new StringBuilder();
657 while (true) {
658 int c = input.read();
659 switch (c) {
660 case Input.EOF:
661 throw new JsonException("Unterminated string: " + builder + ". " + input);
662 case '"': // terminate string
663 return builder.toString();
664 case '\\': // quoted char
665 readEscape(builder);
666 break;
667 default:
668 // RFC 8259 §7: characters U+0000..U+001F MUST be escaped.
669 if (c < 0x20) {
670 throw new JsonException(
671 String.format(
672 "Illegal unescaped control character U+%04X in string. %s", c, input));
673 }
674 builder.append((char) c);
675 }
676 }
677 }
678
679 /**
680 * Convert the escape sequence at the current JSON input stream position, appending the result to

Callers 4

nextNameMethod · 0.95
nextStringMethod · 0.95
executeMethod · 0.80

Calls 5

readEscapeMethod · 0.95
readMethod · 0.65
toStringMethod · 0.65
formatMethod · 0.45
appendMethod · 0.45

Tested by 2

executeMethod · 0.64