Port the build to Gradle

Closes gh-19609
Closes gh-19608
This commit is contained in:
Andy Wilkinson
2020-01-10 13:48:43 +00:00
parent abe95fa8a7
commit ce99db1902
974 changed files with 17108 additions and 26596 deletions

View File

@@ -102,24 +102,21 @@ class JSON {
return null;
}
public static JSONException typeMismatch(Object indexOrName, Object actual,
String requiredType) throws JSONException {
public static JSONException typeMismatch(Object indexOrName, Object actual, String requiredType)
throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
}
throw new JSONException("Value " + actual + " at " + indexOrName + " of type "
+ actual.getClass().getName() + " cannot be converted to "
+ requiredType);
throw new JSONException("Value " + actual + " at " + indexOrName + " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
public static JSONException typeMismatch(Object actual, String requiredType)
throws JSONException {
public static JSONException typeMismatch(Object actual, String requiredType) throws JSONException {
if (actual == null) {
throw new JSONException("Value is null.");
}
throw new JSONException(
"Value " + actual + " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
throw new JSONException("Value " + actual + " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
}
}

View File

@@ -127,7 +127,6 @@ public class JSONArray {
/**
* Appends {@code value} to the end of this array.
*
* @param value the value
* @return this array.
*/
@@ -138,7 +137,6 @@ public class JSONArray {
/**
* Appends {@code value} to the end of this array.
*
* @param value a finite value. May not be {@link Double#isNaN() NaNs} or
* {@link Double#isInfinite() infinities}.
* @return this array.
@@ -171,7 +169,6 @@ public class JSONArray {
/**
* Appends {@code value} to the end of this array.
*
* @param value a {@link JSONObject}, {@link JSONArray}, String, Boolean, Integer,
* Long, Double, {@link JSONObject#NULL}, or {@code null}. May not be
* {@link Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. Unsupported
@@ -288,8 +285,7 @@ public class JSONArray {
return value;
}
catch (IndexOutOfBoundsException e) {
throw new JSONException(
"Index " + index + " out of range [0.." + this.values.size() + ")");
throw new JSONException("Index " + index + " out of range [0.." + this.values.size() + ")");
}
}
@@ -444,7 +440,6 @@ public class JSONArray {
* a long.
* @param index the index to get the value from
* @return the {@code value}
*
* @throws JSONException if the value at {@code index} doesn't exist or cannot be
* coerced to a long.
*/
@@ -642,7 +637,6 @@ public class JSONArray {
* 94043,
* 90210
* ]</pre>
*
* @param indentSpaces the number of spaces to indent for each level of nesting.
* @return a human readable JSON string of this array
* @throws JSONException if processing of json failed

View File

@@ -41,11 +41,11 @@ import java.util.Map;
* <li>When the requested type is an int, other {@link Number} types will be coerced using
* {@link Number#intValue() intValue}. Strings that can be coerced using
* {@link Double#valueOf(String)} will be, and then cast to int.
* <li><a id="lossy">When the requested type is a long, other {@link Number} types will
* be coerced using {@link Number#longValue() longValue}. Strings that can be coerced
* using {@link Double#valueOf(String)} will be, and then cast to long. This two-step
* conversion is lossy for very large values. For example, the string
* "9223372036854775806" yields the long 9223372036854775807.</a>
* <li><a id="lossy">When the requested type is a long, other {@link Number} types will be
* coerced using {@link Number#longValue() longValue}. Strings that can be coerced using
* {@link Double#valueOf(String)} will be, and then cast to long. This two-step conversion
* is lossy for very large values. For example, the string "9223372036854775806" yields
* the long 9223372036854775807.</a>
* <li>When the requested type is a String, other non-null values will be coerced using
* {@link String#valueOf(Object)}. Although null cannot be coerced, the sentinel value
* {@link JSONObject#NULL} is coerced to the string "null".
@@ -117,7 +117,6 @@ public class JSONObject {
/**
* Creates a new {@code JSONObject} by copying all name/value mappings from the given
* map.
*
* @param copyFrom a map whose keys are of type {@link String} and whose values are of
* supported types.
* @throws NullPointerException if any of the map's keys are null.
@@ -334,7 +333,6 @@ public class JSONObject {
/**
* Removes the named mapping if it exists; does nothing otherwise.
*
* @param name the name of the property
* @return the value previously mapped by {@code name}, or null if there was no such
* mapping.
@@ -430,7 +428,6 @@ public class JSONObject {
/**
* Returns the value mapped by {@code name} if it exists and is a double or can be
* coerced to a double.
*
* @param name the name of the property
* @return the value
* @throws JSONException if the mapping doesn't exist or cannot be coerced to a
@@ -690,8 +687,7 @@ public class JSONObject {
* @return the array
*/
public JSONArray names() {
return this.nameValuePairs.isEmpty() ? null
: new JSONArray(new ArrayList<>(this.nameValuePairs.keySet()));
return this.nameValuePairs.isEmpty() ? null : new JSONArray(new ArrayList<>(this.nameValuePairs.keySet()));
}
/**
@@ -823,9 +819,9 @@ public class JSONObject {
if (o instanceof Map) {
return new JSONObject((Map) o);
}
if (o instanceof Boolean || o instanceof Byte || o instanceof Character
|| o instanceof Double || o instanceof Float || o instanceof Integer
|| o instanceof Long || o instanceof Short || o instanceof String) {
if (o instanceof Boolean || o instanceof Byte || o instanceof Character || o instanceof Double
|| o instanceof Float || o instanceof Integer || o instanceof Long || o instanceof Short
|| o instanceof String) {
return o;
}
if (o.getClass().getPackage().getName().startsWith("java.")) {

View File

@@ -191,8 +191,7 @@ public class JSONStringer {
* @return the JSON stringer
* @throws JSONException if processing of json failed
*/
JSONStringer close(Scope empty, Scope nonempty, String closeBracket)
throws JSONException {
JSONStringer close(Scope empty, Scope nonempty, String closeBracket) throws JSONException {
Scope context = peek();
if (context != nonempty && context != empty) {
throw new JSONException("Nesting problem");

View File

@@ -375,8 +375,8 @@ public class JSONTokener {
throw syntaxError("Names cannot be null");
}
else {
throw syntaxError("Names must be strings, but " + name
+ " is of type " + name.getClass().getName());
throw syntaxError(
"Names must be strings, but " + name + " is of type " + name.getClass().getName());
}
}