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

Method readString

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

834 * @throws UncheckedIOException if an I/O exception is encountered
835 */
836 private String readString() {
837 input.read(); // Skip leading quote
838
839 // Fast path: an escape-free string that is fully buffered needs no intermediate copies.
840 String simple = input.readSimpleString();
841 if (simple != null) {
842 return simple;
843 }
844
845 StringBuilder builder = new StringBuilder();
846 while (true) {
847 int c = input.appendStringContent(builder);
848 switch (c) {
849 case Input.EOF:
850 throw new JsonException("Unterminated string: " + builder + ". " + input);
851 case '"': // terminate string
852 input.read();
853 return builder.toString();
854 case '\\': // quoted char
855 input.read();
856 readEscape(builder);
857 break;
858 default:
859 // RFC 8259 §7: characters U+0000..U+001F MUST be escaped.
860 input.read();
861 throw new JsonException(
862 String.format("Illegal unescaped control character U+%04X in string. %s", c, input));
863 }
864 }
865 }
866
867 /**
868 * 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 6

readEscapeMethod · 0.95
readSimpleStringMethod · 0.80
appendStringContentMethod · 0.80
readMethod · 0.65
toStringMethod · 0.65
formatMethod · 0.45

Tested by 2

executeMethod · 0.64