From 4990c3a180e0a2e866b13db21f04139a48b5a6d6 Mon Sep 17 00:00:00 2001 From: harkue Date: Tue, 12 Nov 2019 16:27:24 +0800 Subject: [PATCH] fix typo --- JSONArray.java | 12 ++++++------ JSONObject.java | 14 +++++++------- XML.java | 31 +++++++++++++++---------------- XMLTokener.java | 2 +- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/JSONArray.java b/JSONArray.java index 14a1b01..10e08d2 100644 --- a/JSONArray.java +++ b/JSONArray.java @@ -1409,7 +1409,7 @@ public class JSONArray implements Iterable { public Writer write(Writer writer, int indentFactor, int indent) throws JSONException { try { - boolean commanate = false; + boolean hasComma = false; int length = this.length(); writer.write('['); @@ -1421,23 +1421,23 @@ public class JSONArray implements Iterable { throw new JSONException("Unable to write JSONArray value at index: 0", e); } } else if (length != 0) { - final int newindent = indent + indentFactor; + final int newIndent = indent + indentFactor; for (int i = 0; i < length; i += 1) { - if (commanate) { + if (hasComma) { writer.write(','); } if (indentFactor > 0) { writer.write('\n'); } - JSONObject.indent(writer, newindent); + JSONObject.indent(writer, newIndent); try { JSONObject.writeValue(writer, this.myArrayList.get(i), - indentFactor, newindent); + indentFactor, newIndent); } catch (Exception e) { throw new JSONException("Unable to write JSONArray value at index: " + i, e); } - commanate = true; + hasComma = true; } if (indentFactor > 0) { writer.write('\n'); diff --git a/JSONObject.java b/JSONObject.java index a6bfcea..90de2e4 100644 --- a/JSONObject.java +++ b/JSONObject.java @@ -2141,7 +2141,7 @@ public class JSONObject { //} //return new BigInteger(val); - // BigInteger version: We use a similar bitLenth compare as + // BigInteger version: We use a similar bitLength compare as // BigInteger#intValueExact uses. Increases GC, but objects hold // only what they need. i.e. Less runtime overhead if the value is // long lived. Which is the better tradeoff? This is closer to what's @@ -2496,7 +2496,7 @@ public class JSONObject { public Writer write(Writer writer, int indentFactor, int indent) throws JSONException { try { - boolean commanate = false; + boolean hasComma = false; final int length = this.length(); writer.write('{'); @@ -2514,15 +2514,15 @@ public class JSONObject { throw new JSONException("Unable to write JSONObject value for key: " + key, e); } } else if (length != 0) { - final int newindent = indent + indentFactor; + final int newIndent = indent + indentFactor; for (final Entry entry : this.entrySet()) { - if (commanate) { + if (hasComma) { writer.write(','); } if (indentFactor > 0) { writer.write('\n'); } - indent(writer, newindent); + indent(writer, newIndent); final String key = entry.getKey(); writer.write(quote(key)); writer.write(':'); @@ -2530,11 +2530,11 @@ public class JSONObject { writer.write(' '); } try { - writeValue(writer, entry.getValue(), indentFactor, newindent); + writeValue(writer, entry.getValue(), indentFactor, newIndent); } catch (Exception e) { throw new JSONException("Unable to write JSONObject value for key: " + key, e); } - commanate = true; + hasComma = true; } if (indentFactor > 0) { writer.write('\n'); diff --git a/XML.java b/XML.java index f660d23..f506f67 100644 --- a/XML.java +++ b/XML.java @@ -66,7 +66,7 @@ public class XML { public static final Character SLASH = '/'; /** - * Null attrubute name + * Null attribute name */ public static final String NULL_ATTR = "xsi:nil"; @@ -251,7 +251,7 @@ public class XML { throws JSONException { char c; int i; - JSONObject jsonobject = null; + JSONObject jsonObject = null; String string; String tagName; Object token; @@ -332,7 +332,7 @@ public class XML { } else { tagName = (String) token; token = null; - jsonobject = new JSONObject(); + jsonObject = new JSONObject(); boolean nilAttributeFound = false; for (;;) { if (token == null) { @@ -353,14 +353,14 @@ public class XML { && Boolean.parseBoolean((String) token)) { nilAttributeFound = true; } else if (!nilAttributeFound) { - jsonobject.accumulate(string, + jsonObject.accumulate(string, config.keepStrings ? ((String) token) : stringToValue((String) token)); } token = null; } else { - jsonobject.accumulate(string, ""); + jsonObject.accumulate(string, ""); } @@ -371,8 +371,8 @@ public class XML { } if (nilAttributeFound) { context.accumulate(tagName, JSONObject.NULL); - } else if (jsonobject.length() > 0) { - context.accumulate(tagName, jsonobject); + } else if (jsonObject.length() > 0) { + context.accumulate(tagName, jsonObject); } else { context.accumulate(tagName, ""); } @@ -390,21 +390,20 @@ public class XML { } else if (token instanceof String) { string = (String) token; if (string.length() > 0) { - jsonobject.accumulate(config.cDataTagName, + jsonObject.accumulate(config.cDataTagName, config.keepStrings ? string : stringToValue(string)); } } else if (token == LT) { // Nested element - if (parse(x, jsonobject, tagName, config)) { - if (jsonobject.length() == 0) { + if (parse(x, jsonObject, tagName, config)) { + if (jsonObject.length() == 0) { context.accumulate(tagName, ""); - } else if (jsonobject.length() == 1 - && jsonobject.opt(config.cDataTagName) != null) { - context.accumulate(tagName, - jsonobject.opt(config.cDataTagName)); + } else if (jsonObject.length() == 1 + && jsonObject.opt(config.cDataTagName) != null) { + context.accumulate(tagName, jsonObject.opt(config.cDataTagName)); } else { - context.accumulate(tagName, jsonobject); + context.accumulate(tagName, jsonObject); } return false; } @@ -731,7 +730,7 @@ public class XML { } if (tagName != null) { - // Emit the close tag + // Emit the close tag sb.append("'); diff --git a/XMLTokener.java b/XMLTokener.java index d733447..a9d20b7 100644 --- a/XMLTokener.java +++ b/XMLTokener.java @@ -152,7 +152,7 @@ public class XMLTokener extends JSONTokener { } /** - * Unescapes an XML entity encoding; + * Unescape an XML entity encoding; * @param e entity (only the actual entity value, not the preceding & or ending ; * @return */