Skip to content

Commit

Permalink
Fix google#45: Resolve various comments by Marcono1234
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-voorberg committed Mar 7, 2023
1 parent 8b63f54 commit 6a27a65
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions gson/src/main/java/com/google/gson/GsonBuilder.java
Expand Up @@ -530,13 +530,13 @@ public GsonBuilder setLenient() {
*
* @param strictness the new strictness method of this factory. May not be null.
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern.
* @throws NullPointerException if the provided <code>strictness</code> is <code>null</code>.
* @throws NullPointerException if the provided {@code strictness} is {@code null}.
* @see JsonWriter#setStrictness(Strictness)
* @see JsonReader#setStrictness(Strictness)
* @since $next-version$
*/
public GsonBuilder setStrictness(Strictness strictness) {
this.strictness = Objects.requireNonNull(strictness);;
this.strictness = Objects.requireNonNull(strictness);
return this;
}

Expand Down
21 changes: 12 additions & 9 deletions gson/src/main/java/com/google/gson/Strictness.java
@@ -1,17 +1,20 @@
package com.google.gson;

import com.google.gson.stream.JsonWriter;
import com.google.gson.stream.JsonReader;

/**
* Modes that indicate how strictly a JSON {@linkplain com.google.gson.stream.JsonReader reader} or
* {@linkplain com.google.gson.stream.JsonWriter writer} follows the syntax laid out in the
* <a href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259 JSON specification</a>.
* Modes that indicate how strictly a JSON {@linkplain JsonReader reader} or
* {@linkplain JsonWriter writer} follows the syntax laid out in the
* <a href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259 JSON specification</a>.
*
* <p>You can look at {@link com.google.gson.stream.JsonWriter#setStrictness(Strictness)} to see how the strictness
* affects the {@link com.google.gson.stream.JsonWriter} and you can look at
* {@link com.google.gson.stream.JsonReader#setStrictness(Strictness)} to see how the strictness
* affects the {@link com.google.gson.stream.JsonReader} </p>
* <p>You can look at {@link JsonWriter#setStrictness(Strictness)} to see how the strictness
* affects the {@link JsonWriter} and you can look at
* {@link JsonReader#setStrictness(Strictness)} to see how the strictness
* affects the {@link JsonReader}.</p>
*
* @see com.google.gson.stream.JsonReader#setStrictness(Strictness)
* @see com.google.gson.stream.JsonWriter#setStrictness(Strictness)
* @see JsonReader#setStrictness(Strictness)
* @see JsonWriter#setStrictness(Strictness)
* @since $next-version$
*/
public enum Strictness {
Expand Down
25 changes: 12 additions & 13 deletions gson/src/main/java/com/google/gson/stream/JsonReader.java
Expand Up @@ -293,7 +293,7 @@ public JsonReader(Reader in) {
}

/**
* Set the strictness this JSONReader to {@link Strictness#LENIENT} if the provided argument is true and
* Set the strictness this reader to {@link Strictness#LENIENT} if the provided argument is true and
* set the strictness to {@link Strictness#DEFAULT} if the provided argument if false.
*
* @param lenient passing <code>true</code> will set the strictness of this reader to {@link Strictness#LENIENT} and
Expand All @@ -305,7 +305,7 @@ public final void setLenient(boolean lenient) {
}

/**
* Returns true if the {@link Strictness} of this reader is equal to {@link Strictness#STRICT}.
* Returns true if the {@link Strictness} of this reader is equal to {@link Strictness#LENIENT}.
*
* @see #setStrictness(Strictness)
*/
Expand All @@ -317,21 +317,21 @@ public final boolean isLenient() {
* Configure how liberal this parser is in what it accepts.
*
* <p>In {@linkplain Strictness#STRICT strict} mode, the
* parser only accepts JSON in accordance with <a href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>.
* parser only accepts JSON in accordance with <a href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>.
* In {@linkplain Strictness#DEFAULT default} mode, only JSON in accordance with the <a
* href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a> is accepted, with a few exceptions denoted below
* href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a> is accepted, with a few exceptions denoted below
* for backwards compatibility reasons. In {@linkplain Strictness#LENIENT lenient} mode,
* all sort of non-spec compliant JSON is accepted (see below).</p>
*
* <dl>
* <dt>{@link Strictness#STRICT}</dt>
* <dd>
* In strict mode, only input compliant with <a href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>
* In strict mode, only input compliant with <a href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>
* is parsed.
* </dd>
* <dt>{@link Strictness#DEFAULT}</dt>
* <dd>
* In default mode, the following departures from <a href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>
* In default mode, the following departures from <a href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>
* are accepted:
* <ul>
* <li>JsonReader allows the literals {@code true}, {@code false} and {@code null}
Expand All @@ -340,16 +340,15 @@ public final boolean isLenient() {
* <li>JsonReader supports the escape sequence <code>\<i>LF</i></code> (with {@code LF}
* being the Unicode character U+000A), resulting in a {@code LF} within the
* read JSON string
* <li>JsonReader allows unescaped control characters (U+0000 through U+001F)
* <li>JsonReader allows unescaped control characters (U+0000 through U+001F)
* </ul>
* </dd>
* <dt>{@link Strictness#LENIENT}</dt>
* <dd>
* In lenient mode, all input that is accepted in default mode is accepted in addition to the following
* departures from <a href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>:
* departures from <a href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>:
* <ul>
* <li>Streams that start with the <a href="#nonexecuteprefix">non-execute prefix</a>, <code>")]}'\n"
* </code>.
* <li>Streams that start with the <a href="#nonexecuteprefix">non-execute prefix</a>, {@code ")]}'\n"}
* <li>Streams that include multiple top-level values. With default or strict parsing,
* each stream must contain exactly one top-level value.
* <li>Numbers may be {@link Double#isNaN() NaNs} or {@link Double#isInfinite() infinities} represented by
Expand All @@ -370,7 +369,7 @@ public final boolean isLenient() {
* </dl>
*
* @param strictness the new strictness value of this reader. May not be null.
* @throws NullPointerException if the provided <code>strictness</code> is <code>null</code>.
* @throws NullPointerException if the provided {@code strictness} is {@code null}.
* @since $next-version$
*/
public final void setStrictness(Strictness strictness) {
Expand All @@ -379,7 +378,7 @@ public final void setStrictness(Strictness strictness) {
}

/**
* Returns the {@linkplain Strictness strictness} of this writer.
* Returns the {@linkplain Strictness strictness} of this reader.
*
* @see #setStrictness(Strictness)
* @since $next-version$
Expand Down Expand Up @@ -678,7 +677,7 @@ private int peekKeyword() throws IOException {
// any upper case letters in the buffer are not matched
keywordUpper = strictness == Strictness.STRICT ? keyword : keyword.toUpperCase();

// Confirm that chars [1..length) match the keyword.
// Confirm that chars [0..length) match the keyword.
int length = keyword.length();
for (int i = 0; i < length; i++) {
if (pos + i >= limit && !fillBuffer(i + 1)) {
Expand Down
9 changes: 5 additions & 4 deletions gson/src/main/java/com/google/gson/stream/JsonWriter.java
Expand Up @@ -269,7 +269,7 @@ public final void setLenient(boolean lenient) {
}

/**
* Returns true if this writer has a <code>strictness</code> value of {@link Strictness#LENIENT}, false otherwise.
* Returns true if this writer has a {@code strictness} value of {@link Strictness#LENIENT}, false otherwise.
*
* @see JsonWriter#setStrictness(Strictness)
*/
Expand All @@ -284,13 +284,14 @@ public boolean isLenient() {
* <ul>
* <li>{@link Strictness#DEFAULT} and {@link Strictness#STRICT}: The behavior of these
* is currently identical. In these strictness modes, the writer only writes JSON in accordance to
* <a href="http://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>.</li>
* <a href="https://www.ietf.org/rfc/rfc8259.txt">RFC 8259</a>.</li>
* <li>{@link Strictness#LENIENT}: This mode relaxes the behavior of the writer to allow the writing of
* {@link Double#isNaN() NaNs} and {@link Double#isInfinite() infinities}.</li>
* {@link Double#isNaN() NaNs} and {@link Double#isInfinite() infinities}. It also allows you
* writing JSON objects with multiple top level values.</li>
* </ul>
*
* @param strictness the new strictness of this writer. May not be null.
* @throws NullPointerException A null pointer exception is thrown if the provided <code>strictness</code> is null.
* @throws NullPointerException A null pointer exception is thrown if the provided {@code strictness} is {@code null}.
* @since $next-version$
*/
public final void setStrictness(Strictness strictness) {
Expand Down

0 comments on commit 6a27a65

Please sign in to comment.