first commit
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
Build AsminVoicechat / prepare-release (push) Successful in 14s
Build AsminVoicechat / build-and-test (17) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (18) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (19) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (20) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (21) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (22) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (23) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (24) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (25) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (26) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (27-ea) (push) Canceled after 0s
Build AsminVoicechat / build-and-test (16) (push) Canceled after 38s
This commit is contained in:
commit
bbccd4a815
454 files changed
+45050
No files matched your search
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONArray;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONTokener;
|
||||
|
||||
public class CDL {
|
||||
@Deprecated
|
||||
public CDL() {
|
||||
}
|
||||
|
||||
private static String getValue(JSONTokener x, char delimiter) throws JSONException {
|
||||
char c;
|
||||
while ((c = x.next()) == ' ' || c == '\t') {
|
||||
}
|
||||
if (c == '\u0000') {
|
||||
return null;
|
||||
}
|
||||
if (c == '\"' || c == '\'') {
|
||||
char q = c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
char nextC;
|
||||
if ((c = x.next()) == q && (nextC = x.next()) != '\"') {
|
||||
if (nextC <= '\u0000') break;
|
||||
x.back();
|
||||
break;
|
||||
}
|
||||
if (c == '\u0000' || c == '\n' || c == '\r') {
|
||||
throw x.syntaxError("Missing close quote '" + q + "'.");
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
if (c == delimiter) {
|
||||
x.back();
|
||||
return "";
|
||||
}
|
||||
x.back();
|
||||
return x.nextTo(delimiter);
|
||||
}
|
||||
|
||||
public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
|
||||
return CDL.rowToJSONArray(x, ',');
|
||||
}
|
||||
|
||||
public static JSONArray rowToJSONArray(JSONTokener x, char delimiter) throws JSONException {
|
||||
JSONArray ja = new JSONArray();
|
||||
block0: while (true) {
|
||||
String value = CDL.getValue(x, delimiter);
|
||||
char c = x.next();
|
||||
if (value != null) {
|
||||
ja.put(value);
|
||||
} else {
|
||||
if (ja.length() == 0 && c != delimiter) {
|
||||
return null;
|
||||
}
|
||||
ja.put("");
|
||||
}
|
||||
while (true) {
|
||||
if (c == delimiter) continue block0;
|
||||
if (c != ' ') {
|
||||
if (c == '\n' || c == '\r' || c == '\u0000') {
|
||||
return ja;
|
||||
}
|
||||
throw x.syntaxError("Bad character '" + c + "' (" + c + ").");
|
||||
}
|
||||
c = x.next();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException {
|
||||
return CDL.rowToJSONObject(names, x, ',');
|
||||
}
|
||||
|
||||
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x, char delimiter) throws JSONException {
|
||||
JSONArray ja = CDL.rowToJSONArray(x, delimiter);
|
||||
return ja != null ? ja.toJSONObject(names) : null;
|
||||
}
|
||||
|
||||
public static String rowToString(JSONArray ja) {
|
||||
return CDL.rowToString(ja, ',');
|
||||
}
|
||||
|
||||
public static String rowToString(JSONArray ja, char delimiter) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < ja.length(); ++i) {
|
||||
Object object;
|
||||
if (i > 0) {
|
||||
sb.append(delimiter);
|
||||
}
|
||||
if ((object = ja.opt(i)) == null) continue;
|
||||
String string = object.toString();
|
||||
if (!(string.isEmpty() || string.indexOf(delimiter) < 0 && string.indexOf(10) < 0 && string.indexOf(13) < 0 && string.indexOf(0) < 0 && string.charAt(0) != '\"')) {
|
||||
sb.append('\"');
|
||||
int length = string.length();
|
||||
for (int j = 0; j < length; ++j) {
|
||||
char c = string.charAt(j);
|
||||
if (c < ' ' || c == '\"') continue;
|
||||
sb.append(c);
|
||||
}
|
||||
sb.append('\"');
|
||||
continue;
|
||||
}
|
||||
sb.append(string);
|
||||
}
|
||||
sb.append('\n');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(String string) throws JSONException {
|
||||
return CDL.toJSONArray(string, ',');
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(String string, char delimiter) throws JSONException {
|
||||
return CDL.toJSONArray(new JSONTokener(string), delimiter);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
|
||||
return CDL.toJSONArray(x, ',');
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(JSONTokener x, char delimiter) throws JSONException {
|
||||
return CDL.toJSONArray(CDL.rowToJSONArray(x, delimiter), x, delimiter);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(JSONArray names, String string) throws JSONException {
|
||||
return CDL.toJSONArray(names, string, ',');
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(JSONArray names, String string, char delimiter) throws JSONException {
|
||||
return CDL.toJSONArray(names, new JSONTokener(string), delimiter);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException {
|
||||
return CDL.toJSONArray(names, x, ',');
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(JSONArray names, JSONTokener x, char delimiter) throws JSONException {
|
||||
String key;
|
||||
JSONObject j;
|
||||
JSONObject jo;
|
||||
if (names == null || names.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
JSONArray ja = new JSONArray();
|
||||
while ((jo = CDL.rowToJSONObject(names, x, delimiter)) != null) {
|
||||
ja.put(jo);
|
||||
}
|
||||
if (ja.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (ja.length() == 1 && (j = ja.getJSONObject(0)).length() == 1 && "".equals(key = j.keys().next()) && "".equals(j.get(key))) {
|
||||
return null;
|
||||
}
|
||||
return ja;
|
||||
}
|
||||
|
||||
public static String toString(JSONArray ja) throws JSONException {
|
||||
return CDL.toString(ja, ',');
|
||||
}
|
||||
|
||||
public static String toString(JSONArray ja, char delimiter) throws JSONException {
|
||||
JSONArray names;
|
||||
JSONObject jo = ja.optJSONObject(0);
|
||||
if (jo != null && (names = jo.names()) != null) {
|
||||
return CDL.rowToString(names, delimiter) + CDL.toString(names, ja, delimiter);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String toString(JSONArray names, JSONArray ja) throws JSONException {
|
||||
return CDL.toString(names, ja, ',');
|
||||
}
|
||||
|
||||
public static String toString(JSONArray names, JSONArray ja, char delimiter) throws JSONException {
|
||||
if (names == null || names.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < ja.length(); ++i) {
|
||||
JSONObject jo = ja.optJSONObject(i);
|
||||
if (jo == null) continue;
|
||||
sb.append(CDL.rowToString(jo.toJSONArray(names), delimiter));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONTokener;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Cookie {
|
||||
@Deprecated
|
||||
public Cookie() {
|
||||
}
|
||||
|
||||
public static String escape(String string) {
|
||||
String s = string.trim();
|
||||
int length = s.length();
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
char c = s.charAt(i);
|
||||
if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
|
||||
sb.append('%');
|
||||
sb.append(Character.forDigit((char)(c >>> 4 & 0xF), 16));
|
||||
sb.append(Character.forDigit((char)(c & 0xF), 16));
|
||||
continue;
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string) {
|
||||
JSONObject jo = new JSONObject();
|
||||
JSONTokener x = new JSONTokener(string);
|
||||
String name = Cookie.unescape(x.nextTo('=').trim());
|
||||
if ("".equals(name)) {
|
||||
throw new JSONException("Cookies must have a 'name'");
|
||||
}
|
||||
jo.put("name", name);
|
||||
x.next('=');
|
||||
jo.put("value", Cookie.unescape(x.nextTo(';')).trim());
|
||||
x.next();
|
||||
while (x.more()) {
|
||||
Object value;
|
||||
name = Cookie.unescape(x.nextTo("=;")).trim().toLowerCase(Locale.ROOT);
|
||||
if ("name".equalsIgnoreCase(name)) {
|
||||
throw new JSONException("Illegal attribute name: 'name'");
|
||||
}
|
||||
if ("value".equalsIgnoreCase(name)) {
|
||||
throw new JSONException("Illegal attribute name: 'value'");
|
||||
}
|
||||
if (x.next() != '=') {
|
||||
value = Boolean.TRUE;
|
||||
} else {
|
||||
value = Cookie.unescape(x.nextTo(';')).trim();
|
||||
x.next();
|
||||
}
|
||||
if ("".equals(name) || "".equals(value)) continue;
|
||||
jo.put(name, value);
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String name = null;
|
||||
Object value = null;
|
||||
for (String key : jo.keySet()) {
|
||||
if ("name".equalsIgnoreCase(key)) {
|
||||
name = jo.getString(key).trim();
|
||||
}
|
||||
if ("value".equalsIgnoreCase(key)) {
|
||||
value = jo.getString(key).trim();
|
||||
}
|
||||
if (name == null || value == null) continue;
|
||||
break;
|
||||
}
|
||||
if (name == null || "".equals(name.trim())) {
|
||||
throw new JSONException("Cookie does not have a name");
|
||||
}
|
||||
if (value == null) {
|
||||
value = "";
|
||||
}
|
||||
sb.append(Cookie.escape(name));
|
||||
sb.append("=");
|
||||
sb.append(Cookie.escape((String)value));
|
||||
for (String key : jo.keySet()) {
|
||||
if ("name".equalsIgnoreCase(key) || "value".equalsIgnoreCase(key)) continue;
|
||||
value = jo.opt(key);
|
||||
if (value instanceof Boolean) {
|
||||
if (!Boolean.TRUE.equals(value)) continue;
|
||||
sb.append(';').append(Cookie.escape(key));
|
||||
continue;
|
||||
}
|
||||
sb.append(';').append(Cookie.escape(key)).append('=').append(Cookie.escape(value.toString()));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String unescape(String string) {
|
||||
int length = string.length();
|
||||
StringBuilder sb = new StringBuilder(length);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
char c = string.charAt(i);
|
||||
if (c == '+') {
|
||||
c = ' ';
|
||||
} else if (c == '%' && i + 2 < length) {
|
||||
int d = JSONTokener.dehexchar(string.charAt(i + 1));
|
||||
int e = JSONTokener.dehexchar(string.charAt(i + 2));
|
||||
if (d >= 0 && e >= 0) {
|
||||
c = (char)(d * 16 + e);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.Cookie;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONTokener;
|
||||
|
||||
public class CookieList {
|
||||
@Deprecated
|
||||
public CookieList() {
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string) throws JSONException {
|
||||
JSONObject jo = new JSONObject();
|
||||
JSONTokener x = new JSONTokener(string);
|
||||
while (x.more()) {
|
||||
String name = Cookie.unescape(x.nextTo('='));
|
||||
x.next('=');
|
||||
jo.put(name, Cookie.unescape(x.nextTo(';')));
|
||||
x.next();
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
boolean isEndOfPair = false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String key : jo.keySet()) {
|
||||
Object value = jo.opt(key);
|
||||
if (JSONObject.NULL.equals(value)) continue;
|
||||
if (isEndOfPair) {
|
||||
sb.append(';');
|
||||
}
|
||||
sb.append(Cookie.escape(key));
|
||||
sb.append("=");
|
||||
sb.append(Cookie.escape(value.toString()));
|
||||
isEndOfPair = true;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.HTTPTokener;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import java.util.Locale;
|
||||
|
||||
public class HTTP {
|
||||
public static final String CRLF = "\r\n";
|
||||
|
||||
public static JSONObject toJSONObject(String string) throws JSONException {
|
||||
JSONObject jo = new JSONObject();
|
||||
HTTPTokener x = new HTTPTokener(string);
|
||||
String token = x.nextToken();
|
||||
if (token.toUpperCase(Locale.ROOT).startsWith("HTTP")) {
|
||||
jo.put("HTTP-Version", token);
|
||||
jo.put("Status-Code", x.nextToken());
|
||||
jo.put("Reason-Phrase", x.nextTo('\u0000'));
|
||||
x.next();
|
||||
} else {
|
||||
jo.put("Method", token);
|
||||
jo.put("Request-URI", x.nextToken());
|
||||
jo.put("HTTP-Version", x.nextToken());
|
||||
}
|
||||
while (x.more()) {
|
||||
String name = x.nextTo(':');
|
||||
x.next(':');
|
||||
jo.put(name, x.nextTo('\u0000'));
|
||||
x.next();
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (jo.has("Status-Code") && jo.has("Reason-Phrase")) {
|
||||
sb.append(jo.getString("HTTP-Version"));
|
||||
sb.append(' ');
|
||||
sb.append(jo.getString("Status-Code"));
|
||||
sb.append(' ');
|
||||
sb.append(jo.getString("Reason-Phrase"));
|
||||
} else if (jo.has("Method") && jo.has("Request-URI")) {
|
||||
sb.append(jo.getString("Method"));
|
||||
sb.append(' ');
|
||||
sb.append('\"');
|
||||
sb.append(jo.getString("Request-URI"));
|
||||
sb.append('\"');
|
||||
sb.append(' ');
|
||||
sb.append(jo.getString("HTTP-Version"));
|
||||
} else {
|
||||
throw new JSONException("Not enough material for an HTTP header.");
|
||||
}
|
||||
sb.append(CRLF);
|
||||
for (String key : jo.keySet()) {
|
||||
String value = jo.optString(key);
|
||||
if ("HTTP-Version".equals(key) || "Status-Code".equals(key) || "Reason-Phrase".equals(key) || "Method".equals(key) || "Request-URI".equals(key) || JSONObject.NULL.equals(value)) continue;
|
||||
sb.append(key);
|
||||
sb.append(": ");
|
||||
sb.append(jo.optString(key));
|
||||
sb.append(CRLF);
|
||||
}
|
||||
sb.append(CRLF);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONTokener;
|
||||
|
||||
public class HTTPTokener
|
||||
extends JSONTokener {
|
||||
public HTTPTokener(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public String nextToken() throws JSONException {
|
||||
char c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (Character.isWhitespace(c = this.next())) {
|
||||
}
|
||||
if (c == '\"' || c == '\'') {
|
||||
char q = c;
|
||||
while (true) {
|
||||
if ((c = this.next()) < ' ') {
|
||||
throw this.syntaxError("Unterminated string.");
|
||||
}
|
||||
if (c == q) {
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
while (c != '\u0000' && !Character.isWhitespace(c)) {
|
||||
sb.append(c);
|
||||
c = this.next();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,855 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONParserConfiguration;
|
||||
import de.maxhenkel.voicechat.org.json.JSONPointer;
|
||||
import de.maxhenkel.voicechat.org.json.JSONPointerException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONString;
|
||||
import de.maxhenkel.voicechat.org.json.JSONTokener;
|
||||
import de.maxhenkel.voicechat.org.json.StringBuilderWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSONArray
|
||||
implements Iterable<Object> {
|
||||
private final ArrayList<Object> myArrayList;
|
||||
|
||||
public JSONArray() {
|
||||
this.myArrayList = new ArrayList();
|
||||
}
|
||||
|
||||
public JSONArray(JSONTokener x) throws JSONException {
|
||||
this(x, x.getJsonParserConfiguration());
|
||||
}
|
||||
|
||||
public JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration) throws JSONException {
|
||||
this();
|
||||
boolean isInitial;
|
||||
boolean bl = isInitial = x.getPrevious() == '\u0000';
|
||||
if (x.nextClean() != '[') {
|
||||
throw x.syntaxError("A JSONArray text must start with '['");
|
||||
}
|
||||
char nextChar = x.nextClean();
|
||||
if (nextChar == '\u0000') {
|
||||
throw x.syntaxError("Expected a ',' or ']'");
|
||||
}
|
||||
if (nextChar == ',' && jsonParserConfiguration.isStrictMode()) {
|
||||
throw x.syntaxError("Array content starts with a ','");
|
||||
}
|
||||
if (nextChar != ']') {
|
||||
x.back();
|
||||
do {
|
||||
if (x.nextClean() == ',') {
|
||||
x.back();
|
||||
this.myArrayList.add(JSONObject.NULL);
|
||||
continue;
|
||||
}
|
||||
x.back();
|
||||
this.myArrayList.add(x.nextValue());
|
||||
} while (!JSONArray.checkForSyntaxError(x, jsonParserConfiguration, isInitial));
|
||||
return;
|
||||
}
|
||||
if (isInitial && jsonParserConfiguration.isStrictMode() && x.nextClean() != '\u0000') {
|
||||
throw x.syntaxError("Strict mode error: Unparsed characters found at end of input text");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkForSyntaxError(JSONTokener x, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) {
|
||||
switch (x.nextClean()) {
|
||||
case '\u0000': {
|
||||
throw x.syntaxError("Expected a ',' or ']'");
|
||||
}
|
||||
case ',': {
|
||||
char nextChar = x.nextClean();
|
||||
if (nextChar == '\u0000') {
|
||||
throw x.syntaxError("Expected a ',' or ']'");
|
||||
}
|
||||
if (nextChar == ']') {
|
||||
if (jsonParserConfiguration.isStrictMode()) {
|
||||
throw x.syntaxError("Strict mode error: Expected another array element");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (nextChar == ',') {
|
||||
if (jsonParserConfiguration.isStrictMode()) {
|
||||
throw x.syntaxError("Strict mode error: Expected a valid array element");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
x.back();
|
||||
break;
|
||||
}
|
||||
case ']': {
|
||||
if (isInitial && jsonParserConfiguration.isStrictMode() && x.nextClean() != '\u0000') {
|
||||
throw x.syntaxError("Strict mode error: Unparsed characters found at end of input text");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
throw x.syntaxError("Expected a ',' or ']'");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public JSONArray(String source) throws JSONException {
|
||||
this(source, new JSONParserConfiguration());
|
||||
}
|
||||
|
||||
public JSONArray(String source, JSONParserConfiguration jsonParserConfiguration) throws JSONException {
|
||||
this(new JSONTokener(source, jsonParserConfiguration), jsonParserConfiguration);
|
||||
}
|
||||
|
||||
public JSONArray(Collection<?> collection) {
|
||||
this(collection, 0, new JSONParserConfiguration());
|
||||
}
|
||||
|
||||
public JSONArray(Collection<?> collection, JSONParserConfiguration jsonParserConfiguration) {
|
||||
this(collection, 0, jsonParserConfiguration);
|
||||
}
|
||||
|
||||
JSONArray(Collection<?> collection, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) {
|
||||
if (recursionDepth > jsonParserConfiguration.getMaxNestingDepth()) {
|
||||
throw new JSONException("JSONArray has reached recursion depth limit of " + jsonParserConfiguration.getMaxNestingDepth());
|
||||
}
|
||||
if (collection == null) {
|
||||
this.myArrayList = new ArrayList();
|
||||
} else {
|
||||
this.myArrayList = new ArrayList(collection.size());
|
||||
this.addAll(collection, true, recursionDepth, jsonParserConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONArray(Iterable<?> iter) {
|
||||
this();
|
||||
if (iter == null) {
|
||||
return;
|
||||
}
|
||||
this.addAll(iter, true);
|
||||
}
|
||||
|
||||
public JSONArray(JSONArray array) {
|
||||
this.myArrayList = array == null ? new ArrayList() : new ArrayList<Object>(array.myArrayList);
|
||||
}
|
||||
|
||||
public JSONArray(Object array) throws JSONException {
|
||||
this();
|
||||
if (!array.getClass().isArray()) {
|
||||
throw new JSONException("JSONArray initial value should be a string or collection or array.");
|
||||
}
|
||||
this.addAll(array, true, 0);
|
||||
}
|
||||
|
||||
public JSONArray(int initialCapacity) throws JSONException {
|
||||
if (initialCapacity < 0) {
|
||||
throw new JSONException("JSONArray initial capacity cannot be negative.");
|
||||
}
|
||||
this.myArrayList = new ArrayList(initialCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return this.myArrayList.iterator();
|
||||
}
|
||||
|
||||
public Object get(int index) throws JSONException {
|
||||
Object object = this.opt(index);
|
||||
if (object == null) {
|
||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public boolean getBoolean(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (Boolean.FALSE.equals(object) || object instanceof String && "false".equalsIgnoreCase((String)object)) {
|
||||
return false;
|
||||
}
|
||||
if (Boolean.TRUE.equals(object) || object instanceof String && "true".equalsIgnoreCase((String)object)) {
|
||||
return true;
|
||||
}
|
||||
throw JSONArray.wrongValueFormatException(index, "boolean", object, null);
|
||||
}
|
||||
|
||||
public double getDouble(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof Number) {
|
||||
return ((Number)object).doubleValue();
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(object.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw JSONArray.wrongValueFormatException(index, "double", object, e);
|
||||
}
|
||||
}
|
||||
|
||||
public float getFloat(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof Number) {
|
||||
return ((Number)object).floatValue();
|
||||
}
|
||||
try {
|
||||
return Float.parseFloat(object.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw JSONArray.wrongValueFormatException(index, "float", object, e);
|
||||
}
|
||||
}
|
||||
|
||||
public Number getNumber(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
try {
|
||||
if (object instanceof Number) {
|
||||
return (Number)object;
|
||||
}
|
||||
return JSONObject.stringToNumber(object.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw JSONArray.wrongValueFormatException(index, "number", object, e);
|
||||
}
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException {
|
||||
E val = this.optEnum(clazz, index);
|
||||
if (val == null) {
|
||||
throw JSONArray.wrongValueFormatException(index, "enum of type " + JSONObject.quote(clazz.getSimpleName()), this.opt(index), null);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public BigDecimal getBigDecimal(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
BigDecimal val = JSONObject.objectToBigDecimal(object, null);
|
||||
if (val == null) {
|
||||
throw JSONArray.wrongValueFormatException(index, "BigDecimal", object, null);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public BigInteger getBigInteger(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
BigInteger val = JSONObject.objectToBigInteger(object, null);
|
||||
if (val == null) {
|
||||
throw JSONArray.wrongValueFormatException(index, "BigInteger", object, null);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public int getInt(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof Number) {
|
||||
return ((Number)object).intValue();
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(object.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw JSONArray.wrongValueFormatException(index, "int", object, e);
|
||||
}
|
||||
}
|
||||
|
||||
public JSONArray getJSONArray(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof JSONArray) {
|
||||
return (JSONArray)object;
|
||||
}
|
||||
throw JSONArray.wrongValueFormatException(index, "JSONArray", object, null);
|
||||
}
|
||||
|
||||
public JSONObject getJSONObject(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof JSONObject) {
|
||||
return (JSONObject)object;
|
||||
}
|
||||
throw JSONArray.wrongValueFormatException(index, "JSONObject", object, null);
|
||||
}
|
||||
|
||||
public long getLong(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof Number) {
|
||||
return ((Number)object).longValue();
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(object.toString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw JSONArray.wrongValueFormatException(index, "long", object, e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof String) {
|
||||
return (String)object;
|
||||
}
|
||||
throw JSONArray.wrongValueFormatException(index, "String", object, null);
|
||||
}
|
||||
|
||||
public boolean isNull(int index) {
|
||||
return JSONObject.NULL.equals(this.opt(index));
|
||||
}
|
||||
|
||||
public String join(String separator) throws JSONException {
|
||||
int len = this.length();
|
||||
if (len == 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(JSONObject.valueToString(this.myArrayList.get(0)));
|
||||
for (int i = 1; i < len; ++i) {
|
||||
sb.append(separator).append(JSONObject.valueToString(this.myArrayList.get(i)));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return this.myArrayList.size();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.myArrayList.clear();
|
||||
}
|
||||
|
||||
public Object opt(int index) {
|
||||
return index < 0 || index >= this.length() ? null : this.myArrayList.get(index);
|
||||
}
|
||||
|
||||
public boolean optBoolean(int index) {
|
||||
return this.optBoolean(index, false);
|
||||
}
|
||||
|
||||
public boolean optBoolean(int index, boolean defaultValue) {
|
||||
try {
|
||||
return this.getBoolean(index);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean optBooleanObject(int index) {
|
||||
return this.optBooleanObject(index, false);
|
||||
}
|
||||
|
||||
public Boolean optBooleanObject(int index, Boolean defaultValue) {
|
||||
try {
|
||||
return this.getBoolean(index);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public double optDouble(int index) {
|
||||
return this.optDouble(index, Double.NaN);
|
||||
}
|
||||
|
||||
public double optDouble(int index, double defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.doubleValue();
|
||||
}
|
||||
|
||||
public Double optDoubleObject(int index) {
|
||||
return this.optDoubleObject(index, Double.NaN);
|
||||
}
|
||||
|
||||
public Double optDoubleObject(int index, Double defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.doubleValue();
|
||||
}
|
||||
|
||||
public float optFloat(int index) {
|
||||
return this.optFloat(index, Float.NaN);
|
||||
}
|
||||
|
||||
public float optFloat(int index, float defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.floatValue();
|
||||
}
|
||||
|
||||
public Float optFloatObject(int index) {
|
||||
return this.optFloatObject(index, Float.valueOf(Float.NaN));
|
||||
}
|
||||
|
||||
public Float optFloatObject(int index, Float defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Float.valueOf(val.floatValue());
|
||||
}
|
||||
|
||||
public int optInt(int index) {
|
||||
return this.optInt(index, 0);
|
||||
}
|
||||
|
||||
public int optInt(int index, int defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.intValue();
|
||||
}
|
||||
|
||||
public Integer optIntegerObject(int index) {
|
||||
return this.optIntegerObject(index, 0);
|
||||
}
|
||||
|
||||
public Integer optIntegerObject(int index, Integer defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.intValue();
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> E optEnum(Class<E> clazz, int index) {
|
||||
return this.optEnum(clazz, index, null);
|
||||
}
|
||||
|
||||
public <E extends Enum<E>> E optEnum(Class<E> clazz, int index, E defaultValue) {
|
||||
try {
|
||||
Object val = this.opt(index);
|
||||
if (JSONObject.NULL.equals(val)) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (clazz.isAssignableFrom(val.getClass())) {
|
||||
Enum myE = (Enum)val;
|
||||
return (E)myE;
|
||||
}
|
||||
return Enum.valueOf(clazz, val.toString());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public BigInteger optBigInteger(int index, BigInteger defaultValue) {
|
||||
Object val = this.opt(index);
|
||||
return JSONObject.objectToBigInteger(val, defaultValue);
|
||||
}
|
||||
|
||||
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) {
|
||||
Object val = this.opt(index);
|
||||
return JSONObject.objectToBigDecimal(val, defaultValue);
|
||||
}
|
||||
|
||||
public JSONArray optJSONArray(int index) {
|
||||
return this.optJSONArray(index, null);
|
||||
}
|
||||
|
||||
public JSONArray optJSONArray(int index, JSONArray defaultValue) {
|
||||
Object object = this.opt(index);
|
||||
return object instanceof JSONArray ? (JSONArray)object : defaultValue;
|
||||
}
|
||||
|
||||
public JSONObject optJSONObject(int index) {
|
||||
return this.optJSONObject(index, null);
|
||||
}
|
||||
|
||||
public JSONObject optJSONObject(int index, JSONObject defaultValue) {
|
||||
Object object = this.opt(index);
|
||||
return object instanceof JSONObject ? (JSONObject)object : defaultValue;
|
||||
}
|
||||
|
||||
public long optLong(int index) {
|
||||
return this.optLong(index, 0L);
|
||||
}
|
||||
|
||||
public long optLong(int index, long defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.longValue();
|
||||
}
|
||||
|
||||
public Long optLongObject(int index) {
|
||||
return this.optLongObject(index, 0L);
|
||||
}
|
||||
|
||||
public Long optLongObject(int index, Long defaultValue) {
|
||||
Number val = this.optNumber(index, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return val.longValue();
|
||||
}
|
||||
|
||||
public Number optNumber(int index) {
|
||||
return this.optNumber(index, null);
|
||||
}
|
||||
|
||||
public Number optNumber(int index, Number defaultValue) {
|
||||
Object val = this.opt(index);
|
||||
if (JSONObject.NULL.equals(val)) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (val instanceof Number) {
|
||||
return (Number)val;
|
||||
}
|
||||
if (val instanceof String) {
|
||||
try {
|
||||
return JSONObject.stringToNumber((String)val);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public String optString(int index) {
|
||||
return this.optString(index, "");
|
||||
}
|
||||
|
||||
public String optString(int index, String defaultValue) {
|
||||
Object object = this.opt(index);
|
||||
return JSONObject.NULL.equals(object) ? defaultValue : object.toString();
|
||||
}
|
||||
|
||||
public JSONArray put(boolean value) {
|
||||
return this.put(value ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public JSONArray put(Collection<?> value) {
|
||||
return this.put(new JSONArray(value));
|
||||
}
|
||||
|
||||
public JSONArray put(double value) throws JSONException {
|
||||
return this.put((Object)value);
|
||||
}
|
||||
|
||||
public JSONArray put(float value) throws JSONException {
|
||||
return this.put(Float.valueOf(value));
|
||||
}
|
||||
|
||||
public JSONArray put(int value) {
|
||||
return this.put((Object)value);
|
||||
}
|
||||
|
||||
public JSONArray put(long value) {
|
||||
return this.put((Object)value);
|
||||
}
|
||||
|
||||
public JSONArray put(Map<?, ?> value) {
|
||||
return this.put(new JSONObject(value));
|
||||
}
|
||||
|
||||
public JSONArray put(Object value) {
|
||||
JSONObject.testValidity(value);
|
||||
this.myArrayList.add(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONArray put(int index, boolean value) throws JSONException {
|
||||
return this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public JSONArray put(int index, Collection<?> value) throws JSONException {
|
||||
return this.put(index, new JSONArray(value));
|
||||
}
|
||||
|
||||
public JSONArray put(int index, double value) throws JSONException {
|
||||
return this.put(index, (Object)value);
|
||||
}
|
||||
|
||||
public JSONArray put(int index, float value) throws JSONException {
|
||||
return this.put(index, Float.valueOf(value));
|
||||
}
|
||||
|
||||
public JSONArray put(int index, int value) throws JSONException {
|
||||
return this.put(index, (Object)value);
|
||||
}
|
||||
|
||||
public JSONArray put(int index, long value) throws JSONException {
|
||||
return this.put(index, (Object)value);
|
||||
}
|
||||
|
||||
public JSONArray put(int index, Map<?, ?> value) throws JSONException {
|
||||
this.put(index, new JSONObject(value, new JSONParserConfiguration()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONArray put(int index, Map<?, ?> value, JSONParserConfiguration jsonParserConfiguration) throws JSONException {
|
||||
this.put(index, new JSONObject(value, jsonParserConfiguration));
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONArray put(int index, Object value) throws JSONException {
|
||||
if (index < 0) {
|
||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||
}
|
||||
if (index < this.length()) {
|
||||
JSONObject.testValidity(value);
|
||||
this.myArrayList.set(index, value);
|
||||
return this;
|
||||
}
|
||||
if (index == this.length()) {
|
||||
return this.put(value);
|
||||
}
|
||||
this.myArrayList.ensureCapacity(index + 1);
|
||||
while (index != this.length()) {
|
||||
this.myArrayList.add(JSONObject.NULL);
|
||||
}
|
||||
return this.put(value);
|
||||
}
|
||||
|
||||
public JSONArray putAll(Collection<?> collection) {
|
||||
this.addAll(collection, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONArray putAll(Iterable<?> iter) {
|
||||
this.addAll(iter, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONArray putAll(JSONArray array) {
|
||||
this.myArrayList.addAll(array.myArrayList);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONArray putAll(Object array) throws JSONException {
|
||||
this.addAll(array, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object query(String jsonPointer) {
|
||||
return this.query(new JSONPointer(jsonPointer));
|
||||
}
|
||||
|
||||
public Object query(JSONPointer jsonPointer) {
|
||||
return jsonPointer.queryFrom(this);
|
||||
}
|
||||
|
||||
public Object optQuery(String jsonPointer) {
|
||||
return this.optQuery(new JSONPointer(jsonPointer));
|
||||
}
|
||||
|
||||
public Object optQuery(JSONPointer jsonPointer) {
|
||||
try {
|
||||
return jsonPointer.queryFrom(this);
|
||||
}
|
||||
catch (JSONPointerException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object remove(int index) {
|
||||
return index >= 0 && index < this.length() ? this.myArrayList.remove(index) : null;
|
||||
}
|
||||
|
||||
public boolean similar(Object other) {
|
||||
if (!(other instanceof JSONArray)) {
|
||||
return false;
|
||||
}
|
||||
int len = this.length();
|
||||
if (len != ((JSONArray)other).length()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Object valueOther;
|
||||
Object valueThis = this.myArrayList.get(i);
|
||||
if (valueThis == (valueOther = ((JSONArray)other).myArrayList.get(i))) continue;
|
||||
if (valueThis == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.isSimilar(valueThis, valueOther)) continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isSimilar(Object valueThis, Object valueOther) {
|
||||
return !(valueThis instanceof JSONObject ? !((JSONObject)valueThis).similar(valueOther) : (valueThis instanceof JSONArray ? !((JSONArray)valueThis).similar(valueOther) : (valueThis instanceof Number && valueOther instanceof Number ? !JSONObject.isNumberSimilar((Number)valueThis, (Number)valueOther) : (valueThis instanceof JSONString && valueOther instanceof JSONString ? !((JSONString)valueThis).toJSONString().equals(((JSONString)valueOther).toJSONString()) : !valueThis.equals(valueOther)))));
|
||||
}
|
||||
|
||||
public JSONObject toJSONObject(JSONArray names) throws JSONException {
|
||||
if (names == null || names.isEmpty() || this.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jo = new JSONObject(names.length());
|
||||
for (int i = 0; i < names.length(); ++i) {
|
||||
jo.put(names.getString(i), this.opt(i));
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
return this.toString(0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(int indentFactor) throws JSONException {
|
||||
int initialSize = this.myArrayList.size() * 2;
|
||||
StringBuilderWriter sw = new StringBuilderWriter(Math.max(initialSize, 16));
|
||||
return this.write(sw, indentFactor, 0).toString();
|
||||
}
|
||||
|
||||
public Writer write(Writer writer) throws JSONException {
|
||||
return this.write(writer, 0, 0);
|
||||
}
|
||||
|
||||
public Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
|
||||
try {
|
||||
boolean needsComma = false;
|
||||
int length = this.length();
|
||||
writer.write(91);
|
||||
if (length == 1) {
|
||||
this.writeArrayAttempt(writer, indentFactor, indent, 0);
|
||||
} else if (length != 0) {
|
||||
int newIndent = indent + indentFactor;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (needsComma) {
|
||||
writer.write(44);
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write(10);
|
||||
}
|
||||
JSONObject.indent(writer, newIndent);
|
||||
this.writeArrayAttempt(writer, indentFactor, newIndent, i);
|
||||
needsComma = true;
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write(10);
|
||||
}
|
||||
JSONObject.indent(writer, indent);
|
||||
}
|
||||
writer.write(93);
|
||||
return writer;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeArrayAttempt(Writer writer, int indentFactor, int indent, int i) {
|
||||
try {
|
||||
JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, indent);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new JSONException("Unable to write JSONArray value at index: " + i, e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> toList() {
|
||||
ArrayList<Object> results = new ArrayList<Object>(this.myArrayList.size());
|
||||
for (Object element : this.myArrayList) {
|
||||
if (element == null || JSONObject.NULL.equals(element)) {
|
||||
results.add(null);
|
||||
continue;
|
||||
}
|
||||
if (element instanceof JSONArray) {
|
||||
results.add(((JSONArray)element).toList());
|
||||
continue;
|
||||
}
|
||||
if (element instanceof JSONObject) {
|
||||
results.add(((JSONObject)element).toMap());
|
||||
continue;
|
||||
}
|
||||
results.add(element);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.myArrayList.isEmpty();
|
||||
}
|
||||
|
||||
private void addAll(Collection<?> collection, boolean wrap, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) {
|
||||
this.myArrayList.ensureCapacity(this.myArrayList.size() + collection.size());
|
||||
if (wrap) {
|
||||
for (Object o : collection) {
|
||||
this.put(JSONObject.wrap(o, recursionDepth + 1, jsonParserConfiguration));
|
||||
}
|
||||
} else {
|
||||
for (Object o : collection) {
|
||||
this.put(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addAll(Iterable<?> iter, boolean wrap) {
|
||||
if (wrap) {
|
||||
for (Object o : iter) {
|
||||
this.put(JSONObject.wrap(o));
|
||||
}
|
||||
} else {
|
||||
for (Object o : iter) {
|
||||
this.put(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addAll(Object array, boolean wrap) throws JSONException {
|
||||
this.addAll(array, wrap, 0);
|
||||
}
|
||||
|
||||
private void addAll(Object array, boolean wrap, int recursionDepth) {
|
||||
this.addAll(array, wrap, recursionDepth, new JSONParserConfiguration());
|
||||
}
|
||||
|
||||
private void addAll(Object array, boolean wrap, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) throws JSONException {
|
||||
if (array.getClass().isArray()) {
|
||||
int length = Array.getLength(array);
|
||||
this.myArrayList.ensureCapacity(this.myArrayList.size() + length);
|
||||
if (wrap) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
this.put(JSONObject.wrap(Array.get(array, i), recursionDepth + 1, jsonParserConfiguration));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
this.put(Array.get(array, i));
|
||||
}
|
||||
}
|
||||
} else if (array instanceof JSONArray) {
|
||||
this.myArrayList.addAll(((JSONArray)array).myArrayList);
|
||||
} else if (array instanceof Collection) {
|
||||
this.addAll((Collection)array, wrap, recursionDepth, jsonParserConfiguration);
|
||||
} else if (array instanceof Iterable) {
|
||||
this.addAll((Iterable)array, wrap);
|
||||
} else {
|
||||
throw new JSONException("JSONArray initial value should be a string or collection or array.");
|
||||
}
|
||||
}
|
||||
|
||||
private static JSONException wrongValueFormatException(int idx, String valueType, Object value, Throwable cause) {
|
||||
if (value == null) {
|
||||
return new JSONException("JSONArray[" + idx + "] is not a " + valueType + " (null).", cause);
|
||||
}
|
||||
if (value instanceof Map || value instanceof Iterable || value instanceof JSONObject) {
|
||||
return new JSONException("JSONArray[" + idx + "] is not a " + valueType + " (" + value.getClass() + ").", cause);
|
||||
}
|
||||
return new JSONException("JSONArray[" + idx + "] is not a " + valueType + " (" + value.getClass() + " : " + value + ").", cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
public class JSONException
|
||||
extends RuntimeException {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
public JSONException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public JSONException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public JSONException(Throwable cause) {
|
||||
super(cause.getMessage(), cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONArray;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONMLParserConfiguration;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.XML;
|
||||
import de.maxhenkel.voicechat.org.json.XMLTokener;
|
||||
|
||||
public class JSONML {
|
||||
@Deprecated
|
||||
public JSONML() {
|
||||
}
|
||||
|
||||
private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja, boolean keepStrings, int currentNestingDepth) throws JSONException {
|
||||
return JSONML.parse(x, arrayForm, ja, keepStrings ? JSONMLParserConfiguration.KEEP_STRINGS : JSONMLParserConfiguration.ORIGINAL, currentNestingDepth);
|
||||
}
|
||||
|
||||
private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja, JSONMLParserConfiguration config, int currentNestingDepth) throws JSONException {
|
||||
String closeTag = null;
|
||||
JSONArray newja = null;
|
||||
JSONObject newjo = null;
|
||||
String tagName = null;
|
||||
while (true) {
|
||||
Object value;
|
||||
if (!x.more()) {
|
||||
throw x.syntaxError("Bad XML");
|
||||
}
|
||||
Object token = x.nextContent();
|
||||
if (token == XML.LT) {
|
||||
token = x.nextToken();
|
||||
if (token instanceof Character) {
|
||||
if (token == XML.SLASH) {
|
||||
token = x.nextToken();
|
||||
if (!(token instanceof String)) {
|
||||
throw new JSONException("Expected a closing name instead of '" + token + "'.");
|
||||
}
|
||||
if (x.nextToken() != XML.GT) {
|
||||
throw x.syntaxError("Misshaped close tag");
|
||||
}
|
||||
return token;
|
||||
}
|
||||
if (token == XML.BANG) {
|
||||
char c = x.next();
|
||||
if (c == '-') {
|
||||
if (x.next() == '-') {
|
||||
x.skipPast("-->");
|
||||
continue;
|
||||
}
|
||||
x.back();
|
||||
continue;
|
||||
}
|
||||
if (c == '[') {
|
||||
token = x.nextToken();
|
||||
if ("CDATA".equals(token) && x.next() == '[') {
|
||||
if (ja == null) continue;
|
||||
ja.put(x.nextCDATA());
|
||||
continue;
|
||||
}
|
||||
throw x.syntaxError("Expected 'CDATA['");
|
||||
}
|
||||
int i = 1;
|
||||
do {
|
||||
if ((token = x.nextMeta()) == null) {
|
||||
throw x.syntaxError("Missing '>' after '<!'.");
|
||||
}
|
||||
if (token == XML.LT) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if (token != XML.GT) continue;
|
||||
--i;
|
||||
} while (i > 0);
|
||||
continue;
|
||||
}
|
||||
if (token == XML.QUEST) {
|
||||
x.skipPast("?>");
|
||||
continue;
|
||||
}
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if (!(token instanceof String)) {
|
||||
throw x.syntaxError("Bad tagName '" + token + "'.");
|
||||
}
|
||||
tagName = (String)token;
|
||||
newja = new JSONArray();
|
||||
newjo = new JSONObject();
|
||||
if (arrayForm) {
|
||||
newja.put(tagName);
|
||||
if (ja != null) {
|
||||
ja.put(newja);
|
||||
}
|
||||
} else {
|
||||
newjo.put("tagName", tagName);
|
||||
if (ja != null) {
|
||||
ja.put(newjo);
|
||||
}
|
||||
}
|
||||
token = null;
|
||||
while (true) {
|
||||
if (token == null) {
|
||||
token = x.nextToken();
|
||||
}
|
||||
if (token == null) {
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if (!(token instanceof String)) break;
|
||||
String attribute = (String)token;
|
||||
if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
|
||||
throw x.syntaxError("Reserved attribute.");
|
||||
}
|
||||
token = x.nextToken();
|
||||
if (token == XML.EQ) {
|
||||
token = x.nextToken();
|
||||
if (!(token instanceof String)) {
|
||||
throw x.syntaxError("Missing value");
|
||||
}
|
||||
newjo.accumulate(attribute, config.isKeepStrings() ? (String)token : XML.stringToValue((String)token));
|
||||
token = null;
|
||||
continue;
|
||||
}
|
||||
newjo.accumulate(attribute, "");
|
||||
}
|
||||
if (arrayForm && newjo.length() > 0) {
|
||||
newja.put(newjo);
|
||||
}
|
||||
if (token == XML.SLASH) {
|
||||
if (x.nextToken() != XML.GT) {
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if (ja != null) continue;
|
||||
if (arrayForm) {
|
||||
return newja;
|
||||
}
|
||||
return newjo;
|
||||
}
|
||||
if (token != XML.GT) {
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if (currentNestingDepth == config.getMaxNestingDepth()) {
|
||||
throw x.syntaxError("Maximum nesting depth of " + config.getMaxNestingDepth() + " reached");
|
||||
}
|
||||
closeTag = (String)JSONML.parse(x, arrayForm, newja, config, currentNestingDepth + 1);
|
||||
if (closeTag == null) continue;
|
||||
if (!closeTag.equals(tagName)) {
|
||||
throw x.syntaxError("Mismatched '" + tagName + "' and '" + closeTag + "'");
|
||||
}
|
||||
tagName = null;
|
||||
if (!arrayForm && newja.length() > 0) {
|
||||
newjo.put("childNodes", newja);
|
||||
}
|
||||
if (ja != null) continue;
|
||||
if (arrayForm) {
|
||||
return newja;
|
||||
}
|
||||
return newjo;
|
||||
}
|
||||
if (ja == null) continue;
|
||||
if (token instanceof String) {
|
||||
String strToken = (String)token;
|
||||
value = config.isKeepStrings() ? XML.unescape(strToken) : XML.stringToValue(strToken);
|
||||
} else {
|
||||
value = token;
|
||||
}
|
||||
ja.put(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(String string) throws JSONException {
|
||||
return (JSONArray)JSONML.parse(new XMLTokener(string), true, null, JSONMLParserConfiguration.ORIGINAL, 0);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(String string, boolean keepStrings) throws JSONException {
|
||||
return (JSONArray)JSONML.parse(new XMLTokener(string), true, null, keepStrings, 0);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(String string, JSONMLParserConfiguration config) throws JSONException {
|
||||
return (JSONArray)JSONML.parse(new XMLTokener(string), true, null, config, 0);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(XMLTokener x, JSONMLParserConfiguration config) throws JSONException {
|
||||
return (JSONArray)JSONML.parse(x, true, null, config, 0);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(XMLTokener x, boolean keepStrings) throws JSONException {
|
||||
return (JSONArray)JSONML.parse(x, true, null, keepStrings, 0);
|
||||
}
|
||||
|
||||
public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
|
||||
return (JSONArray)JSONML.parse(x, true, null, false, 0);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string) throws JSONException {
|
||||
return (JSONObject)JSONML.parse(new XMLTokener(string), false, null, false, 0);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string, boolean keepStrings) throws JSONException {
|
||||
return (JSONObject)JSONML.parse(new XMLTokener(string), false, null, keepStrings, 0);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string, JSONMLParserConfiguration config) throws JSONException {
|
||||
return (JSONObject)JSONML.parse(new XMLTokener(string), false, null, config, 0);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
|
||||
return (JSONObject)JSONML.parse(x, false, null, false, 0);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(XMLTokener x, boolean keepStrings) throws JSONException {
|
||||
return (JSONObject)JSONML.parse(x, false, null, keepStrings, 0);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(XMLTokener x, JSONMLParserConfiguration config) throws JSONException {
|
||||
return (JSONObject)JSONML.parse(x, false, null, config, 0);
|
||||
}
|
||||
|
||||
public static String toString(JSONArray ja) throws JSONException {
|
||||
int length;
|
||||
int i;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String tagName = ja.getString(0);
|
||||
XML.noSpace(tagName);
|
||||
tagName = XML.escape(tagName);
|
||||
sb.append('<');
|
||||
sb.append(tagName);
|
||||
Object object = ja.opt(1);
|
||||
if (object instanceof JSONObject) {
|
||||
i = 2;
|
||||
JSONObject jo = (JSONObject)object;
|
||||
for (String key : jo.keySet()) {
|
||||
Object value = jo.opt(key);
|
||||
XML.noSpace(key);
|
||||
if (value == null) continue;
|
||||
sb.append(' ');
|
||||
sb.append(XML.escape(key));
|
||||
sb.append('=');
|
||||
sb.append('\"');
|
||||
sb.append(XML.escape(value.toString()));
|
||||
sb.append('\"');
|
||||
}
|
||||
} else {
|
||||
i = 1;
|
||||
}
|
||||
if (i >= (length = ja.length())) {
|
||||
sb.append('/');
|
||||
sb.append('>');
|
||||
} else {
|
||||
sb.append('>');
|
||||
do {
|
||||
object = ja.get(i);
|
||||
++i;
|
||||
if (object == null) continue;
|
||||
if (object instanceof String) {
|
||||
sb.append(XML.escape(object.toString()));
|
||||
continue;
|
||||
}
|
||||
if (object instanceof JSONObject) {
|
||||
sb.append(JSONML.toString((JSONObject)object));
|
||||
continue;
|
||||
}
|
||||
if (object instanceof JSONArray) {
|
||||
sb.append(JSONML.toString((JSONArray)object));
|
||||
continue;
|
||||
}
|
||||
sb.append(object.toString());
|
||||
} while (i < length);
|
||||
sb.append('<');
|
||||
sb.append('/');
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String tagName = jo.optString("tagName");
|
||||
if (tagName == null) {
|
||||
return XML.escape(jo.toString());
|
||||
}
|
||||
XML.noSpace(tagName);
|
||||
tagName = XML.escape(tagName);
|
||||
sb.append('<');
|
||||
sb.append(tagName);
|
||||
for (String key : jo.keySet()) {
|
||||
if ("tagName".equals(key) || "childNodes".equals(key)) continue;
|
||||
XML.noSpace(key);
|
||||
Object value = jo.opt(key);
|
||||
if (value == null) continue;
|
||||
sb.append(' ');
|
||||
sb.append(XML.escape(key));
|
||||
sb.append('=');
|
||||
sb.append('\"');
|
||||
sb.append(XML.escape(value.toString()));
|
||||
sb.append('\"');
|
||||
}
|
||||
JSONArray ja = jo.optJSONArray("childNodes");
|
||||
if (ja == null) {
|
||||
sb.append('/');
|
||||
sb.append('>');
|
||||
} else {
|
||||
sb.append('>');
|
||||
int length = ja.length();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
Object object = ja.get(i);
|
||||
if (object == null) continue;
|
||||
if (object instanceof String) {
|
||||
sb.append(XML.escape(object.toString()));
|
||||
continue;
|
||||
}
|
||||
if (object instanceof JSONObject) {
|
||||
sb.append(JSONML.toString((JSONObject)object));
|
||||
continue;
|
||||
}
|
||||
if (object instanceof JSONArray) {
|
||||
sb.append(JSONML.toString((JSONArray)object));
|
||||
continue;
|
||||
}
|
||||
sb.append(object.toString());
|
||||
}
|
||||
sb.append('<');
|
||||
sb.append('/');
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.ParserConfiguration;
|
||||
|
||||
public class JSONMLParserConfiguration
|
||||
extends ParserConfiguration {
|
||||
public static final int DEFAULT_MAXIMUM_NESTING_DEPTH = 512;
|
||||
public static final JSONMLParserConfiguration ORIGINAL = new JSONMLParserConfiguration();
|
||||
public static final JSONMLParserConfiguration KEEP_STRINGS = new JSONMLParserConfiguration().withKeepStrings(true);
|
||||
|
||||
public JSONMLParserConfiguration() {
|
||||
this.maxNestingDepth = 512;
|
||||
}
|
||||
|
||||
protected JSONMLParserConfiguration(boolean keepStrings, int maxNestingDepth) {
|
||||
super(keepStrings, maxNestingDepth);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONMLParserConfiguration clone() {
|
||||
return new JSONMLParserConfiguration(this.keepStrings, this.maxNestingDepth);
|
||||
}
|
||||
|
||||
public JSONMLParserConfiguration withKeepStrings(boolean newVal) {
|
||||
return (JSONMLParserConfiguration)super.withKeepStrings(newVal);
|
||||
}
|
||||
|
||||
public JSONMLParserConfiguration withMaxNestingDepth(int maxNestingDepth) {
|
||||
return (JSONMLParserConfiguration)super.withMaxNestingDepth(maxNestingDepth);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.ParserConfiguration;
|
||||
|
||||
public class JSONParserConfiguration
|
||||
extends ParserConfiguration {
|
||||
private boolean overwriteDuplicateKey = false;
|
||||
private boolean useNativeNulls;
|
||||
private boolean strictMode;
|
||||
|
||||
@Override
|
||||
protected JSONParserConfiguration clone() {
|
||||
JSONParserConfiguration clone = new JSONParserConfiguration();
|
||||
clone.overwriteDuplicateKey = this.overwriteDuplicateKey;
|
||||
clone.strictMode = this.strictMode;
|
||||
clone.maxNestingDepth = this.maxNestingDepth;
|
||||
clone.keepStrings = this.keepStrings;
|
||||
clone.useNativeNulls = this.useNativeNulls;
|
||||
return clone;
|
||||
}
|
||||
|
||||
public JSONParserConfiguration withMaxNestingDepth(int maxNestingDepth) {
|
||||
JSONParserConfiguration clone = this.clone();
|
||||
clone.maxNestingDepth = maxNestingDepth;
|
||||
return clone;
|
||||
}
|
||||
|
||||
public JSONParserConfiguration withOverwriteDuplicateKey(boolean overwriteDuplicateKey) {
|
||||
JSONParserConfiguration clone = this.clone();
|
||||
clone.overwriteDuplicateKey = overwriteDuplicateKey;
|
||||
return clone;
|
||||
}
|
||||
|
||||
public JSONParserConfiguration withUseNativeNulls(boolean useNativeNulls) {
|
||||
JSONParserConfiguration clone = this.clone();
|
||||
clone.useNativeNulls = useNativeNulls;
|
||||
return clone;
|
||||
}
|
||||
|
||||
public JSONParserConfiguration withStrictMode() {
|
||||
return this.withStrictMode(true);
|
||||
}
|
||||
|
||||
public JSONParserConfiguration withStrictMode(boolean mode) {
|
||||
JSONParserConfiguration clone = this.clone();
|
||||
clone.strictMode = mode;
|
||||
return clone;
|
||||
}
|
||||
|
||||
public boolean isOverwriteDuplicateKey() {
|
||||
return this.overwriteDuplicateKey;
|
||||
}
|
||||
|
||||
public boolean isUseNativeNulls() {
|
||||
return this.useNativeNulls;
|
||||
}
|
||||
|
||||
public boolean isStrictMode() {
|
||||
return this.strictMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONArray;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONPointerException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class JSONPointer {
|
||||
private static final String ENCODING = "utf-8";
|
||||
private final List<String> refTokens;
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public JSONPointer(String pointer) {
|
||||
String refs;
|
||||
if (pointer == null) {
|
||||
throw new NullPointerException("pointer cannot be null");
|
||||
}
|
||||
if (pointer.isEmpty() || "#".equals(pointer)) {
|
||||
this.refTokens = Collections.emptyList();
|
||||
return;
|
||||
}
|
||||
if (pointer.startsWith("#/")) {
|
||||
refs = pointer.substring(2);
|
||||
try {
|
||||
refs = URLDecoder.decode(refs, ENCODING);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else if (pointer.startsWith("/")) {
|
||||
refs = pointer.substring(1);
|
||||
} else {
|
||||
throw new IllegalArgumentException("a JSON pointer should start with '/' or '#/'");
|
||||
}
|
||||
this.refTokens = new ArrayList<String>();
|
||||
int slashIdx = -1;
|
||||
int prevSlashIdx = 0;
|
||||
do {
|
||||
String token;
|
||||
if ((prevSlashIdx = slashIdx + 1) == (slashIdx = refs.indexOf(47, prevSlashIdx)) || prevSlashIdx == refs.length()) {
|
||||
this.refTokens.add("");
|
||||
continue;
|
||||
}
|
||||
if (slashIdx >= 0) {
|
||||
token = refs.substring(prevSlashIdx, slashIdx);
|
||||
this.refTokens.add(JSONPointer.unescape(token));
|
||||
continue;
|
||||
}
|
||||
token = refs.substring(prevSlashIdx);
|
||||
this.refTokens.add(JSONPointer.unescape(token));
|
||||
} while (slashIdx >= 0);
|
||||
}
|
||||
|
||||
public JSONPointer(List<String> refTokens) {
|
||||
this.refTokens = new ArrayList<String>(refTokens);
|
||||
}
|
||||
|
||||
private static String unescape(String token) {
|
||||
return token.replace("~1", "/").replace("~0", "~");
|
||||
}
|
||||
|
||||
public Object queryFrom(Object document) throws JSONPointerException {
|
||||
if (this.refTokens.isEmpty()) {
|
||||
return document;
|
||||
}
|
||||
Object current = document;
|
||||
for (String token : this.refTokens) {
|
||||
if (current instanceof JSONObject) {
|
||||
current = ((JSONObject)current).opt(JSONPointer.unescape(token));
|
||||
continue;
|
||||
}
|
||||
if (current instanceof JSONArray) {
|
||||
current = JSONPointer.readByIndexToken(current, token);
|
||||
continue;
|
||||
}
|
||||
throw new JSONPointerException(String.format("value [%s] is not an array or object therefore its key %s cannot be resolved", current, token));
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
private static Object readByIndexToken(Object current, String indexToken) throws JSONPointerException {
|
||||
try {
|
||||
int index = Integer.parseInt(indexToken);
|
||||
JSONArray currentArr = (JSONArray)current;
|
||||
if (index >= currentArr.length()) {
|
||||
throw new JSONPointerException(String.format("index %s is out of bounds - the array has %d elements", indexToken, currentArr.length()));
|
||||
}
|
||||
try {
|
||||
return currentArr.get(index);
|
||||
}
|
||||
catch (JSONException e) {
|
||||
throw new JSONPointerException("Error reading value at index position " + index, e);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
throw new JSONPointerException(String.format("%s is not an array index", indexToken), e);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder rval = new StringBuilder();
|
||||
for (String token : this.refTokens) {
|
||||
rval.append('/').append(JSONPointer.escape(token));
|
||||
}
|
||||
return rval.toString();
|
||||
}
|
||||
|
||||
private static String escape(String token) {
|
||||
return token.replace("~", "~0").replace("/", "~1");
|
||||
}
|
||||
|
||||
public String toURIFragment() {
|
||||
try {
|
||||
StringBuilder rval = new StringBuilder("#");
|
||||
for (String token : this.refTokens) {
|
||||
rval.append('/').append(URLEncoder.encode(token, ENCODING));
|
||||
}
|
||||
return rval.toString();
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final List<String> refTokens = new ArrayList<String>();
|
||||
|
||||
public JSONPointer build() {
|
||||
return new JSONPointer(this.refTokens);
|
||||
}
|
||||
|
||||
public Builder append(String token) {
|
||||
if (token == null) {
|
||||
throw new NullPointerException("token cannot be null");
|
||||
}
|
||||
this.refTokens.add(token);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder append(int arrayIndex) {
|
||||
this.refTokens.add(String.valueOf(arrayIndex));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
|
||||
public class JSONPointerException
|
||||
extends JSONException {
|
||||
private static final long serialVersionUID = 8872944667561856751L;
|
||||
|
||||
public JSONPointerException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public JSONPointerException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
@Target(value={ElementType.METHOD})
|
||||
public @interface JSONPropertyIgnore {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
@Target(value={ElementType.METHOD})
|
||||
public @interface JSONPropertyName {
|
||||
public String value();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
public interface JSONString {
|
||||
public String toJSONString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public class JSONStringer
|
||||
extends JSONWriter {
|
||||
public JSONStringer() {
|
||||
super(new StringWriter());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.mode == 'd' ? this.writer.toString() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONArray;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONParserConfiguration;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class JSONTokener {
|
||||
private long character;
|
||||
private boolean eof;
|
||||
private long index;
|
||||
private long line;
|
||||
private char previous;
|
||||
private final Reader reader;
|
||||
private boolean usePrevious;
|
||||
private long characterPreviousLine;
|
||||
private JSONParserConfiguration jsonParserConfiguration;
|
||||
|
||||
public JSONTokener(Reader reader) {
|
||||
this(reader, new JSONParserConfiguration());
|
||||
}
|
||||
|
||||
public JSONTokener(Reader reader, JSONParserConfiguration jsonParserConfiguration) {
|
||||
this.jsonParserConfiguration = jsonParserConfiguration;
|
||||
this.reader = reader.markSupported() ? reader : new BufferedReader(reader);
|
||||
this.eof = false;
|
||||
this.usePrevious = false;
|
||||
this.previous = '\u0000';
|
||||
this.index = 0L;
|
||||
this.character = 1L;
|
||||
this.characterPreviousLine = 0L;
|
||||
this.line = 1L;
|
||||
}
|
||||
|
||||
public JSONTokener(InputStream inputStream) {
|
||||
this(inputStream, new JSONParserConfiguration());
|
||||
}
|
||||
|
||||
public JSONTokener(InputStream inputStream, JSONParserConfiguration jsonParserConfiguration) {
|
||||
this(new InputStreamReader(inputStream, Charset.forName("UTF-8")), jsonParserConfiguration);
|
||||
}
|
||||
|
||||
public JSONTokener(String source) {
|
||||
this(new StringReader(source));
|
||||
}
|
||||
|
||||
public JSONTokener(String source, JSONParserConfiguration jsonParserConfiguration) {
|
||||
this(new StringReader(source), jsonParserConfiguration);
|
||||
}
|
||||
|
||||
public JSONParserConfiguration getJsonParserConfiguration() {
|
||||
return this.jsonParserConfiguration;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setJsonParserConfiguration(JSONParserConfiguration jsonParserConfiguration) {
|
||||
this.jsonParserConfiguration = jsonParserConfiguration;
|
||||
}
|
||||
|
||||
public void back() throws JSONException {
|
||||
if (this.usePrevious || this.index <= 0L) {
|
||||
throw new JSONException("Stepping back two steps is not supported");
|
||||
}
|
||||
this.decrementIndexes();
|
||||
this.usePrevious = true;
|
||||
this.eof = false;
|
||||
}
|
||||
|
||||
private void decrementIndexes() {
|
||||
--this.index;
|
||||
if (this.previous == '\r' || this.previous == '\n') {
|
||||
--this.line;
|
||||
this.character = this.characterPreviousLine;
|
||||
} else if (this.character > 0L) {
|
||||
--this.character;
|
||||
}
|
||||
}
|
||||
|
||||
public static int dehexchar(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - 48;
|
||||
}
|
||||
if (c >= 'A' && c <= 'F') {
|
||||
return c - 55;
|
||||
}
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
return c - 87;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean end() {
|
||||
return this.eof && !this.usePrevious;
|
||||
}
|
||||
|
||||
public boolean more() throws JSONException {
|
||||
if (this.usePrevious) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
this.reader.mark(1);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new JSONException("Unable to preserve stream position", e);
|
||||
}
|
||||
try {
|
||||
if (this.reader.read() <= 0) {
|
||||
this.eof = true;
|
||||
return false;
|
||||
}
|
||||
this.reader.reset();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new JSONException("Unable to read the next character from the stream", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public char next() throws JSONException {
|
||||
int c;
|
||||
if (this.usePrevious) {
|
||||
this.usePrevious = false;
|
||||
c = this.previous;
|
||||
} else {
|
||||
try {
|
||||
c = this.reader.read();
|
||||
}
|
||||
catch (IOException exception) {
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
}
|
||||
if (c <= 0) {
|
||||
this.eof = true;
|
||||
return '\u0000';
|
||||
}
|
||||
this.incrementIndexes(c);
|
||||
this.previous = (char)c;
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
protected char getPrevious() {
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
private void incrementIndexes(int c) {
|
||||
if (c > 0) {
|
||||
++this.index;
|
||||
if (c == 13) {
|
||||
++this.line;
|
||||
this.characterPreviousLine = this.character;
|
||||
this.character = 0L;
|
||||
} else if (c == 10) {
|
||||
if (this.previous != '\r') {
|
||||
++this.line;
|
||||
this.characterPreviousLine = this.character;
|
||||
}
|
||||
this.character = 0L;
|
||||
} else {
|
||||
++this.character;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public char next(char c) throws JSONException {
|
||||
char n = this.next();
|
||||
if (n != c) {
|
||||
if (n > '\u0000') {
|
||||
throw this.syntaxError("Expected '" + c + "' and instead saw '" + n + "'");
|
||||
}
|
||||
throw this.syntaxError("Expected '" + c + "' and instead saw ''");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public String next(int n) throws JSONException {
|
||||
if (n == 0) {
|
||||
return "";
|
||||
}
|
||||
char[] chars = new char[n];
|
||||
for (int pos = 0; pos < n; ++pos) {
|
||||
chars[pos] = this.next();
|
||||
if (!this.end()) continue;
|
||||
throw this.syntaxError("Substring bounds error");
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
public char nextClean() throws JSONException {
|
||||
char c;
|
||||
while ((c = this.next()) != '\u0000' && c <= ' ') {
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public String nextString(char quote) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
block15: while (true) {
|
||||
char c = this.next();
|
||||
switch (c) {
|
||||
case '\u0000':
|
||||
case '\n':
|
||||
case '\r': {
|
||||
throw this.syntaxError("Unterminated string. Character with int code " + c + " is not allowed within a quoted string.");
|
||||
}
|
||||
case '\\': {
|
||||
c = this.next();
|
||||
switch (c) {
|
||||
case 'b': {
|
||||
sb.append('\b');
|
||||
continue block15;
|
||||
}
|
||||
case 't': {
|
||||
sb.append('\t');
|
||||
continue block15;
|
||||
}
|
||||
case 'n': {
|
||||
sb.append('\n');
|
||||
continue block15;
|
||||
}
|
||||
case 'f': {
|
||||
sb.append('\f');
|
||||
continue block15;
|
||||
}
|
||||
case 'r': {
|
||||
sb.append('\r');
|
||||
continue block15;
|
||||
}
|
||||
case 'u': {
|
||||
String next = this.next(4);
|
||||
try {
|
||||
sb.append((char)Integer.parseInt(next, 16));
|
||||
continue block15;
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
throw this.syntaxError("Illegal escape. \\u must be followed by a 4 digit hexadecimal number. \\" + next + " is not valid.", e);
|
||||
}
|
||||
}
|
||||
case '\"':
|
||||
case '\'':
|
||||
case '/':
|
||||
case '\\': {
|
||||
sb.append(c);
|
||||
continue block15;
|
||||
}
|
||||
}
|
||||
throw this.syntaxError("Illegal escape. Escape sequence \\" + c + " is not valid.");
|
||||
}
|
||||
}
|
||||
if (c == quote) {
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
public String nextTo(char delimiter) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
char c;
|
||||
if ((c = this.next()) == delimiter || c == '\u0000' || c == '\n' || c == '\r') {
|
||||
if (c != '\u0000') {
|
||||
this.back();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
public String nextTo(String delimiters) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
char c;
|
||||
if (delimiters.indexOf(c = this.next()) >= 0 || c == '\u0000' || c == '\n' || c == '\r') {
|
||||
if (c != '\u0000') {
|
||||
this.back();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
public Object nextValue() throws JSONException {
|
||||
char c = this.nextClean();
|
||||
switch (c) {
|
||||
case '{': {
|
||||
this.back();
|
||||
try {
|
||||
return new JSONObject(this, this.jsonParserConfiguration);
|
||||
}
|
||||
catch (StackOverflowError e) {
|
||||
throw new JSONException("JSON Array or Object depth too large to process.", e);
|
||||
}
|
||||
}
|
||||
case '[': {
|
||||
this.back();
|
||||
try {
|
||||
return new JSONArray(this, this.jsonParserConfiguration);
|
||||
}
|
||||
catch (StackOverflowError e) {
|
||||
throw new JSONException("JSON Array or Object depth too large to process.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.nextSimpleValue(c);
|
||||
}
|
||||
|
||||
Object nextSimpleValue(char c) {
|
||||
String string;
|
||||
if (this.jsonParserConfiguration != null && this.jsonParserConfiguration.isStrictMode() && c == '\'') {
|
||||
throw this.syntaxError("Strict mode error: Single quoted strings are not allowed");
|
||||
}
|
||||
switch (c) {
|
||||
case '\"':
|
||||
case '\'': {
|
||||
return this.nextString(c);
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
||||
sb.append(c);
|
||||
c = this.next();
|
||||
}
|
||||
if (!this.eof) {
|
||||
this.back();
|
||||
}
|
||||
if ("".equals(string = sb.toString().trim())) {
|
||||
throw this.syntaxError("Missing value");
|
||||
}
|
||||
if (this.jsonParserConfiguration != null && this.jsonParserConfiguration.isStrictMode() && string.endsWith(".")) {
|
||||
throw this.syntaxError(String.format("Strict mode error: Value '%s' ends with dot", string));
|
||||
}
|
||||
Object obj = JSONObject.stringToValue(string);
|
||||
if (this.jsonParserConfiguration != null && this.jsonParserConfiguration.isStrictMode()) {
|
||||
if (obj instanceof Boolean && !"true".equals(string) && !"false".equals(string)) {
|
||||
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not lowercase boolean", obj));
|
||||
}
|
||||
if (obj == JSONObject.NULL && !"null".equals(string)) {
|
||||
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not lowercase null", obj));
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
throw this.syntaxError(String.format("Strict mode error: Value '%s' is not surrounded by quotes", obj));
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public char skipTo(char to) throws JSONException {
|
||||
char c;
|
||||
try {
|
||||
long startIndex = this.index;
|
||||
long startCharacter = this.character;
|
||||
long startLine = this.line;
|
||||
this.reader.mark(1000000);
|
||||
do {
|
||||
if ((c = this.next()) != '\u0000') continue;
|
||||
this.reader.reset();
|
||||
this.index = startIndex;
|
||||
this.character = startCharacter;
|
||||
this.line = startLine;
|
||||
return '\u0000';
|
||||
} while (c != to);
|
||||
this.reader.mark(1);
|
||||
}
|
||||
catch (IOException exception) {
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
this.back();
|
||||
return c;
|
||||
}
|
||||
|
||||
public JSONException syntaxError(String message) {
|
||||
return new JSONException(message + this.toString());
|
||||
}
|
||||
|
||||
public JSONException syntaxError(String message, Throwable causedBy) {
|
||||
return new JSONException(message + this.toString(), causedBy);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return " at " + this.index + " [character " + this.character + " line " + this.line + "]";
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (this.reader != null) {
|
||||
this.reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONArray;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.JSONString;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSONWriter {
|
||||
private static final int maxdepth = 200;
|
||||
private boolean comma = false;
|
||||
protected char mode = (char)105;
|
||||
private final JSONObject[] stack = new JSONObject[200];
|
||||
private int top = 0;
|
||||
protected Appendable writer;
|
||||
|
||||
public JSONWriter(Appendable w) {
|
||||
this.writer = w;
|
||||
}
|
||||
|
||||
private JSONWriter append(String string) throws JSONException {
|
||||
if (string == null) {
|
||||
throw new JSONException("Null pointer");
|
||||
}
|
||||
if (this.mode == 'o' || this.mode == 'a') {
|
||||
try {
|
||||
if (this.comma && this.mode == 'a') {
|
||||
this.writer.append(',');
|
||||
}
|
||||
this.writer.append(string);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if (this.mode == 'o') {
|
||||
this.mode = (char)107;
|
||||
}
|
||||
this.comma = true;
|
||||
return this;
|
||||
}
|
||||
throw new JSONException("Value out of sequence.");
|
||||
}
|
||||
|
||||
public JSONWriter array() throws JSONException {
|
||||
if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
|
||||
this.push(null);
|
||||
this.append("[");
|
||||
this.comma = false;
|
||||
return this;
|
||||
}
|
||||
throw new JSONException("Misplaced array.");
|
||||
}
|
||||
|
||||
private JSONWriter end(char m, char c) throws JSONException {
|
||||
if (this.mode != m) {
|
||||
throw new JSONException(m == 'a' ? "Misplaced endArray." : "Misplaced endObject.");
|
||||
}
|
||||
this.pop(m);
|
||||
try {
|
||||
this.writer.append(c);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
this.comma = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSONWriter endArray() throws JSONException {
|
||||
return this.end('a', ']');
|
||||
}
|
||||
|
||||
public JSONWriter endObject() throws JSONException {
|
||||
return this.end('k', '}');
|
||||
}
|
||||
|
||||
public JSONWriter key(String string) throws JSONException {
|
||||
if (string == null) {
|
||||
throw new JSONException("Null key.");
|
||||
}
|
||||
if (this.mode == 'k') {
|
||||
try {
|
||||
JSONObject topObject = this.stack[this.top - 1];
|
||||
if (topObject.has(string)) {
|
||||
throw new JSONException("Duplicate key \"" + string + "\"");
|
||||
}
|
||||
topObject.put(string, true);
|
||||
if (this.comma) {
|
||||
this.writer.append(',');
|
||||
}
|
||||
this.writer.append(JSONObject.quote(string));
|
||||
this.writer.append(':');
|
||||
this.comma = false;
|
||||
this.mode = (char)111;
|
||||
return this;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
}
|
||||
throw new JSONException("Misplaced key.");
|
||||
}
|
||||
|
||||
public JSONWriter object() throws JSONException {
|
||||
if (this.mode == 'i') {
|
||||
this.mode = (char)111;
|
||||
}
|
||||
if (this.mode == 'o' || this.mode == 'a') {
|
||||
this.append("{");
|
||||
this.push(new JSONObject());
|
||||
this.comma = false;
|
||||
return this;
|
||||
}
|
||||
throw new JSONException("Misplaced object.");
|
||||
}
|
||||
|
||||
private void pop(char c) throws JSONException {
|
||||
char m;
|
||||
if (this.top <= 0) {
|
||||
throw new JSONException("Nesting error.");
|
||||
}
|
||||
char c2 = m = this.stack[this.top - 1] == null ? (char)'a' : 'k';
|
||||
if (m != c) {
|
||||
throw new JSONException("Nesting error.");
|
||||
}
|
||||
--this.top;
|
||||
this.mode = (char)(this.top == 0 ? 100 : (this.stack[this.top - 1] == null ? 97 : 107));
|
||||
}
|
||||
|
||||
private void push(JSONObject jo) throws JSONException {
|
||||
if (this.top >= 200) {
|
||||
throw new JSONException("Nesting too deep.");
|
||||
}
|
||||
this.stack[this.top] = jo;
|
||||
this.mode = (char)(jo == null ? 97 : 107);
|
||||
++this.top;
|
||||
}
|
||||
|
||||
public static String valueToString(Object value) throws JSONException {
|
||||
if (value == null || value.equals(null)) {
|
||||
return "null";
|
||||
}
|
||||
if (value instanceof JSONString) {
|
||||
String object;
|
||||
try {
|
||||
object = ((JSONString)value).toJSONString();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if (object != null) {
|
||||
return object;
|
||||
}
|
||||
throw new JSONException("Bad value from toJSONString: " + object);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
String numberAsString = JSONObject.numberToString((Number)value);
|
||||
if (JSONObject.NUMBER_PATTERN.matcher(numberAsString).matches()) {
|
||||
return numberAsString;
|
||||
}
|
||||
return JSONObject.quote(numberAsString);
|
||||
}
|
||||
if (value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray) {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
Map map = (Map)value;
|
||||
return new JSONObject(map).toString();
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
Collection coll = (Collection)value;
|
||||
return new JSONArray(coll).toString();
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return new JSONArray(value).toString();
|
||||
}
|
||||
if (value instanceof Enum) {
|
||||
return JSONObject.quote(((Enum)value).name());
|
||||
}
|
||||
return JSONObject.quote(value.toString());
|
||||
}
|
||||
|
||||
public JSONWriter value(boolean b) throws JSONException {
|
||||
return this.append(b ? "true" : "false");
|
||||
}
|
||||
|
||||
public JSONWriter value(double d) throws JSONException {
|
||||
return this.value((Object)d);
|
||||
}
|
||||
|
||||
public JSONWriter value(long l) throws JSONException {
|
||||
return this.append(Long.toString(l));
|
||||
}
|
||||
|
||||
public JSONWriter value(Object object) throws JSONException {
|
||||
return this.append(JSONWriter.valueToString(object));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
public class ParserConfiguration {
|
||||
public static final int UNDEFINED_MAXIMUM_NESTING_DEPTH = -1;
|
||||
public static final int DEFAULT_MAXIMUM_NESTING_DEPTH = 512;
|
||||
protected boolean keepStrings;
|
||||
protected int maxNestingDepth;
|
||||
|
||||
public ParserConfiguration() {
|
||||
this.keepStrings = false;
|
||||
this.maxNestingDepth = 512;
|
||||
}
|
||||
|
||||
protected ParserConfiguration(boolean keepStrings, int maxNestingDepth) {
|
||||
this.keepStrings = keepStrings;
|
||||
this.maxNestingDepth = maxNestingDepth;
|
||||
}
|
||||
|
||||
protected ParserConfiguration clone() {
|
||||
return new ParserConfiguration(this.keepStrings, this.maxNestingDepth);
|
||||
}
|
||||
|
||||
public boolean isKeepStrings() {
|
||||
return this.keepStrings;
|
||||
}
|
||||
|
||||
public <T extends ParserConfiguration> T withKeepStrings(boolean newVal) {
|
||||
ParserConfiguration newConfig = this.clone();
|
||||
newConfig.keepStrings = newVal;
|
||||
return (T)newConfig;
|
||||
}
|
||||
|
||||
public int getMaxNestingDepth() {
|
||||
return this.maxNestingDepth;
|
||||
}
|
||||
|
||||
public <T extends ParserConfiguration> T withMaxNestingDepth(int maxNestingDepth) {
|
||||
ParserConfiguration newConfig = this.clone();
|
||||
newConfig.maxNestingDepth = maxNestingDepth > -1 ? maxNestingDepth : -1;
|
||||
return (T)newConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
public class Property {
|
||||
public static JSONObject toJSONObject(Properties properties) throws JSONException {
|
||||
JSONObject jo = new JSONObject();
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
Enumeration<?> enumProperties = properties.propertyNames();
|
||||
while (enumProperties.hasMoreElements()) {
|
||||
String name = (String)enumProperties.nextElement();
|
||||
jo.put(name, properties.getProperty(name));
|
||||
}
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
public static Properties toProperties(JSONObject jo) throws JSONException {
|
||||
Properties properties = new Properties();
|
||||
if (jo != null) {
|
||||
for (String key : jo.keySet()) {
|
||||
Object value = jo.opt(key);
|
||||
if (JSONObject.NULL.equals(value)) continue;
|
||||
properties.put(key, value.toString());
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
public class StringBuilderWriter
|
||||
extends Writer {
|
||||
private final StringBuilder builder;
|
||||
|
||||
public StringBuilderWriter() {
|
||||
this.builder = new StringBuilder();
|
||||
this.lock = this.builder;
|
||||
}
|
||||
|
||||
public StringBuilderWriter(int initialSize) {
|
||||
this.builder = new StringBuilder(initialSize);
|
||||
this.lock = this.builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int c) {
|
||||
this.builder.append((char)c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(char[] cbuf, int offset, int length) {
|
||||
if (offset < 0 || offset > cbuf.length || length < 0 || offset + length > cbuf.length || offset + length < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
this.builder.append(cbuf, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String str) {
|
||||
this.builder.append(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(String str, int offset, int length) {
|
||||
this.builder.append(str, offset, offset + length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuilderWriter append(CharSequence csq) {
|
||||
this.write(String.valueOf(csq));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuilderWriter append(CharSequence csq, int start, int end) {
|
||||
if (csq == null) {
|
||||
csq = "null";
|
||||
}
|
||||
return this.append(csq.subSequence(start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuilderWriter append(char c) {
|
||||
this.write(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,623 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONArray;
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONObject;
|
||||
import de.maxhenkel.voicechat.org.json.XMLParserConfiguration;
|
||||
import de.maxhenkel.voicechat.org.json.XMLTokener;
|
||||
import de.maxhenkel.voicechat.org.json.XMLXsiTypeConverter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class XML {
|
||||
public static final Character AMP = Character.valueOf('&');
|
||||
public static final Character APOS = Character.valueOf('\'');
|
||||
public static final Character BANG = Character.valueOf('!');
|
||||
public static final Character EQ = Character.valueOf('=');
|
||||
public static final Character GT = Character.valueOf('>');
|
||||
public static final Character LT = Character.valueOf('<');
|
||||
public static final Character QUEST = Character.valueOf('?');
|
||||
public static final Character QUOT = Character.valueOf('\"');
|
||||
public static final Character SLASH = Character.valueOf('/');
|
||||
public static final String NULL_ATTR = "xsi:nil";
|
||||
public static final String TYPE_ATTR = "xsi:type";
|
||||
|
||||
private static Iterable<Integer> codePointIterator(final String string) {
|
||||
return new Iterable<Integer>(){
|
||||
|
||||
@Override
|
||||
public Iterator<Integer> iterator() {
|
||||
return new Iterator<Integer>(){
|
||||
private int nextIndex = 0;
|
||||
private int length;
|
||||
{
|
||||
this.length = string.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return this.nextIndex < this.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer next() {
|
||||
int result = string.codePointAt(this.nextIndex);
|
||||
this.nextIndex += Character.charCount(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static String escape(String string) {
|
||||
StringBuilder sb = new StringBuilder(string.length());
|
||||
block7: for (int cp : XML.codePointIterator(string)) {
|
||||
switch (cp) {
|
||||
case 38: {
|
||||
sb.append("&");
|
||||
continue block7;
|
||||
}
|
||||
case 60: {
|
||||
sb.append("<");
|
||||
continue block7;
|
||||
}
|
||||
case 62: {
|
||||
sb.append(">");
|
||||
continue block7;
|
||||
}
|
||||
case 34: {
|
||||
sb.append(""");
|
||||
continue block7;
|
||||
}
|
||||
case 39: {
|
||||
sb.append("'");
|
||||
continue block7;
|
||||
}
|
||||
}
|
||||
if (XML.mustEscape(cp)) {
|
||||
sb.append("&#x");
|
||||
sb.append(Integer.toHexString(cp));
|
||||
sb.append(';');
|
||||
continue;
|
||||
}
|
||||
sb.appendCodePoint(cp);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static boolean mustEscape(int cp) {
|
||||
return Character.isISOControl(cp) && cp != 9 && cp != 10 && cp != 13 || (cp < 32 || cp > 55295) && (cp < 57344 || cp > 65533) && (cp < 65536 || cp > 0x10FFFF);
|
||||
}
|
||||
|
||||
public static String unescape(String string) {
|
||||
StringBuilder sb = new StringBuilder(string.length());
|
||||
int length = string.length();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
char c = string.charAt(i);
|
||||
if (c == '&') {
|
||||
int semic = string.indexOf(59, i);
|
||||
if (semic > i) {
|
||||
String entity = string.substring(i + 1, semic);
|
||||
sb.append(XMLTokener.unescapeEntity(entity));
|
||||
i += entity.length() + 1;
|
||||
continue;
|
||||
}
|
||||
sb.append(c);
|
||||
continue;
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void noSpace(String string) throws JSONException {
|
||||
int length = string.length();
|
||||
if (length == 0) {
|
||||
throw new JSONException("Empty string.");
|
||||
}
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (!Character.isWhitespace(string.charAt(i))) continue;
|
||||
throw new JSONException("'" + string + "' contains a space character.");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean parse(XMLTokener x, JSONObject context, String name, XMLParserConfiguration config, int currentNestingDepth) throws JSONException {
|
||||
Object obj;
|
||||
String string;
|
||||
JSONObject jsonObject = null;
|
||||
Object token = x.nextToken();
|
||||
if (token == BANG) {
|
||||
char c = x.next();
|
||||
if (c == '-') {
|
||||
if (x.next() == '-') {
|
||||
x.skipPast("-->");
|
||||
return false;
|
||||
}
|
||||
x.back();
|
||||
} else if (c == '[') {
|
||||
token = x.nextToken();
|
||||
if ("CDATA".equals(token) && x.next() == '[') {
|
||||
String string2 = x.nextCDATA();
|
||||
if (string2.length() > 0) {
|
||||
context.accumulate(config.getcDataTagName(), string2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
throw x.syntaxError("Expected 'CDATA['");
|
||||
}
|
||||
int i = 1;
|
||||
do {
|
||||
if ((token = x.nextMeta()) == null) {
|
||||
throw x.syntaxError("Missing '>' after '<!'.");
|
||||
}
|
||||
if (token == LT) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if (token != GT) continue;
|
||||
--i;
|
||||
} while (i > 0);
|
||||
return false;
|
||||
}
|
||||
if (token == QUEST) {
|
||||
x.skipPast("?>");
|
||||
return false;
|
||||
}
|
||||
if (token == SLASH) {
|
||||
token = x.nextToken();
|
||||
if (name == null) {
|
||||
throw x.syntaxError("Mismatched close tag " + token);
|
||||
}
|
||||
if (!token.equals(name)) {
|
||||
throw x.syntaxError("Mismatched " + name + " and " + token);
|
||||
}
|
||||
if (x.nextToken() != GT) {
|
||||
throw x.syntaxError("Misshaped close tag");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (token instanceof Character) {
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
String tagName = (String)token;
|
||||
token = null;
|
||||
jsonObject = new JSONObject();
|
||||
boolean nilAttributeFound = false;
|
||||
XMLXsiTypeConverter<?> xmlXsiTypeConverter = null;
|
||||
while (true) {
|
||||
if (token == null) {
|
||||
token = x.nextToken();
|
||||
}
|
||||
if (!(token instanceof String)) break;
|
||||
string = (String)token;
|
||||
token = x.nextToken();
|
||||
if (token == EQ) {
|
||||
token = x.nextToken();
|
||||
if (!(token instanceof String)) {
|
||||
throw x.syntaxError("Missing value");
|
||||
}
|
||||
if (config.isConvertNilAttributeToNull() && NULL_ATTR.equals(string) && Boolean.parseBoolean((String)token)) {
|
||||
nilAttributeFound = true;
|
||||
} else if (config.getXsiTypeMap() != null && !config.getXsiTypeMap().isEmpty() && TYPE_ATTR.equals(string)) {
|
||||
xmlXsiTypeConverter = config.getXsiTypeMap().get(token);
|
||||
} else if (!nilAttributeFound) {
|
||||
obj = XML.stringToValue((String)token);
|
||||
if (obj instanceof Boolean) {
|
||||
jsonObject.accumulate(string, config.isKeepBooleanAsString() ? (String)token : obj);
|
||||
} else if (obj instanceof Number) {
|
||||
jsonObject.accumulate(string, config.isKeepNumberAsString() ? (String)token : obj);
|
||||
} else {
|
||||
jsonObject.accumulate(string, XML.stringToValue((String)token));
|
||||
}
|
||||
}
|
||||
token = null;
|
||||
continue;
|
||||
}
|
||||
jsonObject.accumulate(string, "");
|
||||
}
|
||||
if (token == SLASH) {
|
||||
if (x.nextToken() != GT) {
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
if (config.getForceList().contains(tagName)) {
|
||||
if (nilAttributeFound) {
|
||||
context.append(tagName, JSONObject.NULL);
|
||||
} else if (jsonObject.length() > 0) {
|
||||
context.append(tagName, jsonObject);
|
||||
} else {
|
||||
context.put(tagName, new JSONArray());
|
||||
}
|
||||
} else if (nilAttributeFound) {
|
||||
context.accumulate(tagName, JSONObject.NULL);
|
||||
} else if (jsonObject.length() > 0) {
|
||||
context.accumulate(tagName, jsonObject);
|
||||
} else {
|
||||
context.accumulate(tagName, "");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (token == GT) {
|
||||
while (true) {
|
||||
if ((token = x.nextContent()) == null) {
|
||||
if (tagName != null) {
|
||||
throw x.syntaxError("Unclosed tag " + tagName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (token instanceof String) {
|
||||
string = (String)token;
|
||||
if (string.length() <= 0) continue;
|
||||
if (xmlXsiTypeConverter != null) {
|
||||
jsonObject.accumulate(config.getcDataTagName(), XML.stringToValue(string, xmlXsiTypeConverter));
|
||||
continue;
|
||||
}
|
||||
obj = XML.stringToValue((String)token);
|
||||
if (obj instanceof Boolean) {
|
||||
jsonObject.accumulate(config.getcDataTagName(), config.isKeepBooleanAsString() ? (String)token : obj);
|
||||
continue;
|
||||
}
|
||||
if (obj instanceof Number) {
|
||||
jsonObject.accumulate(config.getcDataTagName(), config.isKeepNumberAsString() ? (String)token : obj);
|
||||
continue;
|
||||
}
|
||||
if (obj == JSONObject.NULL) {
|
||||
jsonObject.accumulate(config.getcDataTagName(), config.isKeepStrings() ? (String)token : obj);
|
||||
continue;
|
||||
}
|
||||
jsonObject.accumulate(config.getcDataTagName(), XML.stringToValue((String)token));
|
||||
continue;
|
||||
}
|
||||
if (token != LT) continue;
|
||||
if (currentNestingDepth == config.getMaxNestingDepth()) {
|
||||
throw x.syntaxError("Maximum nesting depth of " + config.getMaxNestingDepth() + " reached");
|
||||
}
|
||||
if (XML.parse(x, jsonObject, tagName, config, currentNestingDepth + 1)) break;
|
||||
}
|
||||
if (config.getForceList().contains(tagName)) {
|
||||
if (jsonObject.length() == 0) {
|
||||
context.put(tagName, new JSONArray());
|
||||
} else if (jsonObject.length() == 1 && jsonObject.opt(config.getcDataTagName()) != null) {
|
||||
context.append(tagName, jsonObject.opt(config.getcDataTagName()));
|
||||
} else {
|
||||
context.append(tagName, jsonObject);
|
||||
}
|
||||
} else if (jsonObject.length() == 0) {
|
||||
context.accumulate(tagName, "");
|
||||
} else if (jsonObject.length() == 1 && jsonObject.opt(config.getcDataTagName()) != null) {
|
||||
context.accumulate(tagName, jsonObject.opt(config.getcDataTagName()));
|
||||
} else {
|
||||
if (!config.shouldTrimWhiteSpace()) {
|
||||
XML.removeEmpty(jsonObject, config);
|
||||
}
|
||||
context.accumulate(tagName, jsonObject);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
throw x.syntaxError("Misshaped tag");
|
||||
}
|
||||
|
||||
private static void removeEmpty(JSONObject jsonObject, XMLParserConfiguration config) {
|
||||
if (jsonObject.has(config.getcDataTagName())) {
|
||||
Object s = jsonObject.get(config.getcDataTagName());
|
||||
if (s instanceof String) {
|
||||
if (XML.isStringAllWhiteSpace(s.toString())) {
|
||||
jsonObject.remove(config.getcDataTagName());
|
||||
}
|
||||
} else if (s instanceof JSONArray) {
|
||||
JSONArray sArray = (JSONArray)s;
|
||||
for (int k = sArray.length() - 1; k >= 0; --k) {
|
||||
String s1;
|
||||
Object eachString = sArray.get(k);
|
||||
if (!(eachString instanceof String) || !XML.isStringAllWhiteSpace(s1 = (String)eachString)) continue;
|
||||
sArray.remove(k);
|
||||
}
|
||||
if (sArray.isEmpty()) {
|
||||
jsonObject.remove(config.getcDataTagName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isStringAllWhiteSpace(String s) {
|
||||
for (int k = 0; k < s.length(); ++k) {
|
||||
char eachChar = s.charAt(k);
|
||||
if (Character.isWhitespace(eachChar)) continue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Number stringToNumber(String val) throws NumberFormatException {
|
||||
char initial = val.charAt(0);
|
||||
if (initial >= '0' && initial <= '9' || initial == '-') {
|
||||
BigInteger bi;
|
||||
char at1;
|
||||
if (XML.isDecimalNotation(val)) {
|
||||
try {
|
||||
BigDecimal bd = new BigDecimal(val);
|
||||
if (initial == '-' && BigDecimal.ZERO.compareTo(bd) == 0) {
|
||||
return -0.0;
|
||||
}
|
||||
return bd;
|
||||
}
|
||||
catch (NumberFormatException retryAsDouble) {
|
||||
try {
|
||||
Double d = Double.valueOf(val);
|
||||
if (d.isNaN() || d.isInfinite()) {
|
||||
throw new NumberFormatException("val [" + val + "] is not a valid number.");
|
||||
}
|
||||
return d;
|
||||
}
|
||||
catch (NumberFormatException ignore) {
|
||||
throw new NumberFormatException("val [" + val + "] is not a valid number.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (initial == '0' && val.length() > 1) {
|
||||
at1 = val.charAt(1);
|
||||
if (at1 >= '0' && at1 <= '9') {
|
||||
throw new NumberFormatException("val [" + val + "] is not a valid number.");
|
||||
}
|
||||
} else if (initial == '-' && val.length() > 2) {
|
||||
at1 = val.charAt(1);
|
||||
char at2 = val.charAt(2);
|
||||
if (at1 == '0' && at2 >= '0' && at2 <= '9') {
|
||||
throw new NumberFormatException("val [" + val + "] is not a valid number.");
|
||||
}
|
||||
}
|
||||
if ((bi = new BigInteger(val)).bitLength() <= 31) {
|
||||
return bi.intValue();
|
||||
}
|
||||
if (bi.bitLength() <= 63) {
|
||||
return bi.longValue();
|
||||
}
|
||||
return bi;
|
||||
}
|
||||
throw new NumberFormatException("val [" + val + "] is not a valid number.");
|
||||
}
|
||||
|
||||
private static boolean isDecimalNotation(String val) {
|
||||
return val.indexOf(46) > -1 || val.indexOf(101) > -1 || val.indexOf(69) > -1 || "-0".equals(val);
|
||||
}
|
||||
|
||||
public static Object stringToValue(String string, XMLXsiTypeConverter<?> typeConverter) {
|
||||
if (typeConverter != null) {
|
||||
return typeConverter.convert(string);
|
||||
}
|
||||
return XML.stringToValue(string);
|
||||
}
|
||||
|
||||
public static Object stringToValue(String string) {
|
||||
if ("".equals(string)) {
|
||||
return string;
|
||||
}
|
||||
if ("true".equalsIgnoreCase(string)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if ("false".equalsIgnoreCase(string)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
if ("null".equalsIgnoreCase(string)) {
|
||||
return JSONObject.NULL;
|
||||
}
|
||||
char initial = string.charAt(0);
|
||||
if (initial >= '0' && initial <= '9' || initial == '-') {
|
||||
try {
|
||||
return XML.stringToNumber(string);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string) throws JSONException {
|
||||
return XML.toJSONObject(string, XMLParserConfiguration.ORIGINAL);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(Reader reader) throws JSONException {
|
||||
return XML.toJSONObject(reader, XMLParserConfiguration.ORIGINAL);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(Reader reader, boolean keepStrings) throws JSONException {
|
||||
if (keepStrings) {
|
||||
return XML.toJSONObject(reader, XMLParserConfiguration.KEEP_STRINGS);
|
||||
}
|
||||
return XML.toJSONObject(reader, XMLParserConfiguration.ORIGINAL);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(Reader reader, boolean keepNumberAsString, boolean keepBooleanAsString) throws JSONException {
|
||||
XMLParserConfiguration xmlParserConfiguration = new XMLParserConfiguration();
|
||||
if (keepNumberAsString) {
|
||||
xmlParserConfiguration = xmlParserConfiguration.withKeepNumberAsString(keepNumberAsString);
|
||||
}
|
||||
if (keepBooleanAsString) {
|
||||
xmlParserConfiguration = xmlParserConfiguration.withKeepBooleanAsString(keepBooleanAsString);
|
||||
}
|
||||
return XML.toJSONObject(reader, xmlParserConfiguration);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(Reader reader, XMLParserConfiguration config) throws JSONException {
|
||||
JSONObject jo = new JSONObject();
|
||||
XMLTokener x = new XMLTokener(reader, config);
|
||||
while (x.more()) {
|
||||
x.skipPast("<");
|
||||
if (!x.more()) continue;
|
||||
XML.parse(x, jo, null, config, 0);
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string, boolean keepStrings) throws JSONException {
|
||||
return XML.toJSONObject((Reader)new StringReader(string), keepStrings);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string, boolean keepNumberAsString, boolean keepBooleanAsString) throws JSONException {
|
||||
return XML.toJSONObject(new StringReader(string), keepNumberAsString, keepBooleanAsString);
|
||||
}
|
||||
|
||||
public static JSONObject toJSONObject(String string, XMLParserConfiguration config) throws JSONException {
|
||||
return XML.toJSONObject((Reader)new StringReader(string), config);
|
||||
}
|
||||
|
||||
public static String toString(Object object) throws JSONException {
|
||||
return XML.toString(object, null, XMLParserConfiguration.ORIGINAL);
|
||||
}
|
||||
|
||||
public static String toString(Object object, String tagName) {
|
||||
return XML.toString(object, tagName, XMLParserConfiguration.ORIGINAL);
|
||||
}
|
||||
|
||||
public static String toString(Object object, String tagName, XMLParserConfiguration config) throws JSONException {
|
||||
return XML.toString(object, tagName, config, 0, 0);
|
||||
}
|
||||
|
||||
private static String toString(Object object, String tagName, XMLParserConfiguration config, int indentFactor, int indent) throws JSONException {
|
||||
String indentationSuffix;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (object instanceof JSONObject) {
|
||||
if (tagName != null) {
|
||||
sb.append(XML.indent(indent));
|
||||
sb.append('<');
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
if (indentFactor > 0) {
|
||||
sb.append("\n");
|
||||
indent += indentFactor;
|
||||
}
|
||||
}
|
||||
JSONObject jo = (JSONObject)object;
|
||||
for (String key : jo.keySet()) {
|
||||
Object val;
|
||||
int i;
|
||||
int jaLength;
|
||||
JSONArray ja;
|
||||
Object value = jo.opt(key);
|
||||
if (value == null) {
|
||||
value = "";
|
||||
} else if (value.getClass().isArray()) {
|
||||
value = new JSONArray(value);
|
||||
}
|
||||
if (key.equals(config.getcDataTagName())) {
|
||||
if (value instanceof JSONArray) {
|
||||
ja = (JSONArray)value;
|
||||
jaLength = ja.length();
|
||||
for (i = 0; i < jaLength; ++i) {
|
||||
if (i > 0) {
|
||||
sb.append('\n');
|
||||
}
|
||||
val = ja.opt(i);
|
||||
sb.append(XML.escape(val.toString()));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
sb.append(XML.escape(value.toString()));
|
||||
continue;
|
||||
}
|
||||
if (value instanceof JSONArray) {
|
||||
ja = (JSONArray)value;
|
||||
jaLength = ja.length();
|
||||
for (i = 0; i < jaLength; ++i) {
|
||||
val = ja.opt(i);
|
||||
if (val instanceof JSONArray) {
|
||||
sb.append('<');
|
||||
sb.append(key);
|
||||
sb.append('>');
|
||||
sb.append(XML.toString(val, null, config, indentFactor, indent));
|
||||
sb.append("</");
|
||||
sb.append(key);
|
||||
sb.append('>');
|
||||
continue;
|
||||
}
|
||||
sb.append(XML.toString(val, key, config, indentFactor, indent));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ("".equals(value)) {
|
||||
if (config.isCloseEmptyTag()) {
|
||||
sb.append(XML.indent(indent));
|
||||
sb.append('<');
|
||||
sb.append(key);
|
||||
sb.append(">");
|
||||
sb.append("</");
|
||||
sb.append(key);
|
||||
sb.append(">");
|
||||
if (indentFactor <= 0) continue;
|
||||
sb.append("\n");
|
||||
continue;
|
||||
}
|
||||
sb.append(XML.indent(indent));
|
||||
sb.append('<');
|
||||
sb.append(key);
|
||||
sb.append("/>");
|
||||
if (indentFactor <= 0) continue;
|
||||
sb.append("\n");
|
||||
continue;
|
||||
}
|
||||
sb.append(XML.toString(value, key, config, indentFactor, indent));
|
||||
}
|
||||
if (tagName != null) {
|
||||
sb.append(XML.indent(indent - indentFactor));
|
||||
sb.append("</");
|
||||
sb.append(tagName);
|
||||
sb.append('>');
|
||||
if (indentFactor > 0) {
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
if (object != null && (object instanceof JSONArray || object.getClass().isArray())) {
|
||||
JSONArray ja = object.getClass().isArray() ? new JSONArray(object) : (JSONArray)object;
|
||||
int jaLength = ja.length();
|
||||
for (int i = 0; i < jaLength; ++i) {
|
||||
Object val = ja.opt(i);
|
||||
sb.append(XML.toString(val, tagName == null ? "array" : tagName, config, indentFactor, indent));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
String string = object == null ? "null" : XML.escape(object.toString());
|
||||
String string2 = indentationSuffix = indentFactor > 0 ? "\n" : "";
|
||||
if (tagName == null) {
|
||||
return XML.indent(indent) + "\"" + string + "\"" + indentationSuffix;
|
||||
}
|
||||
if (string.length() == 0) {
|
||||
return XML.indent(indent) + "<" + tagName + "/>" + indentationSuffix;
|
||||
}
|
||||
return XML.indent(indent) + "<" + tagName + ">" + string + "</" + tagName + ">" + indentationSuffix;
|
||||
}
|
||||
|
||||
public static String toString(Object object, int indentFactor) {
|
||||
return XML.toString(object, null, XMLParserConfiguration.ORIGINAL, indentFactor);
|
||||
}
|
||||
|
||||
public static String toString(Object object, String tagName, int indentFactor) {
|
||||
return XML.toString(object, tagName, XMLParserConfiguration.ORIGINAL, indentFactor);
|
||||
}
|
||||
|
||||
public static String toString(Object object, String tagName, XMLParserConfiguration config, int indentFactor) throws JSONException {
|
||||
return XML.toString(object, tagName, config, indentFactor, 0);
|
||||
}
|
||||
|
||||
private static final String indent(int indent) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < indent; ++i) {
|
||||
sb.append(' ');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.ParserConfiguration;
|
||||
import de.maxhenkel.voicechat.org.json.XMLXsiTypeConverter;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class XMLParserConfiguration
|
||||
extends ParserConfiguration {
|
||||
private boolean keepNumberAsString;
|
||||
private boolean keepBooleanAsString;
|
||||
public static final XMLParserConfiguration ORIGINAL = new XMLParserConfiguration();
|
||||
public static final XMLParserConfiguration KEEP_STRINGS = new XMLParserConfiguration().withKeepStrings(true);
|
||||
private String cDataTagName;
|
||||
private boolean convertNilAttributeToNull;
|
||||
private boolean closeEmptyTag;
|
||||
private Map<String, XMLXsiTypeConverter<?>> xsiTypeMap;
|
||||
private Set<String> forceList;
|
||||
private boolean shouldTrimWhiteSpace;
|
||||
|
||||
public XMLParserConfiguration() {
|
||||
this.cDataTagName = "content";
|
||||
this.convertNilAttributeToNull = false;
|
||||
this.xsiTypeMap = Collections.emptyMap();
|
||||
this.forceList = Collections.emptySet();
|
||||
this.shouldTrimWhiteSpace = true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public XMLParserConfiguration(boolean keepStrings) {
|
||||
this(keepStrings, "content", false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public XMLParserConfiguration(String cDataTagName) {
|
||||
this(false, cDataTagName, false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public XMLParserConfiguration(boolean keepStrings, String cDataTagName) {
|
||||
super(keepStrings, 512);
|
||||
this.cDataTagName = cDataTagName;
|
||||
this.convertNilAttributeToNull = false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public XMLParserConfiguration(boolean keepStrings, String cDataTagName, boolean convertNilAttributeToNull) {
|
||||
super(false, 512);
|
||||
this.keepNumberAsString = keepStrings;
|
||||
this.keepBooleanAsString = keepStrings;
|
||||
this.cDataTagName = cDataTagName;
|
||||
this.convertNilAttributeToNull = convertNilAttributeToNull;
|
||||
}
|
||||
|
||||
private XMLParserConfiguration(boolean keepStrings, String cDataTagName, boolean convertNilAttributeToNull, Map<String, XMLXsiTypeConverter<?>> xsiTypeMap, Set<String> forceList, int maxNestingDepth, boolean closeEmptyTag, boolean keepNumberAsString, boolean keepBooleanAsString) {
|
||||
super(false, maxNestingDepth);
|
||||
this.keepNumberAsString = keepNumberAsString;
|
||||
this.keepBooleanAsString = keepBooleanAsString;
|
||||
this.cDataTagName = cDataTagName;
|
||||
this.convertNilAttributeToNull = convertNilAttributeToNull;
|
||||
this.xsiTypeMap = Collections.unmodifiableMap(xsiTypeMap);
|
||||
this.forceList = Collections.unmodifiableSet(forceList);
|
||||
this.closeEmptyTag = closeEmptyTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XMLParserConfiguration clone() {
|
||||
XMLParserConfiguration config = new XMLParserConfiguration(this.keepStrings, this.cDataTagName, this.convertNilAttributeToNull, this.xsiTypeMap, this.forceList, this.maxNestingDepth, this.closeEmptyTag, this.keepNumberAsString, this.keepBooleanAsString);
|
||||
config.shouldTrimWhiteSpace = this.shouldTrimWhiteSpace;
|
||||
return config;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withKeepStrings(boolean newVal) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
newConfig.keepStrings = newVal;
|
||||
newConfig.keepNumberAsString = newVal;
|
||||
newConfig.keepBooleanAsString = newVal;
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withKeepNumberAsString(boolean newVal) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
newConfig.keepNumberAsString = newVal;
|
||||
newConfig.keepStrings = newConfig.keepBooleanAsString && newConfig.keepNumberAsString;
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withKeepBooleanAsString(boolean newVal) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
newConfig.keepBooleanAsString = newVal;
|
||||
newConfig.keepStrings = newConfig.keepBooleanAsString && newConfig.keepNumberAsString;
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public String getcDataTagName() {
|
||||
return this.cDataTagName;
|
||||
}
|
||||
|
||||
public boolean isKeepNumberAsString() {
|
||||
return this.keepNumberAsString;
|
||||
}
|
||||
|
||||
public boolean isKeepBooleanAsString() {
|
||||
return this.keepBooleanAsString;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withcDataTagName(String newVal) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
newConfig.cDataTagName = newVal;
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public boolean isConvertNilAttributeToNull() {
|
||||
return this.convertNilAttributeToNull;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withConvertNilAttributeToNull(boolean newVal) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
newConfig.convertNilAttributeToNull = newVal;
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public Map<String, XMLXsiTypeConverter<?>> getXsiTypeMap() {
|
||||
return this.xsiTypeMap;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withXsiTypeMap(Map<String, XMLXsiTypeConverter<?>> xsiTypeMap) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
HashMap cloneXsiTypeMap = new HashMap(xsiTypeMap);
|
||||
newConfig.xsiTypeMap = Collections.unmodifiableMap(cloneXsiTypeMap);
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public Set<String> getForceList() {
|
||||
return this.forceList;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withForceList(Set<String> forceList) {
|
||||
XMLParserConfiguration newConfig = this.clone();
|
||||
HashSet<String> cloneForceList = new HashSet<String>(forceList);
|
||||
newConfig.forceList = Collections.unmodifiableSet(cloneForceList);
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withMaxNestingDepth(int maxNestingDepth) {
|
||||
return (XMLParserConfiguration)super.withMaxNestingDepth(maxNestingDepth);
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withCloseEmptyTag(boolean closeEmptyTag) {
|
||||
XMLParserConfiguration clonedConfiguration = this.clone();
|
||||
clonedConfiguration.closeEmptyTag = closeEmptyTag;
|
||||
return clonedConfiguration;
|
||||
}
|
||||
|
||||
public XMLParserConfiguration withShouldTrimWhitespace(boolean shouldTrimWhiteSpace) {
|
||||
XMLParserConfiguration clonedConfiguration = this.clone();
|
||||
clonedConfiguration.shouldTrimWhiteSpace = shouldTrimWhiteSpace;
|
||||
return clonedConfiguration;
|
||||
}
|
||||
|
||||
public boolean isCloseEmptyTag() {
|
||||
return this.closeEmptyTag;
|
||||
}
|
||||
|
||||
public boolean shouldTrimWhiteSpace() {
|
||||
return this.shouldTrimWhiteSpace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
import de.maxhenkel.voicechat.org.json.JSONException;
|
||||
import de.maxhenkel.voicechat.org.json.JSONTokener;
|
||||
import de.maxhenkel.voicechat.org.json.XML;
|
||||
import de.maxhenkel.voicechat.org.json.XMLParserConfiguration;
|
||||
import java.io.Reader;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class XMLTokener
|
||||
extends JSONTokener {
|
||||
public static final HashMap<String, Character> entity = new HashMap(8);
|
||||
private XMLParserConfiguration configuration = XMLParserConfiguration.ORIGINAL;
|
||||
|
||||
public XMLTokener(Reader r) {
|
||||
super(r);
|
||||
}
|
||||
|
||||
public XMLTokener(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public XMLTokener(Reader r, XMLParserConfiguration configuration) {
|
||||
super(r);
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public String nextCDATA() throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (this.more()) {
|
||||
char c = this.next();
|
||||
sb.append(c);
|
||||
int i = sb.length() - 3;
|
||||
if (i < 0 || sb.charAt(i) != ']' || sb.charAt(i + 1) != ']' || sb.charAt(i + 2) != '>') continue;
|
||||
sb.setLength(i);
|
||||
return sb.toString();
|
||||
}
|
||||
throw this.syntaxError("Unclosed CDATA");
|
||||
}
|
||||
|
||||
public Object nextContent() throws JSONException {
|
||||
char c;
|
||||
while (Character.isWhitespace(c = this.next()) && this.configuration.shouldTrimWhiteSpace()) {
|
||||
}
|
||||
if (c == '\u0000') {
|
||||
return null;
|
||||
}
|
||||
if (c == '<') {
|
||||
return XML.LT;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (c != '\u0000') {
|
||||
if (c == '<') {
|
||||
this.back();
|
||||
if (this.configuration.shouldTrimWhiteSpace()) {
|
||||
return sb.toString().trim();
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
if (c == '&') {
|
||||
sb.append(this.nextEntity(c));
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
c = this.next();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
public Object nextEntity(char ampersand) throws JSONException {
|
||||
char c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (Character.isLetterOrDigit(c = this.next()) || c == '#') {
|
||||
sb.append(Character.toLowerCase(c));
|
||||
}
|
||||
if (c != ';') {
|
||||
throw this.syntaxError("Missing ';' in XML entity: &" + sb);
|
||||
}
|
||||
String string = sb.toString();
|
||||
return XMLTokener.unescapeEntity(string);
|
||||
}
|
||||
|
||||
static String unescapeEntity(String e) {
|
||||
if (e == null || e.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
if (e.charAt(0) == '#') {
|
||||
int cp = e.charAt(1) == 'x' || e.charAt(1) == 'X' ? Integer.parseInt(e.substring(2), 16) : Integer.parseInt(e.substring(1));
|
||||
return new String(new int[]{cp}, 0, 1);
|
||||
}
|
||||
Character knownEntity = entity.get(e);
|
||||
if (knownEntity == null) {
|
||||
return '&' + e + ';';
|
||||
}
|
||||
return knownEntity.toString();
|
||||
}
|
||||
|
||||
public Object nextMeta() throws JSONException {
|
||||
char c;
|
||||
while (Character.isWhitespace(c = this.next())) {
|
||||
}
|
||||
switch (c) {
|
||||
case '\u0000': {
|
||||
throw this.syntaxError("Misshaped meta tag");
|
||||
}
|
||||
case '<': {
|
||||
return XML.LT;
|
||||
}
|
||||
case '>': {
|
||||
return XML.GT;
|
||||
}
|
||||
case '/': {
|
||||
return XML.SLASH;
|
||||
}
|
||||
case '=': {
|
||||
return XML.EQ;
|
||||
}
|
||||
case '!': {
|
||||
return XML.BANG;
|
||||
}
|
||||
case '?': {
|
||||
return XML.QUEST;
|
||||
}
|
||||
case '\"':
|
||||
case '\'': {
|
||||
char q = c;
|
||||
do {
|
||||
if ((c = this.next()) != '\u0000') continue;
|
||||
throw this.syntaxError("Unterminated string");
|
||||
} while (c != q);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
while (!Character.isWhitespace(c = this.next())) {
|
||||
switch (c) {
|
||||
case '\u0000': {
|
||||
throw this.syntaxError("Unterminated string");
|
||||
}
|
||||
case '!':
|
||||
case '\"':
|
||||
case '\'':
|
||||
case '/':
|
||||
case '<':
|
||||
case '=':
|
||||
case '>':
|
||||
case '?': {
|
||||
this.back();
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
public Object nextToken() throws JSONException {
|
||||
char c;
|
||||
while (Character.isWhitespace(c = this.next())) {
|
||||
}
|
||||
switch (c) {
|
||||
case '\u0000': {
|
||||
throw this.syntaxError("Misshaped element");
|
||||
}
|
||||
case '<': {
|
||||
throw this.syntaxError("Misplaced '<'");
|
||||
}
|
||||
case '>': {
|
||||
return XML.GT;
|
||||
}
|
||||
case '/': {
|
||||
return XML.SLASH;
|
||||
}
|
||||
case '=': {
|
||||
return XML.EQ;
|
||||
}
|
||||
case '!': {
|
||||
return XML.BANG;
|
||||
}
|
||||
case '?': {
|
||||
return XML.QUEST;
|
||||
}
|
||||
case '\"':
|
||||
case '\'': {
|
||||
char q = c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
if ((c = this.next()) == '\u0000') {
|
||||
throw this.syntaxError("Unterminated string");
|
||||
}
|
||||
if (c == q) {
|
||||
return sb.toString();
|
||||
}
|
||||
if (c == '&') {
|
||||
sb.append(this.nextEntity(c));
|
||||
continue;
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (true) {
|
||||
sb.append(c);
|
||||
c = this.next();
|
||||
if (Character.isWhitespace(c)) {
|
||||
return sb.toString();
|
||||
}
|
||||
switch (c) {
|
||||
case '\u0000': {
|
||||
return sb.toString();
|
||||
}
|
||||
case '!':
|
||||
case '/':
|
||||
case '=':
|
||||
case '>':
|
||||
case '?':
|
||||
case '[':
|
||||
case ']': {
|
||||
this.back();
|
||||
return sb.toString();
|
||||
}
|
||||
case '\"':
|
||||
case '\'':
|
||||
case '<': {
|
||||
throw this.syntaxError("Bad character in a name");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void skipPast(String to) {
|
||||
char c;
|
||||
int i;
|
||||
int offset = 0;
|
||||
int length = to.length();
|
||||
char[] circle = new char[length];
|
||||
for (i = 0; i < length; ++i) {
|
||||
c = this.next();
|
||||
if (c == '\u0000') {
|
||||
return;
|
||||
}
|
||||
circle[i] = c;
|
||||
}
|
||||
while (true) {
|
||||
int j = offset;
|
||||
boolean b = true;
|
||||
for (i = 0; i < length; ++i) {
|
||||
if (circle[j] != to.charAt(i)) {
|
||||
b = false;
|
||||
break;
|
||||
}
|
||||
if (++j < length) continue;
|
||||
j -= length;
|
||||
}
|
||||
if (b) {
|
||||
return;
|
||||
}
|
||||
c = this.next();
|
||||
if (c == '\u0000') {
|
||||
return;
|
||||
}
|
||||
circle[offset] = c;
|
||||
if (++offset < length) continue;
|
||||
offset -= length;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
entity.put("amp", XML.AMP);
|
||||
entity.put("apos", XML.APOS);
|
||||
entity.put("gt", XML.GT);
|
||||
entity.put("lt", XML.LT);
|
||||
entity.put("quot", XML.QUOT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package de.maxhenkel.voicechat.org.json;
|
||||
|
||||
public interface XMLXsiTypeConverter<T> {
|
||||
public T convert(String var1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user