From bdad98669b5593b1610442190f9cf3f101dd375a Mon Sep 17 00:00:00 2001
From: M4TH1EU <41210834+M4TH1EU@users.noreply.github.com>
Date: Sat, 20 Jul 2019 21:57:52 +0200
Subject: [PATCH] =?UTF-8?q?Config=20en=20.json=20termin=C3=A9e=20+=20advan?=
=?UTF-8?q?cedstatus=20refait.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/ch/m4th1eu/json/CDL.java | 89 +-
src/main/java/ch/m4th1eu/json/Cookie.java | 33 +-
src/main/java/ch/m4th1eu/json/CookieList.java | 11 +-
src/main/java/ch/m4th1eu/json/HTTP.java | 21 +-
.../java/ch/m4th1eu/json/HTTPTokener.java | 9 +-
src/main/java/ch/m4th1eu/json/JSONArray.java | 565 ++--
.../java/ch/m4th1eu/json/JSONException.java | 20 +-
src/main/java/ch/m4th1eu/json/JSONML.java | 147 +-
src/main/java/ch/m4th1eu/json/JSONObject.java | 2430 ++++++++---------
.../java/ch/m4th1eu/json/JSONPointer.java | 181 +-
.../ch/m4th1eu/json/JSONPointerException.java | 2 +-
.../ch/m4th1eu/json/JSONPropertyIgnore.java | 9 +-
.../ch/m4th1eu/json/JSONPropertyName.java | 6 +-
src/main/java/ch/m4th1eu/json/JSONString.java | 3 +-
.../java/ch/m4th1eu/json/JSONStringer.java | 2 +
.../java/ch/m4th1eu/json/JSONTokener.java | 295 +-
src/main/java/ch/m4th1eu/json/JSONWriter.java | 447 +--
src/main/java/ch/m4th1eu/json/Property.java | 13 +-
src/main/java/ch/m4th1eu/json/XML.java | 173 +-
.../m4th1eu/json/XMLParserConfiguration.java | 42 +-
src/main/java/ch/m4th1eu/json/XMLTokener.java | 417 +--
.../java/ch/m4th1eu/richpresence/Main.java | 82 +-
.../java/ch/m4th1eu/richpresence/Utils.java | 98 +-
.../events/AdvancedStatusEvent.java | 46 +-
.../richpresence/events/EventPresence.java | 12 +-
.../richpresence/proxy/ClientProxy.java | 4 +-
.../richpresence/proxy/CommonProxy.java | 2 +-
27 files changed, 2539 insertions(+), 2620 deletions(-)
diff --git a/src/main/java/ch/m4th1eu/json/CDL.java b/src/main/java/ch/m4th1eu/json/CDL.java
index 6daf829..e442e88 100644
--- a/src/main/java/ch/m4th1eu/json/CDL.java
+++ b/src/main/java/ch/m4th1eu/json/CDL.java
@@ -40,6 +40,7 @@ SOFTWARE.
* A comma delimited list can be converted into a JSONArray of JSONObjects.
* The names for the elements in the JSONObjects can be taken from the names
* in the first row.
+ *
* @author JSON.org
* @version 2016-05-01
*/
@@ -48,6 +49,7 @@ public class CDL {
/**
* Get the next value. The value can be wrapped in quotes. The value can
* be empty.
+ *
* @param x A JSONTokener of the source text.
* @return The value string, or null if empty.
* @throws JSONException if the quoted string is badly formed.
@@ -60,49 +62,50 @@ public class CDL {
c = x.next();
} while (c == ' ' || c == '\t');
switch (c) {
- case 0:
- return null;
- case '"':
- case '\'':
- q = c;
- sb = new StringBuffer();
- for (;;) {
- c = x.next();
- if (c == q) {
- //Handle escaped double-quote
- char nextC = x.next();
- if(nextC != '\"') {
- // if our quote was the end of the file, don't step
- if(nextC > 0) {
- x.back();
+ case 0:
+ return null;
+ case '"':
+ case '\'':
+ q = c;
+ sb = new StringBuffer();
+ for (; ; ) {
+ c = x.next();
+ if (c == q) {
+ //Handle escaped double-quote
+ char nextC = x.next();
+ if (nextC != '\"') {
+ // if our quote was the end of the file, don't step
+ if (nextC > 0) {
+ x.back();
+ }
+ break;
}
- break;
}
+ if (c == 0 || c == '\n' || c == '\r') {
+ throw x.syntaxError("Missing close quote '" + q + "'.");
+ }
+ sb.append(c);
}
- if (c == 0 || c == '\n' || c == '\r') {
- throw x.syntaxError("Missing close quote '" + q + "'.");
- }
- sb.append(c);
- }
- return sb.toString();
- case ',':
- x.back();
- return "";
- default:
- x.back();
- return x.nextTo(',');
+ return sb.toString();
+ case ',':
+ x.back();
+ return "";
+ default:
+ x.back();
+ return x.nextTo(',');
}
}
/**
* Produce a JSONArray of strings from a row of comma delimited values.
+ *
* @param x A JSONTokener of the source text.
* @return A JSONArray of strings.
* @throws JSONException
*/
public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
JSONArray ja = new JSONArray();
- for (;;) {
+ for (; ; ) {
String value = getValue(x);
char c = x.next();
if (value == null ||
@@ -110,7 +113,7 @@ public class CDL {
return null;
}
ja.put(value);
- for (;;) {
+ for (; ; ) {
if (c == ',') {
break;
}
@@ -119,7 +122,7 @@ public class CDL {
return ja;
}
throw x.syntaxError("Bad character '" + c + "' (" +
- (int)c + ").");
+ (int) c + ").");
}
c = x.next();
}
@@ -129,23 +132,25 @@ public class CDL {
/**
* Produce a JSONObject from a row of comma delimited text, using a
* parallel JSONArray of strings to provides the names of the elements.
+ *
* @param names A JSONArray of names. This is commonly obtained from the
- * first row of a comma delimited text file using the rowToJSONArray
- * method.
- * @param x A JSONTokener of the source text.
+ * first row of a comma delimited text file using the rowToJSONArray
+ * method.
+ * @param x A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
*/
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
throws JSONException {
JSONArray ja = rowToJSONArray(x);
- return ja != null ? ja.toJSONObject(names) : null;
+ return ja != null ? ja.toJSONObject(names) : null;
}
/**
* Produce a comma delimited text row from a JSONArray. Values containing
* the comma character will be quoted. Troublesome characters may be
* removed.
+ *
* @param ja A JSONArray of strings.
* @return A string ending in NEWLINE.
*/
@@ -182,6 +187,7 @@ public class CDL {
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
+ *
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
@@ -193,6 +199,7 @@ public class CDL {
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
+ *
* @param x The JSONTokener containing the comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
@@ -204,7 +211,8 @@ public class CDL {
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
- * @param names A JSONArray of strings.
+ *
+ * @param names A JSONArray of strings.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
@@ -217,8 +225,9 @@ public class CDL {
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
+ *
* @param names A JSONArray of strings.
- * @param x A JSONTokener of the source text.
+ * @param x A JSONTokener of the source text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
@@ -228,7 +237,7 @@ public class CDL {
return null;
}
JSONArray ja = new JSONArray();
- for (;;) {
+ for (; ; ) {
JSONObject jo = rowToJSONObject(names, x);
if (jo == null) {
break;
@@ -246,6 +255,7 @@ public class CDL {
* Produce a comma delimited text from a JSONArray of JSONObjects. The
* first row will be a list of names obtained by inspecting the first
* JSONObject.
+ *
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
@@ -265,8 +275,9 @@ public class CDL {
* Produce a comma delimited text from a JSONArray of JSONObjects using
* a provided list of names. The list of names is not included in the
* output.
+ *
* @param names A JSONArray of strings.
- * @param ja A JSONArray of JSONObjects.
+ * @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
diff --git a/src/main/java/ch/m4th1eu/json/Cookie.java b/src/main/java/ch/m4th1eu/json/Cookie.java
index f0463cf..eef2f6b 100644
--- a/src/main/java/ch/m4th1eu/json/Cookie.java
+++ b/src/main/java/ch/m4th1eu/json/Cookie.java
@@ -27,6 +27,7 @@ SOFTWARE.
/**
* Convert a web browser cookie specification to a JSONObject and back.
* JSON and Cookies are both notations for name/value pairs.
+ *
* @author JSON.org
* @version 2015-12-09
*/
@@ -41,20 +42,21 @@ public class Cookie {
* only a convention, not a standard. Often, cookies are expected to have
* encoded values. We encode '=' and ';' because we must. We encode '%' and
* '+' because they are meta characters in URL encoding.
+ *
* @param string The source string.
- * @return The escaped result.
+ * @return The escaped result.
*/
public static String escape(String string) {
- char c;
- String s = string.trim();
- int length = s.length();
- StringBuilder sb = new StringBuilder(length);
+ char c;
+ String s = string.trim();
+ int length = s.length();
+ StringBuilder sb = new StringBuilder(length);
for (int i = 0; i < length; i += 1) {
c = s.charAt(i);
if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
sb.append('%');
- sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
- sb.append(Character.forDigit((char)(c & 0x0f), 16));
+ sb.append(Character.forDigit((char) ((c >>> 4) & 0x0f), 16));
+ sb.append(Character.forDigit((char) (c & 0x0f), 16));
} else {
sb.append(c);
}
@@ -73,15 +75,16 @@ public class Cookie {
* stored under the key "value". This method does not do checking or
* validation of the parameters. It only converts the cookie string into
* a JSONObject.
+ *
* @param string The cookie specification string.
* @return A JSONObject containing "name", "value", and possibly other
- * members.
+ * members.
* @throws JSONException
*/
public static JSONObject toJSONObject(String string) throws JSONException {
- String name;
- JSONObject jo = new JSONObject();
- Object value;
+ String name;
+ JSONObject jo = new JSONObject();
+ Object value;
JSONTokener x = new JSONTokener(string);
jo.put("name", x.nextTo('='));
x.next('=');
@@ -111,6 +114,7 @@ public class Cookie {
* If the JSONObject contains "expires", "domain", "path", or "secure"
* members, they will be appended to the cookie specification string.
* All other members are ignored.
+ *
* @param jo A JSONObject
* @return A cookie specification string
* @throws JSONException
@@ -142,9 +146,10 @@ public class Cookie {
/**
* Convert %
hh sequences to single characters, and
* convert plus to space.
+ *
* @param string A string that may contain
- * +
(plus) and
- * %
hh sequences.
+ * +
(plus) and
+ * %
hh sequences.
* @return The unescaped string.
*/
public static String unescape(String string) {
@@ -158,7 +163,7 @@ public class Cookie {
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);
+ c = (char) (d * 16 + e);
i += 2;
}
}
diff --git a/src/main/java/ch/m4th1eu/json/CookieList.java b/src/main/java/ch/m4th1eu/json/CookieList.java
index 57388d5..5f558d8 100644
--- a/src/main/java/ch/m4th1eu/json/CookieList.java
+++ b/src/main/java/ch/m4th1eu/json/CookieList.java
@@ -26,6 +26,7 @@ SOFTWARE.
/**
* Convert a web browser cookie list string to a JSONObject and back.
+ *
* @author JSON.org
* @version 2015-12-09
*/
@@ -36,11 +37,12 @@ public class CookieList {
* of name/value pairs. The names are separated from the values by '='.
* The pairs are separated by ';'. The names and the values
* will be unescaped, possibly converting '+' and '%' sequences.
- *
+ *
* To add a cookie to a cookie list, * cookielistJSONObject.put(cookieJSONObject.getString("name"), - * cookieJSONObject.getString("value")); - * @param string A cookie list string + * cookieJSONObject.getString("value")); + * + * @param string A cookie list string * @return A JSONObject * @throws JSONException */ @@ -61,12 +63,13 @@ public class CookieList { * of name/value pairs. The names are separated from the values by '='. * The pairs are separated by ';'. The characters '%', '+', '=', and ';' * in the names and values are replaced by "%hh". + * * @param jo A JSONObject * @return A cookie list string * @throws JSONException */ public static String toString(JSONObject jo) throws JSONException { - boolean b = false; + boolean b = false; final StringBuilder sb = new StringBuilder(); // Don't use the new entrySet API to maintain Android support for (final String key : jo.keySet()) { diff --git a/src/main/java/ch/m4th1eu/json/HTTP.java b/src/main/java/ch/m4th1eu/json/HTTP.java index d490cf4..400d275 100644 --- a/src/main/java/ch/m4th1eu/json/HTTP.java +++ b/src/main/java/ch/m4th1eu/json/HTTP.java @@ -28,12 +28,15 @@ import java.util.Locale; /** * Convert an HTTP header to a JSONObject and back. + * * @author JSON.org * @version 2015-12-09 */ public class HTTP { - /** Carriage return/line feed. */ + /** + * Carriage return/line feed. + */ public static final String CRLF = "\r\n"; /** @@ -63,15 +66,16 @@ public class HTTP { * ...} * It does no further checking or conversion. It does not parse dates. * It does not do '%' transforms on URLs. + * * @param string An HTTP header string. * @return A JSONObject containing the elements and attributes * of the XML string. * @throws JSONException */ public static JSONObject toJSONObject(String string) throws JSONException { - JSONObject jo = new JSONObject(); - HTTPTokener x = new HTTPTokener(string); - String token; + JSONObject jo = new JSONObject(); + HTTPTokener x = new HTTPTokener(string); + String token; token = x.nextToken(); if (token.toUpperCase(Locale.ROOT).startsWith("HTTP")) { @@ -119,13 +123,14 @@ public class HTTP { * } * Any other members of the JSONObject will be output as HTTP fields. * The result will end with two CRLF pairs. + * * @param jo A JSONObject * @return An HTTP header string. * @throws JSONException if the object does not contain enough - * information. + * information. */ public static String toString(JSONObject jo) throws JSONException { - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); if (jo.has("Status-Code") && jo.has("Reason-Phrase")) { sb.append(jo.getString("HTTP-Version")); sb.append(' '); @@ -147,9 +152,9 @@ public class HTTP { // Don't use the new entrySet API to maintain Android support for (final String key : jo.keySet()) { String value = jo.optString(key); - if (!"HTTP-Version".equals(key) && !"Status-Code".equals(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)) { + !"Request-URI".equals(key) && !JSONObject.NULL.equals(value)) { sb.append(key); sb.append(": "); sb.append(jo.optString(key)); diff --git a/src/main/java/ch/m4th1eu/json/HTTPTokener.java b/src/main/java/ch/m4th1eu/json/HTTPTokener.java index 2fcf50f..1a8b9d7 100644 --- a/src/main/java/ch/m4th1eu/json/HTTPTokener.java +++ b/src/main/java/ch/m4th1eu/json/HTTPTokener.java @@ -27,6 +27,7 @@ SOFTWARE. /** * The HTTPTokener extends the JSONTokener to provide additional methods * for the parsing of HTTP headers. + * * @author JSON.org * @version 2015-12-09 */ @@ -34,6 +35,7 @@ public class HTTPTokener extends JSONTokener { /** * Construct an HTTPTokener from a string. + * * @param string A source string. */ public HTTPTokener(String string) { @@ -43,8 +45,9 @@ public class HTTPTokener extends JSONTokener { /** * Get the next token or string. This is used in parsing HTTP headers. - * @throws JSONException + * * @return A String. + * @throws JSONException */ public String nextToken() throws JSONException { char c; @@ -55,7 +58,7 @@ public class HTTPTokener extends JSONTokener { } while (Character.isWhitespace(c)); if (c == '"' || c == '\'') { q = c; - for (;;) { + for (; ; ) { c = next(); if (c < ' ') { throw syntaxError("Unterminated string."); @@ -66,7 +69,7 @@ public class HTTPTokener extends JSONTokener { sb.append(c); } } - for (;;) { + for (; ; ) { if (c == 0 || Character.isWhitespace(c)) { return sb.toString(); } diff --git a/src/main/java/ch/m4th1eu/json/JSONArray.java b/src/main/java/ch/m4th1eu/json/JSONArray.java index a8066de..11462aa 100644 --- a/src/main/java/ch/m4th1eu/json/JSONArray.java +++ b/src/main/java/ch/m4th1eu/json/JSONArray.java @@ -30,11 +30,7 @@ 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; +import java.util.*; /** @@ -98,17 +94,15 @@ public class JSONArray implements Iterable