diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/CDL.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/json/CDL.java deleted file mode 100644 index 003e4cb2c..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/CDL.java +++ /dev/null @@ -1,249 +0,0 @@ -package com.github.intellectualsites.plotsquared.json; - -/** - * This provides static methods to convert comma delimited text into a JSONArray, and to covert a JSONArray into comma - * delimited text. Comma delimited text is a very popular format for data interchange. It is understood by most - * database, spreadsheet, and organizer programs. - *
- * Each row of text represents a row in a table or a data record. Each row ends with a NEWLINE character. Each row - * contains one or more values. Values are separated by commas. A value can contain any character except for comma, - * unless is is wrapped in single quotes or double quotes. - *
- * The first row usually contains the names of the columns. - *
- * 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 2014-05-03
- */
-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.
- */
- private static String getValue(JSONTokener x) throws JSONException {
- char c;
- char q;
- StringBuffer sb;
- do {
- 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) {
- break;
- }
- 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(',');
- }
- }
-
- /**
- * 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 (; ; ) {
- String value = getValue(x);
- char c = x.next();
- if ((value == null) || ((ja.length() == 0) && value.isEmpty() && (c != ','))) {
- return null;
- }
- ja.put(value);
- for (; ; ) {
- if (c == ',') {
- break;
- }
- if (c != ' ') {
- if ((c == '\n') || (c == '\r') || (c == 0)) {
- return ja;
- }
- throw x.syntaxError("Bad character '" + c + "' (" + (int) c + ").");
- }
- c = x.next();
- }
- }
- }
-
- /**
- * 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.
- * @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;
- }
-
- /**
- * 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.
- */
- public static String rowToString(JSONArray ja) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < ja.length(); i += 1) {
- if (i > 0) {
- sb.append(',');
- }
- Object object = ja.opt(i);
- if (object != null) {
- String string = object.toString();
- if (!string.isEmpty() && ((string.indexOf(',') >= 0) || (string.indexOf('\n') >= 0)
- || (string.indexOf('\r') >= 0) || (string.indexOf(0) >= 0) || (string.charAt(0)
- == '"'))) {
- sb.append('"');
- int length = string.length();
- for (int j = 0; j < length; j += 1) {
- char c = string.charAt(j);
- if ((c >= ' ') && (c != '"')) {
- sb.append(c);
- }
- }
- sb.append('"');
- } else {
- sb.append(string);
- }
- }
- }
- sb.append('\n');
- return sb.toString();
- }
-
- /**
- * 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
- */
- public static JSONArray toJSONArray(String string) throws JSONException {
- return toJSONArray(new JSONTokener(string));
- }
-
- /**
- * 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
- */
- public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
- return toJSONArray(rowToJSONArray(x), x);
- }
-
- /**
- * 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 string The comma delimited text.
- * @return A JSONArray of JSONObjects.
- * @throws JSONException
- */
- public static JSONArray toJSONArray(JSONArray names, String string) throws JSONException {
- return toJSONArray(names, new JSONTokener(string));
- }
-
- /**
- * 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.
- * @return A JSONArray of JSONObjects.
- * @throws JSONException
- */
- public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException {
- if ((names == null) || (names.length() == 0)) {
- return null;
- }
- JSONArray ja = new JSONArray();
- for (; ; ) {
- JSONObject jo = rowToJSONObject(names, x);
- if (jo == null) {
- break;
- }
- ja.put(jo);
- }
- if (ja.length() == 0) {
- return null;
- }
- return ja;
- }
-
- /**
- * 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
- */
- public static String toString(JSONArray ja) throws JSONException {
- JSONObject jo = ja.optJSONObject(0);
- if (jo != null) {
- JSONArray names = jo.names();
- if (names != null) {
- return rowToString(names) + toString(names, ja);
- }
- }
- return null;
- }
-
- /**
- * 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.
- * @return A comma delimited text.
- * @throws JSONException
- */
- public static String toString(JSONArray names, JSONArray ja) throws JSONException {
- if ((names == null) || (names.length() == 0)) {
- return null;
- }
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < ja.length(); i += 1) {
- JSONObject jo = ja.optJSONObject(i);
- if (jo != null) {
- sb.append(rowToString(jo.toJSONArray(names)));
- }
- }
- return sb.toString();
- }
-}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/Cookie.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/json/Cookie.java
deleted file mode 100644
index 8e3c7444d..000000000
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/Cookie.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package com.github.intellectualsites.plotsquared.json;
-
-/**
- * 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 2014-05-03
- */
-public class Cookie {
- /**
- * Produce a copy of a string in which the characters '+', '%', '=', ';' and control characters are replaced with
- * "%hh". This is a gentle form of URL encoding, attempting to cause as little distortion to the string as possible.
- * The characters '=' and ';' are meta characters in cookies. By convention, they are escaped using the
- * URL-encoding. This is 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.
- */
- public static String escape(final String string) {
- char c;
- final String s = string.trim();
- final int length = s.length();
- final 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));
- } else {
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
- /**
- * Convert a cookie specification string into a JSONObject. The string will contain a name value pair separated by
- * '='. The name and the value will be unescaped, possibly converting '+' and '%' sequences. The cookie properties
- * may follow, separated by ';', also represented as name=value (except the secure property, which does not have a
- * value). The name will be stored under the key "name", and the value will be 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.
- * @throws JSONException
- */
- public static JSONObject toJSONObject(final String string) throws JSONException {
- String name;
- final JSONObject jo = new JSONObject();
- Object value;
- final JSONTokener x = new JSONTokener(string);
- jo.put("name", x.nextTo('='));
- x.next('=');
- jo.put("value", x.nextTo(';'));
- x.next();
- while (x.more()) {
- name = unescape(x.nextTo("=;"));
- if (x.next() != '=') {
- if (name.equals("secure")) {
- value = Boolean.TRUE;
- } else {
- throw x.syntaxError("Missing '=' in cookie parameter.");
- }
- } else {
- value = unescape(x.nextTo(';'));
- x.next();
- }
- jo.put(name, value);
- }
- return jo;
- }
-
- /**
- * Convert a JSONObject into a cookie specification string. The JSONObject must contain "name" and "value" members.
- * 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
- */
- public static String toString(final JSONObject jo) throws JSONException {
- final StringBuilder sb = new StringBuilder();
- sb.append(escape(jo.getString("name"))).append("=").append(escape(jo.getString("value")));
- if (jo.has("expires")) {
- sb.append(";expires=").append(jo.getString("expires"));
- }
- if (jo.has("domain")) {
- sb.append(";domain=").append(escape(jo.getString("domain")));
- }
- if (jo.has("path")) {
- sb.append(";path=").append(escape(jo.getString("path")));
- }
- if (jo.optBoolean("secure")) {
- sb.append(";secure");
- }
- return sb.toString();
- }
-
- /**
- * Convert {@code %}hh sequences to single characters, and convert plus to space.
- *
- * @param string A string that may contain {@code +} (plus) and %
hh
- * sequences.
- * @return The unescaped string.
- */
- public static String unescape(final String string) {
- final int length = string.length();
- final 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)) {
- final int d = JSONTokener.dehexchar(string.charAt(i + 1));
- final 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();
- }
-}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/CookieList.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/json/CookieList.java
deleted file mode 100644
index 90b51cdd7..000000000
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/CookieList.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.github.intellectualsites.plotsquared.json;
-
-import java.util.Iterator;
-
-/**
- * Convert a web browser cookie list string to a JSONObject and back.
- *
- * @author JSON.org
- * @version 2014-05-03
- */
-public class CookieList {
- /**
- * Convert a cookie list into a JSONObject. A cookie list is a sequence 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 cooklist, cookielistJSONObject.put(cookieJSONObject.getString("name"),
- * cookieJSONObject.getString("value"));
- *
- * @param string A cookie list string
- * @return A JSONObject
- * @throws JSONException
- */
- public static JSONObject toJSONObject(final String string) throws JSONException {
- final JSONObject jo = new JSONObject();
- final JSONTokener x = new JSONTokener(string);
- while (x.more()) {
- final String name = Cookie.unescape(x.nextTo('='));
- x.next('=');
- jo.put(name, Cookie.unescape(x.nextTo(';')));
- x.next();
- }
- return jo;
- }
-
- /**
- * Convert a JSONObject into a cookie list. A cookie list is a sequence 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(final JSONObject jo) throws JSONException {
- boolean b = false;
- final Iterator
- * A response header must contain
- *
- *
- *
- * 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.
- */
- public static String toString(final JSONObject jo) throws JSONException {
- final Iterator
- * Comments, prologs, DTDs, and
- * Comments, prologs, DTDs, and
- * A JSONStringer instance provides a
- * which produces the string
- *
- *
- *
- * The first method called must be
- * This can sometimes be easier than using a JSONObject to build a string.
- *
- * @author JSON.org
- * @version 2008-09-18
- */
-public class JSONStringer extends JSONWriter {
- /**
- * Make a fresh JSONStringer. It can be used to build one JSON text.
- */
- public JSONStringer() {
- super(new StringWriter());
- }
-
- /**
- * Return the JSON text. This method is used to obtain the product of the JSONStringer instance. It will return
- *
- * A JSONWriter instance provides a
- * which writes
- *
- *
- *
- * The first method called must be
- * This can sometimes be easier than using a JSONObject to build a string.
- *
- * @author JSON.org
- * @version 2011-11-24
- */
-public class JSONWriter {
- private static final int maxdepth = 200;
- /**
- * The writer that will receive the output.
- */
- protected final Writer writer;
- /**
- * The object/array stack.
- */
- private final JSONObject stack[];
- /**
- * The current mode. Values: 'a' (array), 'd' (done), 'i' (initial), 'k' (key), 'o' (object).
- */
- protected char mode;
- /**
- * The comma flag determines if a comma should be output before the next value.
- */
- private boolean comma;
- /**
- * The stack top index. A value of 0 indicates that the stack is empty.
- */
- private int top;
-
- /**
- * Make a fresh JSONWriter. It can be used to build one JSON text.
- */
- public JSONWriter(final Writer w) {
- comma = false;
- mode = 'i';
- stack = new JSONObject[maxdepth];
- top = 0;
- writer = w;
- }
-
- /**
- * Append a value.
- *
- * @param string A string value.
- * @return this
- * @throws JSONException If the value is out of sequence.
- */
- private JSONWriter append(final String string) throws JSONException {
- if (string == null) {
- throw new JSONException("Null pointer");
- }
- if ((mode == 'o') || (mode == 'a')) {
- try {
- if (comma && (mode == 'a')) {
- writer.write(',');
- }
- writer.write(string);
- } catch (final IOException e) {
- throw new JSONException(e);
- }
- if (mode == 'o') {
- mode = 'k';
- }
- comma = true;
- return this;
- }
- throw new JSONException("Value out of sequence.");
- }
-
- /**
- * Begin appending a new array. All values until the balancing
- * Kim UTF-8 one byte U+007F U+007F two bytes U+3FFF U+07FF three bytes U+10FFF U+FFFF four bytes U+10FFFF
- *
- * Characters in the ranges U+0800..U+3FFF and U+10000..U+10FFFF will be one byte smaller when encoded in Kim compared
- * to UTF-8.
- *
- * Kim is beneficial when using scripts such as Old South Arabian, Aramaic, Avestan, Balinese, Batak, Bopomofo,
- * Buginese, Buhid, Carian, Cherokee, Coptic, Cyrillic, Deseret, Egyptian Hieroglyphs, Ethiopic, Georgian, Glagolitic,
- * Gothic, Hangul Jamo, Hanunoo, Hiragana, Kanbun, Kaithi, Kannada, Katakana, Kharoshthi, Khmer, Lao, Lepcha, Limbu,
- * Lycian, Lydian, Malayalam, Mandaic, Meroitic, Miao, Mongolian, Myanmar, New Tai Lue, Ol Chiki, Old Turkic, Oriya,
- * Osmanya, Pahlavi, Parthian, Phags-Pa, Phoenician, Samaritan, Sharada, Sinhala, Sora Sompeng, Tagalog, Tagbanwa,
- * Takri, Tai Le, Tai Tham, Tamil, Telugu, Thai, Tibetan, Tifinagh, UCAS.
- *
- * A kim object can be constructed from an ordinary UTF-16 string, or from a byte array. A kim object can produce a
- * UTF-16 string.
- *
- * As with UTF-8, it is possible to detect character boundaries within a byte sequence. UTF-8 is one of the world's
- * great inventions. While Kim is more efficient, it is not clear that it is worth the expense of transition.
- *
- * @version 2013-04-18
- */
-public class Kim {
- /**
- * The number of bytes in the kim. The number of bytes can be as much as three times the number of characters.
- */
- public int length = 0;
- /**
- * The byte array containing the kim's content.
- */
- private byte[] bytes = null;
- /**
- * The kim's hashcode, conforming to Java's hashcode conventions.
- */
- private int hashcode = 0;
- /**
- * The memoization of toString().
- */
- private String string = null;
-
- /**
- * Make a kim from a portion of a byte array.
- *
- * @param bytes A byte array.
- * @param from The index of the first byte.
- * @param thru The index of the last byte plus one.
- */
- public Kim(final byte[] bytes, final int from, final int thru) {
- // As the bytes are copied into the new kim, a hashcode is computed
- // using a
- // modified Fletcher code.
- int sum = 1;
- int value;
- hashcode = 0;
- length = thru - from;
- if (length > 0) {
- this.bytes = new byte[length];
- for (int at = 0; at < length; at += 1) {
- value = bytes[at + from] & 0xFF;
- sum += value;
- hashcode += sum;
- this.bytes[at] = (byte) value;
- }
- hashcode += sum << 16;
- }
- }
-
- /**
- * Make a kim from a byte array.
- *
- * @param bytes The byte array.
- * @param length The number of bytes.
- */
- public Kim(final byte[] bytes, final int length) {
- this(bytes, 0, length);
- }
-
- /**
- * Make a new kim from a substring of an existing kim. The coordinates are in byte units, not character units.
- *
- * @param kim The source of bytes.
- * @param from The point at which to take bytes.
- * @param thru The point at which to stop taking bytes.
- */
- public Kim(final Kim kim, final int from, final int thru) {
- this(kim.bytes, from, thru);
- }
-
- /**
- * Make a kim from a string.
- *
- * @param string The string.
- * @throws JSONException if surrogate pair mismatch.
- */
- public Kim(final String string) throws JSONException {
- final int stringLength = string.length();
- hashcode = 0;
- length = 0;
- // First pass: Determine the length of the kim, allowing for the UTF-16
- // to UTF-32 conversion, and then the UTF-32 to Kim conversion.
- if (stringLength > 0) {
- for (int i = 0; i < stringLength; i += 1) {
- final int c = string.charAt(i);
- if (c <= 0x7F) {
- length += 1;
- } else if (c <= 0x3FFF) {
- length += 2;
- } else {
- if ((c >= 0xD800) && (c <= 0xDFFF)) {
- i += 1;
- final int d = string.charAt(i);
- if ((c > 0xDBFF) || (d < 0xDC00) || (d > 0xDFFF)) {
- throw new JSONException("Bad UTF16");
- }
- }
- length += 3;
- }
- }
- // Second pass: Allocate a byte array and fill that array with the
- // conversion
- // while computing the hashcode.
- bytes = new byte[length];
- int at = 0;
- int b;
- int sum = 1;
- for (int i = 0; i < stringLength; i += 1) {
- int character = string.charAt(i);
- if (character <= 0x7F) {
- bytes[at] = (byte) character;
- sum += character;
- hashcode += sum;
- at += 1;
- } else if (character <= 0x3FFF) {
- b = 0x80 | (character >>> 7);
- bytes[at] = (byte) b;
- sum += b;
- hashcode += sum;
- at += 1;
- b = character & 0x7F;
- bytes[at] = (byte) b;
- sum += b;
- hashcode += sum;
- at += 1;
- } else {
- if ((character >= 0xD800) && (character <= 0xDBFF)) {
- i += 1;
- character =
- (((character & 0x3FF) << 10) | (string.charAt(i) & 0x3FF)) + 65536;
- }
- b = 0x80 | (character >>> 14);
- bytes[at] = (byte) b;
- sum += b;
- hashcode += sum;
- at += 1;
- b = 0x80 | ((character >>> 7) & 0xFF);
- bytes[at] = (byte) b;
- sum += b;
- hashcode += sum;
- at += 1;
- b = character & 0x7F;
- bytes[at] = (byte) b;
- sum += b;
- hashcode += sum;
- at += 1;
- }
- }
- hashcode += sum << 16;
- }
- }
-
- /**
- * Returns the number of bytes needed to contain the character in Kim format.
- *
- * @param character a Unicode character between 0 and 0x10FFFF.
- * @return 1, 2, or 3
- * @throws JSONException if the character is not representable in a kim.
- */
- public static int characterSize(final int character) throws JSONException {
- if ((character < 0) || (character > 0x10FFFF)) {
- throw new JSONException("Bad character " + character);
- }
- return character <= 0x7F ? 1 : character <= 0x3FFF ? 2 : 3;
- }
-
- /**
- * Returns the character at the specified index. The index refers to byte values and ranges from 0 to length - 1.
- * The index of the next character is at index + Kim.characterSize(kim.characterAt(index)).
- *
- * @param at the index of the char value. The first character is at 0.
- * @return a Unicode character between 0 and 0x10FFFF.
- * @throws JSONException if at does not point to a valid character.
- */
- public int characterAt(final int at) throws JSONException {
- final int c = get(at);
- if ((c & 0x80) == 0) {
- return c;
- }
- int character;
- final int c1 = get(at + 1);
- if ((c1 & 0x80) == 0) {
- character = ((c & 0x7F) << 7) | c1;
- if (character > 0x7F) {
- return character;
- }
- } else {
- final int c2 = get(at + 2);
- character = ((c & 0x7F) << 14) | ((c1 & 0x7F) << 7) | c2;
- if (((c2 & 0x80) == 0) && (character > 0x3FFF) && (character <= 0x10FFFF) && (
- (character < 0xD800) || (character > 0xDFFF))) {
- return character;
- }
- }
- throw new JSONException("Bad character at " + at);
- }
-
- /**
- * Copy the contents of this kim to a byte array.
- *
- * @param bytes A byte array of sufficient size.
- * @param at The position within the byte array to take the byes.
- * @return The position immediately after the copy.
- */
- public int copy(final byte[] bytes, final int at) {
- System.arraycopy(this.bytes, 0, bytes, at, length);
- return at + length;
- }
-
- /**
- * Two kim objects containing exactly the same bytes in the same order are equal to each other.
- *
- * @param obj the other kim with which to compare.
- * @return true if this and obj are both kim objects containing identical byte sequences.
- */
- @Override public boolean equals(final Object obj) {
- if (!(obj instanceof Kim)) {
- return false;
- }
- final Kim that = (Kim) obj;
- if (this == that) {
- return true;
- }
- if (hashcode != that.hashcode) {
- return false;
- }
- return java.util.Arrays.equals(bytes, that.bytes);
- }
-
- /**
- * Get a byte from a kim.
- *
- * @param at The position of the byte. The first byte is at 0.
- * @return The byte.
- * @throws JSONException if there is no byte at that position.
- */
- public int get(final int at) throws JSONException {
- if ((at < 0) || (at > length)) {
- throw new JSONException("Bad character at " + at);
- }
- return (bytes[at]) & 0xFF;
- }
-
- /**
- * Returns a hash code value for the kim.
- */
- @Override public int hashCode() {
- return hashcode;
- }
-
- /**
- * Produce a UTF-16 String from this kim. The number of codepoints in the string will not be greater than the number
- * of bytes in the kim, although it could be less.
- *
- * @return The string. A kim memoizes its string representation.
- * @throws JSONException if the kim is not valid.
- */
- @Override public String toString() throws JSONException {
- if (string == null) {
- int c;
- int length = 0;
- final char chars[] = new char[this.length];
- for (int at = 0; at < this.length; at += characterSize(c)) {
- c = characterAt(at);
- if (c < 0x10000) {
- chars[length] = (char) c;
- length += 1;
- } else {
- chars[length] = (char) (0xD800 | ((c - 0x10000) >>> 10));
- length += 1;
- chars[length] = (char) (0xDC00 | (c & 0x03FF));
- length += 1;
- }
- }
- string = new String(chars, 0, length);
- }
- return string;
- }
-}
- * {
- * Method: "POST" (for example),
- * "Request-URI": "/" (for example),
- * "HTTP-Version": "HTTP/1.1" (for example)
- * }
- *
- *
- * {
- * "HTTP-Version": "HTTP/1.1" (for example),
- * "Status-Code": "200" (for example),
- * "Reason-Phrase": "OK" (for example)
- * }
- *
- * <[ [ ]]>
- * are ignored.
- *
- * @param x An XMLTokener.
- * @return A JSONArray containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
- return (JSONArray) parse(x, true, null);
- }
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each
- * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
- * will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes"
- * property which will be an array of strings and JsonML JSONObjects.
- * <[ [ ]]>
are ignored.
- *
- * @param x An XMLTokener of the XML source text.
- * @return A JSONObject containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
- return (JSONObject) parse(x, false, null);
- }
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a JSONObject using the JsonML transform. Each
- * XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
- * will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes"
- * property which will be an array of strings and JsonML JSONObjects.
- * <[ [ ]]>
are ignored.
- *
- * @param string The XML source text.
- * @return A JSONObject containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONObject toJSONObject(String string) throws JSONException {
- return toJSONObject(new XMLTokener(string));
- }
-
- /**
- * Reverse the JSONML transformation, making an XML text from a JSONArray.
- *
- * @param ja A JSONArray.
- * @return An XML string.
- * @throws JSONException
- */
- public static String toString(JSONArray ja) throws JSONException {
- int i;
- JSONObject jo;
- String key;
- Iteratorvalue
method for appending values to the text, and a key
- * method for adding keys before values in objects. There are array
and endArray
methods that
- * make and bound array values, and object
and endObject
methods which make and bound object
- * values. All of these methods return the JSONWriter instance, permitting cascade style. For example,
- *
- *
- *
- * myString = new JSONStringer().object().key("JSON").value("Hello,
- * World!").endObject().toString();
- *
- *
- * {"JSON":"Hello, World!"}
- *
- * array
or object
. There are no methods for adding commas or
- * colons. JSONStringer adds them for you. Objects and arrays can be nested up to 20 levels deep.
- * null
if there was a problem in the construction of the JSON text (such as the calls to
- * array
were not properly balanced with calls to endArray
).
- *
- * @return The JSON text.
- */
- @Override public String toString() {
- return mode == 'd' ? writer.toString() : null;
- }
-}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/JSONWriter.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/json/JSONWriter.java
deleted file mode 100644
index de6af2c75..000000000
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/JSONWriter.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package com.github.intellectualsites.plotsquared.json;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * JSONWriter provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON
- * syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of
- * JSONWriter can produce one JSON text.
- * value
method for appending values to the text, and a key
- * method for adding keys before values in objects. There are array
and endArray
methods that
- * make and bound array values, and object
and endObject
methods which make and bound object
- * values. All of these methods return the JSONWriter instance, permitting a cascade style. For example,
- *
- *
- *
- * new JSONWriter(myWriter).object().key("JSON").value("Hello, World!").endObject();
- *
- *
- * {"JSON":"Hello, World!"}
- *
- * array
or object
. There are no methods for adding commas or
- * colons. JSONWriter adds them for you. Objects and arrays can be nested up to 20 levels deep.
- * endArray
will be appended to this array.
- * The endArray
method must be called to mark the array's end.
- *
- * @return this
- * @throws JSONException If the nesting is too deep, or if the object is started in the wrong place (for example as
- * a key or after the end of the outermost array or object).
- */
- public JSONWriter array() throws JSONException {
- if ((mode == 'i') || (mode == 'o') || (mode == 'a')) {
- push(null);
- append("[");
- comma = false;
- return this;
- }
- throw new JSONException("Misplaced array.");
- }
-
- /**
- * End something.
- *
- * @param mode Mode
- * @param c Closing character
- * @return this
- * @throws JSONException If unbalanced.
- */
- private JSONWriter end(final char mode, final char c) throws JSONException {
- if (this.mode != mode) {
- throw new JSONException(mode == 'a' ? "Misplaced endArray." : "Misplaced endObject.");
- }
- pop(mode);
- try {
- writer.write(c);
- } catch (final IOException e) {
- throw new JSONException(e);
- }
- comma = true;
- return this;
- }
-
- /**
- * End an array. This method most be called to balance calls to array
.
- *
- * @return this
- * @throws JSONException If incorrectly nested.
- */
- public JSONWriter endArray() throws JSONException {
- return end('a', ']');
- }
-
- /**
- * End an object. This method most be called to balance calls to object
.
- *
- * @return this
- * @throws JSONException If incorrectly nested.
- */
- public JSONWriter endObject() throws JSONException {
- return end('k', '}');
- }
-
- /**
- * Append a key. The key will be associated with the next value. In an object, every value must be preceded by a
- * key.
- *
- * @param string A key string.
- * @return this
- * @throws JSONException If the key is out of place. For example, keys do not belong in arrays or if the key is
- * null.
- */
- public JSONWriter key(final String string) throws JSONException {
- if (string == null) {
- throw new JSONException("Null key.");
- }
- if (mode == 'k') {
- try {
- stack[top - 1].putOnce(string, Boolean.TRUE);
- if (comma) {
- writer.write(',');
- }
- writer.write(JSONObject.quote(string));
- writer.write(':');
- comma = false;
- mode = 'o';
- return this;
- } catch (final IOException e) {
- throw new JSONException(e);
- }
- }
- throw new JSONException("Misplaced key.");
- }
-
- /**
- * Begin appending a new object. All keys and values until the balancing endObject
will be appended to
- * this object. The endObject
method must be called to mark the object's end.
- *
- * @return this
- * @throws JSONException If the nesting is too deep, or if the object is started in the wrong place (for example as
- * a key or after the end of the outermost array or object).
- */
- public JSONWriter object() throws JSONException {
- if (mode == 'i') {
- mode = 'o';
- }
- if ((mode == 'o') || (mode == 'a')) {
- append("{");
- push(new JSONObject());
- comma = false;
- return this;
- }
- throw new JSONException("Misplaced object.");
- }
-
- /**
- * Pop an array or object scope.
- *
- * @param c The scope to close.
- * @throws JSONException If nesting is wrong.
- */
- private void pop(final char c) throws JSONException {
- if (top <= 0) {
- throw new JSONException("Nesting error.");
- }
- final char m = stack[top - 1] == null ? 'a' : 'k';
- if (m != c) {
- throw new JSONException("Nesting error.");
- }
- top -= 1;
- mode = top == 0 ? 'd' : stack[top - 1] == null ? 'a' : 'k';
- }
-
- /**
- * Push an array or object scope.
- *
- * @param jo The scope to open.
- * @throws JSONException If nesting is too deep.
- */
- private void push(final JSONObject jo) throws JSONException {
- if (top >= maxdepth) {
- throw new JSONException("Nesting too deep.");
- }
- stack[top] = jo;
- mode = jo == null ? 'a' : 'k';
- top += 1;
- }
-
- /**
- * Append either the value true
or the value false
.
- *
- * @param b A boolean.
- * @return this
- * @throws JSONException
- */
- public JSONWriter value(final boolean b) throws JSONException {
- return append(b ? "true" : "false");
- }
-
- /**
- * Append a double value.
- *
- * @param d A double.
- * @return this
- * @throws JSONException If the number is not finite.
- */
- public JSONWriter value(final double d) throws JSONException {
- return this.value(new Double(d));
- }
-
- /**
- * Append a long value.
- *
- * @param l A long.
- * @return this
- * @throws JSONException
- */
- public JSONWriter value(final long l) throws JSONException {
- return append(Long.toString(l));
- }
-
- /**
- * Append an object value.
- *
- * @param object The object to append. It can be null, or a Boolean, Number, String, JSONObject, or JSONArray, or an
- * object that implements JSONString.
- * @return this
- * @throws JSONException If the value is out of sequence.
- */
- public JSONWriter value(final Object object) throws JSONException {
- return append(JSONObject.valueToString(object));
- }
-}
diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/Kim.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/json/Kim.java
deleted file mode 100644
index adf696179..000000000
--- a/Core/src/main/java/com/github/intellectualsites/plotsquared/json/Kim.java
+++ /dev/null
@@ -1,303 +0,0 @@
-package com.github.intellectualsites.plotsquared.json;
-
-/**
- * Kim makes immutable eight bit Unicode strings. If the MSB of a byte is set, then the next byte is a continuation
- * byte. The last byte of a character never has the MSB reset. Every byte that is not the last byte has the MSB set. Kim
- * stands for "Keep it minimal". A Unicode character is never longer than 3 bytes. Every byte contributes 7 bits to the
- * character. ASCII is unmodified.
- *