IDEA Auto Inspect
This commit is contained in:
@@ -69,7 +69,7 @@ public class CDL {
|
||||
}
|
||||
|
||||
public static String rowToString(JSONArray ja) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < ja.length(); i += 1) {
|
||||
if (i > 0) {
|
||||
sb.append(',');
|
||||
@@ -146,7 +146,7 @@ public class CDL {
|
||||
if (names == null || names.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < ja.length(); i += 1) {
|
||||
JSONObject jo = ja.optJSONObject(i);
|
||||
if (jo != null) {
|
||||
|
||||
@@ -5,7 +5,7 @@ public class Cookie {
|
||||
public static String escape(String string) {
|
||||
char c;
|
||||
String s = string.trim();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int length = s.length();
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
c = s.charAt(i);
|
||||
@@ -47,7 +47,7 @@ public class Cookie {
|
||||
}
|
||||
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(escape(jo.getString("name")));
|
||||
sb.append("=");
|
||||
@@ -72,7 +72,7 @@ public class Cookie {
|
||||
|
||||
public static String unescape(String string) {
|
||||
int length = string.length();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
char c = string.charAt(i);
|
||||
if (c == '+') {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CookieList {
|
||||
boolean b = false;
|
||||
Iterator keys = jo.keys();
|
||||
String string;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (keys.hasNext()) {
|
||||
string = keys.next().toString();
|
||||
if (!jo.isNull(string)) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class HTTP {
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
Iterator keys = jo.keys();
|
||||
String string;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (jo.has("Status-Code") && jo.has("Reason-Phrase")) {
|
||||
sb.append(jo.getString("HTTP-Version"));
|
||||
sb.append(' ');
|
||||
|
||||
@@ -9,7 +9,7 @@ public class HTTPTokener extends JSONTokener {
|
||||
public String nextToken() throws JSONException {
|
||||
char c;
|
||||
char q;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
do {
|
||||
c = next();
|
||||
} while (Character.isWhitespace(c));
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@@ -57,9 +56,8 @@ public class JSONArray {
|
||||
public JSONArray(Collection collection) {
|
||||
this.myArrayList = new ArrayList();
|
||||
if (collection != null) {
|
||||
Iterator iter = collection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
this.myArrayList.add(JSONObject.wrap(iter.next()));
|
||||
for (Object aCollection : collection) {
|
||||
this.myArrayList.add(JSONObject.wrap(aCollection));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +164,7 @@ public class JSONArray {
|
||||
|
||||
public String join(String separator) throws JSONException {
|
||||
int len = this.length();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < len; i += 1) {
|
||||
if (i > 0) {
|
||||
@@ -267,7 +265,7 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
public JSONArray put(double value) throws JSONException {
|
||||
Double d = new Double(value);
|
||||
Double d = value;
|
||||
JSONObject.testValidity(d);
|
||||
this.put(d);
|
||||
return this;
|
||||
|
||||
@@ -40,33 +40,37 @@ public class JSONML {
|
||||
return token;
|
||||
} else if (token == XML.BANG) {
|
||||
c = x.next();
|
||||
if (c == '-') {
|
||||
if (x.next() == '-') {
|
||||
x.skipPast("-->");
|
||||
} else {
|
||||
x.back();
|
||||
}
|
||||
} else if (c == '[') {
|
||||
token = x.nextToken();
|
||||
if (token.equals("CDATA") && x.next() == '[') {
|
||||
if (ja != null) {
|
||||
ja.put(x.nextCDATA());
|
||||
switch (c) {
|
||||
case '-':
|
||||
if (x.next() == '-') {
|
||||
x.skipPast("-->");
|
||||
} else {
|
||||
x.back();
|
||||
}
|
||||
} else {
|
||||
throw x.syntaxError("Expected 'CDATA['");
|
||||
}
|
||||
} else {
|
||||
i = 1;
|
||||
do {
|
||||
token = x.nextMeta();
|
||||
if (token == null) {
|
||||
throw x.syntaxError("Missing '>' after '<!'.");
|
||||
} else if (token == XML.LT) {
|
||||
i += 1;
|
||||
} else if (token == XML.GT) {
|
||||
i -= 1;
|
||||
break;
|
||||
case '[':
|
||||
token = x.nextToken();
|
||||
if (token.equals("CDATA") && x.next() == '[') {
|
||||
if (ja != null) {
|
||||
ja.put(x.nextCDATA());
|
||||
}
|
||||
} else {
|
||||
throw x.syntaxError("Expected 'CDATA['");
|
||||
}
|
||||
} while (i > 0);
|
||||
break;
|
||||
default:
|
||||
i = 1;
|
||||
do {
|
||||
token = x.nextMeta();
|
||||
if (token == null) {
|
||||
throw x.syntaxError("Missing '>' after '<!'.");
|
||||
} else if (token == XML.LT) {
|
||||
i += 1;
|
||||
} else if (token == XML.GT) {
|
||||
i -= 1;
|
||||
}
|
||||
} while (i > 0);
|
||||
break;
|
||||
}
|
||||
} else if (token == XML.QUEST) {
|
||||
x.skipPast("?>");
|
||||
@@ -189,7 +193,7 @@ public class JSONML {
|
||||
Iterator keys;
|
||||
int length;
|
||||
Object object;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String tagName;
|
||||
String value;
|
||||
tagName = ja.getString(0);
|
||||
@@ -247,7 +251,7 @@ public class JSONML {
|
||||
}
|
||||
|
||||
public static String toString(JSONObject jo) throws JSONException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i;
|
||||
JSONArray ja;
|
||||
String key;
|
||||
|
||||
@@ -6,13 +6,7 @@ import java.io.Writer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public class JSONObject {
|
||||
@@ -42,9 +36,9 @@ public class JSONObject {
|
||||
|
||||
public JSONObject(JSONObject jo, String[] names) {
|
||||
this();
|
||||
for (int i = 0; i < names.length; i += 1) {
|
||||
for (String name : names) {
|
||||
try {
|
||||
this.putOnce(names[i], jo.opt(names[i]));
|
||||
this.putOnce(name, jo.opt(name));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
@@ -97,9 +91,8 @@ public class JSONObject {
|
||||
public JSONObject(Map map) {
|
||||
this.map = new HashMap();
|
||||
if (map != null) {
|
||||
Iterator i = map.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry e = (Map.Entry)i.next();
|
||||
for (Object o : map.entrySet()) {
|
||||
Map.Entry e = (Map.Entry) o;
|
||||
Object value = e.getValue();
|
||||
if (value != null) {
|
||||
this.map.put(e.getKey(), wrap(value));
|
||||
@@ -116,8 +109,7 @@ public class JSONObject {
|
||||
public JSONObject(Object object, String names[]) {
|
||||
this();
|
||||
Class c = object.getClass();
|
||||
for (int i = 0; i < names.length; i += 1) {
|
||||
String name = names[i];
|
||||
for (String name : names) {
|
||||
try {
|
||||
this.putOpt(name, c.getField(name).get(object));
|
||||
} catch (Exception ignore) {
|
||||
@@ -329,22 +321,41 @@ public class JSONObject {
|
||||
return this.map.containsKey(key);
|
||||
}
|
||||
|
||||
public JSONObject increment(String key) throws JSONException {
|
||||
Object value = this.opt(key);
|
||||
if (value == null) {
|
||||
this.put(key, 1);
|
||||
} else if (value instanceof Integer) {
|
||||
this.put(key, ((Integer)value).intValue() + 1);
|
||||
} else if (value instanceof Long) {
|
||||
this.put(key, ((Long)value).longValue() + 1);
|
||||
} else if (value instanceof Double) {
|
||||
this.put(key, ((Double)value).doubleValue() + 1);
|
||||
} else if (value instanceof Float) {
|
||||
this.put(key, ((Float)value).floatValue() + 1);
|
||||
} else {
|
||||
throw new JSONException("Unable to increment [" + quote(key) + "].");
|
||||
public static Object stringToValue(String string) {
|
||||
Double d;
|
||||
if (string.equals("")) {
|
||||
return string;
|
||||
}
|
||||
return this;
|
||||
if (string.equalsIgnoreCase("true")) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if (string.equalsIgnoreCase("false")) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
if (string.equalsIgnoreCase("null")) {
|
||||
return JSONObject.NULL;
|
||||
}
|
||||
char b = string.charAt(0);
|
||||
if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
|
||||
try {
|
||||
if (string.indexOf('.') > -1 ||
|
||||
string.indexOf('e') > -1 || string.indexOf('E') > -1) {
|
||||
d = Double.valueOf(string);
|
||||
if (!d.isInfinite() && !d.isNaN()) {
|
||||
return d;
|
||||
}
|
||||
} else {
|
||||
Long myLong = new Long(string);
|
||||
if (myLong == myLong.intValue()) {
|
||||
return myLong.intValue();
|
||||
} else {
|
||||
return myLong;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public boolean isNull(String key) {
|
||||
@@ -458,49 +469,39 @@ public class JSONObject {
|
||||
return NULL.equals(object) ? defaultValue : object.toString();
|
||||
}
|
||||
|
||||
|
||||
private void populateMap(Object bean) {
|
||||
Class klass = bean.getClass();
|
||||
boolean includeSuperClass = klass.getClassLoader() != null;
|
||||
|
||||
Method[] methods = includeSuperClass
|
||||
? klass.getMethods()
|
||||
: klass.getDeclaredMethods();
|
||||
for (int i = 0; i < methods.length; i += 1) {
|
||||
try {
|
||||
Method method = methods[i];
|
||||
if (Modifier.isPublic(method.getModifiers())) {
|
||||
String name = method.getName();
|
||||
String key = "";
|
||||
if (name.startsWith("get")) {
|
||||
if ("getClass".equals(name) ||
|
||||
"getDeclaringClass".equals(name)) {
|
||||
key = "";
|
||||
} else {
|
||||
key = name.substring(3);
|
||||
}
|
||||
} else if (name.startsWith("is")) {
|
||||
key = name.substring(2);
|
||||
}
|
||||
if (key.length() > 0 &&
|
||||
Character.isUpperCase(key.charAt(0)) &&
|
||||
method.getParameterTypes().length == 0) {
|
||||
if (key.length() == 1) {
|
||||
key = key.toLowerCase();
|
||||
} else if (!Character.isUpperCase(key.charAt(1))) {
|
||||
key = key.substring(0, 1).toLowerCase() +
|
||||
key.substring(1);
|
||||
}
|
||||
|
||||
Object result = method.invoke(bean, (Object[])null);
|
||||
if (result != null) {
|
||||
this.map.put(key, wrap(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
public static String valueToString(Object value) throws JSONException {
|
||||
if (value == null || value == null) {
|
||||
return "null";
|
||||
}
|
||||
if (value instanceof JSONString) {
|
||||
Object object;
|
||||
try {
|
||||
object = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
}
|
||||
throw new JSONException("Bad value from toJSONString: " + object);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return numberToString((Number) value);
|
||||
}
|
||||
if (value instanceof Boolean || value instanceof JSONObject ||
|
||||
value instanceof JSONArray) {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
return new JSONObject((Map) value).toString();
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
return new JSONArray((Collection) value).toString();
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return new JSONArray(value).toString();
|
||||
}
|
||||
return quote(value.toString());
|
||||
}
|
||||
|
||||
public JSONObject put(String key, boolean value) throws JSONException {
|
||||
@@ -635,41 +636,37 @@ public class JSONObject {
|
||||
return this.map.remove(key);
|
||||
}
|
||||
|
||||
public static Object stringToValue(String string) {
|
||||
Double d;
|
||||
if (string.equals("")) {
|
||||
return string;
|
||||
}
|
||||
if (string.equalsIgnoreCase("true")) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if (string.equalsIgnoreCase("false")) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
if (string.equalsIgnoreCase("null")) {
|
||||
return JSONObject.NULL;
|
||||
}
|
||||
char b = string.charAt(0);
|
||||
if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
|
||||
static Writer writeValue(Writer writer, Object value,
|
||||
int indentFactor, int indent) throws JSONException, IOException {
|
||||
if (value == null || value == null) {
|
||||
writer.write("null");
|
||||
} else if (value instanceof JSONObject) {
|
||||
((JSONObject) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof JSONArray) {
|
||||
((JSONArray) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Map) {
|
||||
new JSONObject((Map) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Collection) {
|
||||
new JSONArray((Collection) value).write(writer, indentFactor,
|
||||
indent);
|
||||
} else if (value.getClass().isArray()) {
|
||||
new JSONArray(value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Number) {
|
||||
writer.write(numberToString((Number) value));
|
||||
} else if (value instanceof Boolean) {
|
||||
writer.write(value.toString());
|
||||
} else if (value instanceof JSONString) {
|
||||
Object o;
|
||||
try {
|
||||
if (string.indexOf('.') > -1 ||
|
||||
string.indexOf('e') > -1 || string.indexOf('E') > -1) {
|
||||
d = Double.valueOf(string);
|
||||
if (!d.isInfinite() && !d.isNaN()) {
|
||||
return d;
|
||||
}
|
||||
} else {
|
||||
Long myLong = new Long(string);
|
||||
if (myLong.longValue() == myLong.intValue()) {
|
||||
return new Integer(myLong.intValue());
|
||||
} else {
|
||||
return myLong;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
o = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
writer.write(o != null ? o.toString() : quote(value.toString()));
|
||||
} else {
|
||||
quote(value.toString(), writer);
|
||||
}
|
||||
return string;
|
||||
return writer;
|
||||
}
|
||||
|
||||
public static void testValidity(Object o) throws JSONException {
|
||||
@@ -714,39 +711,10 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static String valueToString(Object value) throws JSONException {
|
||||
if (value == null || value.equals(null)) {
|
||||
return "null";
|
||||
static void indent(Writer writer, int indent) throws IOException {
|
||||
for (int i = 0; i < indent; i += 1) {
|
||||
writer.write(' ');
|
||||
}
|
||||
if (value instanceof JSONString) {
|
||||
Object object;
|
||||
try {
|
||||
object = ((JSONString)value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
if (object instanceof String) {
|
||||
return (String)object;
|
||||
}
|
||||
throw new JSONException("Bad value from toJSONString: " + object);
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return numberToString((Number) value);
|
||||
}
|
||||
if (value instanceof Boolean || value instanceof JSONObject ||
|
||||
value instanceof JSONArray) {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof Map) {
|
||||
return new JSONObject((Map)value).toString();
|
||||
}
|
||||
if (value instanceof Collection) {
|
||||
return new JSONArray((Collection)value).toString();
|
||||
}
|
||||
if (value.getClass().isArray()) {
|
||||
return new JSONArray(value).toString();
|
||||
}
|
||||
return quote(value.toString());
|
||||
}
|
||||
|
||||
public static Object wrap(Object object) {
|
||||
@@ -794,43 +762,65 @@ public class JSONObject {
|
||||
return this.write(writer, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static final Writer writeValue(Writer writer, Object value,
|
||||
int indentFactor, int indent) throws JSONException, IOException {
|
||||
if (value == null || value.equals(null)) {
|
||||
writer.write("null");
|
||||
} else if (value instanceof JSONObject) {
|
||||
((JSONObject) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof JSONArray) {
|
||||
((JSONArray) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Map) {
|
||||
new JSONObject((Map) value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Collection) {
|
||||
new JSONArray((Collection) value).write(writer, indentFactor,
|
||||
indent);
|
||||
} else if (value.getClass().isArray()) {
|
||||
new JSONArray(value).write(writer, indentFactor, indent);
|
||||
} else if (value instanceof Number) {
|
||||
writer.write(numberToString((Number) value));
|
||||
} else if (value instanceof Boolean) {
|
||||
writer.write(value.toString());
|
||||
} else if (value instanceof JSONString) {
|
||||
Object o;
|
||||
try {
|
||||
o = ((JSONString) value).toJSONString();
|
||||
} catch (Exception e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
writer.write(o != null ? o.toString() : quote(value.toString()));
|
||||
public JSONObject increment(String key) throws JSONException {
|
||||
Object value = this.opt(key);
|
||||
if (value == null) {
|
||||
this.put(key, 1);
|
||||
} else if (value instanceof Integer) {
|
||||
this.put(key, (Integer) value + 1);
|
||||
} else if (value instanceof Long) {
|
||||
this.put(key, (Long) value + 1);
|
||||
} else if (value instanceof Double) {
|
||||
this.put(key, (Double) value + 1);
|
||||
} else if (value instanceof Float) {
|
||||
this.put(key, (Float) value + 1);
|
||||
} else {
|
||||
quote(value.toString(), writer);
|
||||
throw new JSONException("Unable to increment [" + quote(key) + "].");
|
||||
}
|
||||
return writer;
|
||||
return this;
|
||||
}
|
||||
|
||||
static final void indent(Writer writer, int indent) throws IOException {
|
||||
for (int i = 0; i < indent; i += 1) {
|
||||
writer.write(' ');
|
||||
private void populateMap(Object bean) {
|
||||
Class klass = bean.getClass();
|
||||
boolean includeSuperClass = klass.getClassLoader() != null;
|
||||
|
||||
Method[] methods = includeSuperClass
|
||||
? klass.getMethods()
|
||||
: klass.getDeclaredMethods();
|
||||
for (Method method1 : methods) {
|
||||
try {
|
||||
Method method = method1;
|
||||
if (Modifier.isPublic(method.getModifiers())) {
|
||||
String name = method.getName();
|
||||
String key = "";
|
||||
if (name.startsWith("get")) {
|
||||
if ("getClass".equals(name) ||
|
||||
"getDeclaringClass".equals(name)) {
|
||||
key = "";
|
||||
} else {
|
||||
key = name.substring(3);
|
||||
}
|
||||
} else if (name.startsWith("is")) {
|
||||
key = name.substring(2);
|
||||
}
|
||||
if (key.length() > 0 &&
|
||||
Character.isUpperCase(key.charAt(0)) &&
|
||||
method.getParameterTypes().length == 0) {
|
||||
if (key.length() == 1) {
|
||||
key = key.toLowerCase();
|
||||
} else if (!Character.isUpperCase(key.charAt(1))) {
|
||||
key = key.substring(0, 1).toLowerCase() +
|
||||
key.substring(1);
|
||||
}
|
||||
|
||||
Object result = method.invoke(bean, (Object[]) null);
|
||||
if (result != null) {
|
||||
this.map.put(key, wrap(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@ package me.skymc.taboolib.json;
|
||||
|
||||
public interface JSONString {
|
||||
|
||||
public String toJSONString();
|
||||
String toJSONString();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package me.skymc.taboolib.json;
|
||||
|
||||
|
||||
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.io.*;
|
||||
|
||||
public class JSONTokener {
|
||||
|
||||
@@ -30,7 +25,7 @@ public class JSONTokener {
|
||||
this.line = 1;
|
||||
}
|
||||
|
||||
public JSONTokener(InputStream inputStream) throws JSONException {
|
||||
public JSONTokener(InputStream inputStream) {
|
||||
this(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
@@ -143,7 +138,7 @@ public class JSONTokener {
|
||||
|
||||
public String nextString(char quote) throws JSONException {
|
||||
char c;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
c = this.next();
|
||||
switch (c) {
|
||||
@@ -192,7 +187,7 @@ public class JSONTokener {
|
||||
}
|
||||
|
||||
public String nextTo(char delimiter) throws JSONException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
char c = this.next();
|
||||
if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
|
||||
@@ -207,7 +202,7 @@ public class JSONTokener {
|
||||
|
||||
public String nextTo(String delimiters) throws JSONException {
|
||||
char c;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
c = this.next();
|
||||
if (delimiters.indexOf(c) >= 0 || c == 0 ||
|
||||
@@ -237,7 +232,7 @@ public class JSONTokener {
|
||||
return new JSONArray(this);
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
||||
sb.append(c);
|
||||
c = this.next();
|
||||
|
||||
@@ -6,26 +6,26 @@ import java.util.Iterator;
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
public class XML {
|
||||
|
||||
public static final Character AMP = new Character('&');
|
||||
public static final Character AMP = '&';
|
||||
|
||||
public static final Character APOS = new Character('\'');
|
||||
public static final Character APOS = '\'';
|
||||
|
||||
public static final Character BANG = new Character('!');
|
||||
public static final Character BANG = '!';
|
||||
|
||||
public static final Character EQ = new Character('=');
|
||||
public static final Character EQ = '=';
|
||||
|
||||
public static final Character GT = new Character('>');
|
||||
public static final Character GT = '>';
|
||||
|
||||
public static final Character LT = new Character('<');
|
||||
public static final Character LT = '<';
|
||||
|
||||
public static final Character QUEST = new Character('?');
|
||||
public static final Character QUEST = '?';
|
||||
|
||||
public static final Character QUOT = new Character('"');
|
||||
public static final Character QUOT = '"';
|
||||
|
||||
public static final Character SLASH = new Character('/');
|
||||
public static final Character SLASH = '/';
|
||||
|
||||
public static String escape(String string) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0, length = string.length(); i < length; i++) {
|
||||
char c = string.charAt(i);
|
||||
switch (c) {
|
||||
@@ -206,7 +206,7 @@ public class XML {
|
||||
return JSONObject.NULL;
|
||||
}
|
||||
if ("0".equals(string)) {
|
||||
return new Integer(0);
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
char initial = string.charAt(0);
|
||||
@@ -223,8 +223,8 @@ public class XML {
|
||||
return Double.valueOf(string);
|
||||
} else if (string.indexOf('e') < 0 && string.indexOf('E') < 0) {
|
||||
Long myLong = new Long(string);
|
||||
if (myLong.longValue() == myLong.intValue()) {
|
||||
return new Integer(myLong.intValue());
|
||||
if (myLong == myLong.intValue()) {
|
||||
return myLong.intValue();
|
||||
} else {
|
||||
return myLong;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public class XML {
|
||||
|
||||
public static String toString(Object object, String tagName)
|
||||
throws JSONException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i;
|
||||
JSONArray ja;
|
||||
JSONObject jo;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class XMLTokener extends JSONTokener {
|
||||
public String nextCDATA() throws JSONException {
|
||||
char c;
|
||||
int i;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
c = next();
|
||||
if (end()) {
|
||||
@@ -65,7 +65,7 @@ public class XMLTokener extends JSONTokener {
|
||||
}
|
||||
|
||||
public Object nextEntity(char ampersand) throws JSONException {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
char c = next();
|
||||
if (Character.isLetterOrDigit(c) || c == '#') {
|
||||
|
||||
Reference in New Issue
Block a user