MCPcopy Index your code
hub / github.com/google/gson / nextDouble

Method nextDouble

src/main/java/com/google/gson/stream/JsonReader.java:525–543  ·  view source on GitHub ↗

Returns the JsonToken#NUMBER double value of the next token, consuming it. If the next token is a string, this method will attempt to parse it as a double. @throws IllegalStateException if the next token is not a literal value. @throws NumberFormatException if the next literal value cannot

()

Source from the content-addressed store, hash-verified

523 * as a double, or is non-finite.
524 */
525 public double nextDouble() throws IOException {
526 quickPeek();
527 if (value == null) {
528 throw new IllegalStateException("Expected a double but was " + peek());
529 }
530
531 double result = Double.parseDouble(value);
532
533 if ((result >= 1.0d && value.startsWith("0"))) {
534 throw new NumberFormatException("JSON forbids octal prefixes: " + value);
535 }
536
537 if (!lenient && (Double.isNaN(result) || Double.isInfinite(result))) {
538 throw new NumberFormatException("JSON forbids NaN and infinities: " + value);
539 }
540
541 advance();
542 return result;
543 }
544
545 /**
546 * Returns the {@link JsonToken#NUMBER long} value of the next token,

Callers 6

testDoublesMethod · 0.95
testLongsMethod · 0.95

Calls 3

quickPeekMethod · 0.95
peekMethod · 0.95
advanceMethod · 0.95

Tested by 6

testDoublesMethod · 0.76
testLongsMethod · 0.76