Files
AsminVoicechat/source/decompiled/de/maxhenkel/voicechat/org/json/JSONML.java
T
asminme bbccd4a815
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
first commit
2026-10-24 15:18:03 +02:00

333 lines
13 KiB
Java

/*
* 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();
}
}