Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo #495

Merged
merged 2 commits into from Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions JSONArray.java
Expand Up @@ -1409,7 +1409,7 @@ public Writer write(Writer writer) throws JSONException {
public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {
try {
boolean commanate = false;
harkue marked this conversation as resolved.
Show resolved Hide resolved
boolean hasComma = false;
int length = this.length();
writer.write('[');

Expand All @@ -1421,23 +1421,23 @@ public Writer write(Writer writer, int indentFactor, int indent)
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');
Expand Down
14 changes: 7 additions & 7 deletions JSONObject.java
Expand Up @@ -2141,7 +2141,7 @@ protected static Number stringToNumber(final String val) throws NumberFormatExce
//}
//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
Expand Down Expand Up @@ -2496,7 +2496,7 @@ static final void indent(Writer writer, int indent) throws IOException {
public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {
try {
boolean commanate = false;
harkue marked this conversation as resolved.
Show resolved Hide resolved
boolean hasComma = false;
final int length = this.length();
writer.write('{');

Expand All @@ -2514,27 +2514,27 @@ public Writer write(Writer writer, int indentFactor, int indent)
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<String,?> 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(':');
if (indentFactor > 0) {
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');
Expand Down
31 changes: 15 additions & 16 deletions XML.java
Expand Up @@ -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";

Expand Down Expand Up @@ -251,7 +251,7 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP
throws JSONException {
char c;
int i;
JSONObject jsonobject = null;
JSONObject jsonObject = null;
String string;
String tagName;
Object token;
Expand Down Expand Up @@ -332,7 +332,7 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP
} else {
tagName = (String) token;
token = null;
jsonobject = new JSONObject();
jsonObject = new JSONObject();
boolean nilAttributeFound = false;
for (;;) {
if (token == null) {
Expand All @@ -353,14 +353,14 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP
&& 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, "");
}


Expand All @@ -371,8 +371,8 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP
}
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, "");
}
Expand All @@ -390,21 +390,20 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, XMLP
} 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;
}
Expand Down Expand Up @@ -731,7 +730,7 @@ public static String toString(final Object object, final String tagName, final X
}
if (tagName != null) {

// Emit the </tagname> close tag
// Emit the </tagName> close tag
sb.append("</");
sb.append(tagName);
sb.append('>');
Expand Down
2 changes: 1 addition & 1 deletion XMLTokener.java
Expand Up @@ -152,7 +152,7 @@ public Object nextEntity(@SuppressWarnings("unused") char ampersand) throws JSON
}

/**
* Unescapes an XML entity encoding;
* Unescape an XML entity encoding;
* @param e entity (only the actual entity value, not the preceding & or ending ;
* @return
*/
Expand Down