This commit is contained in:
Daniel Mills
2021-07-16 02:25:35 -04:00
parent 22387b2610
commit 71140381e0
198 changed files with 1033 additions and 1146 deletions

View File

@@ -19,9 +19,6 @@
package com.volmit.iris.util.json;
import com.volmit.iris.util.json.JSONException;
import com.volmit.iris.util.json.JSONTokener;
/**
* The HTTPTokener extends the JSONTokener to provide additional methods for the
* parsing of HTTP headers.

View File

@@ -261,7 +261,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return new BigDecimal(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] could not convert to BigDecimal.");
}
}
@@ -278,7 +279,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return new BigInteger(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] could not convert to BigInteger.");
}
}
@@ -294,7 +296,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@@ -343,7 +346,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@@ -438,7 +442,8 @@ public class JSONArray implements Iterable<Object> {
public boolean optBoolean(int index, boolean defaultValue) {
try {
return this.getBoolean(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -467,7 +472,8 @@ public class JSONArray implements Iterable<Object> {
public double optDouble(int index, double defaultValue) {
try {
return this.getDouble(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -496,7 +502,8 @@ public class JSONArray implements Iterable<Object> {
public int optInt(int index, int defaultValue) {
try {
return this.getInt(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -534,9 +541,11 @@ public class JSONArray implements Iterable<Object> {
return myE;
}
return Enum.valueOf(clazz, val.toString());
} catch (IllegalArgumentException e) {Iris.reportError(e);
} catch (IllegalArgumentException e) {
Iris.reportError(e);
return defaultValue;
} catch (NullPointerException e) {Iris.reportError(e);
} catch (NullPointerException e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -553,7 +562,8 @@ public class JSONArray implements Iterable<Object> {
public BigInteger optBigInteger(int index, BigInteger defaultValue) {
try {
return this.getBigInteger(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -570,7 +580,8 @@ public class JSONArray implements Iterable<Object> {
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) {
try {
return this.getBigDecimal(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -624,7 +635,8 @@ public class JSONArray implements Iterable<Object> {
public long optLong(int index, long defaultValue) {
try {
return this.getLong(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -937,7 +949,8 @@ public class JSONArray implements Iterable<Object> {
public String toString() {
try {
return this.toString(0);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return null;
}
}

View File

@@ -283,7 +283,8 @@ public class JSONObject {
String name = names[i];
try {
this.putOpt(name, c.getField(name).get(object));
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
}
@@ -491,7 +492,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return new BigInteger(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigInteger.");
}
}
@@ -508,7 +510,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return new BigDecimal(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigDecimal.");
}
}
@@ -525,7 +528,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] is not a number.");
}
}
@@ -542,7 +546,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
}
}
@@ -589,7 +594,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
}
}
@@ -818,9 +824,11 @@ public class JSONObject {
return myE;
}
return Enum.valueOf(clazz, val.toString());
} catch (IllegalArgumentException e) {Iris.reportError(e);
} catch (IllegalArgumentException e) {
Iris.reportError(e);
return defaultValue;
} catch (NullPointerException e) {Iris.reportError(e);
} catch (NullPointerException e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -848,7 +856,8 @@ public class JSONObject {
public boolean optBoolean(String key, boolean defaultValue) {
try {
return this.getBoolean(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -877,7 +886,8 @@ public class JSONObject {
public BigInteger optBigInteger(String key, BigInteger defaultValue) {
try {
return this.getBigInteger(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -894,7 +904,8 @@ public class JSONObject {
public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
try {
return this.getBigDecimal(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -911,7 +922,8 @@ public class JSONObject {
public double optDouble(String key, double defaultValue) {
try {
return this.getDouble(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -940,7 +952,8 @@ public class JSONObject {
public int optInt(String key, int defaultValue) {
try {
return this.getInt(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -993,7 +1006,8 @@ public class JSONObject {
public long optLong(String key, long defaultValue) {
try {
return this.getLong(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -1059,7 +1073,8 @@ public class JSONObject {
}
}
}
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
}
@@ -1220,7 +1235,8 @@ public class JSONObject {
synchronized (sw.getBuffer()) {
try {
return quote(string, sw).toString();
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
// will never happen - we are writing to a string writer
return "";
}
@@ -1331,7 +1347,8 @@ public class JSONObject {
}
}
return true;
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
return false;
}
}
@@ -1381,7 +1398,8 @@ public class JSONObject {
}
}
}
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
return string;
@@ -1442,7 +1460,8 @@ public class JSONObject {
public String toString() {
try {
return this.toString(0);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return null;
}
}
@@ -1496,7 +1515,8 @@ public class JSONObject {
Object object;
try {
object = ((JSONString) value).toJSONString();
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException(e);
}
if (object instanceof String) {
@@ -1565,7 +1585,8 @@ public class JSONObject {
return object.toString();
}
return new JSONObject(object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return null;
}
}
@@ -1608,7 +1629,8 @@ public class JSONObject {
Object o;
try {
o = ((JSONString) value).toJSONString();
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException(e);
}
writer.write(o != null ? o.toString() : quote(value.toString()));
@@ -1674,7 +1696,8 @@ public class JSONObject {
}
writer.write('}');
return writer;
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
}

View File

@@ -398,7 +398,8 @@ public class JSONTokener {
return c;
}
} while (c != to);
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
this.back();

View File

@@ -163,7 +163,8 @@ public class JSONWriter {
this.pop(mode);
try {
this.writer.write(c);
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
this.comma = true;
@@ -216,7 +217,8 @@ public class JSONWriter {
this.comma = false;
this.mode = 'o';
return this;
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
}

View File

@@ -330,7 +330,8 @@ public class XML {
if (value.toString().equals(string)) {
return value;
}
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
return string;