@@ -31,11 +31,11 @@ of this software and associated documentation files (the "Software"), to deal
31
31
* This provides static methods to convert an XML text into a JSONObject,
32
32
* and to covert a JSONObject into an XML text.
33
33
* @author JSON.org
34
- * @version 2011-02-11
34
+ * @version 2012-10-26
35
35
*/
36
36
public class XML {
37
37
38
- /** The Character '&'. */
38
+ /** The Character '& '. */
39
39
public static final Character AMP = new Character ('&' );
40
40
41
41
/** The Character '''. */
@@ -50,7 +50,7 @@ public class XML {
50
50
/** The Character '>'. */
51
51
public static final Character GT = new Character ('>' );
52
52
53
- /** The Character '< '. */
53
+ /** The Character '< '. */
54
54
public static final Character LT = new Character ('<' );
55
55
56
56
/** The Character '?'. */
@@ -99,9 +99,9 @@ public static String escape(String string) {
99
99
}
100
100
return sb .toString ();
101
101
}
102
-
102
+
103
103
/**
104
- * Throw an exception if the string contains whitespace.
104
+ * Throw an exception if the string contains whitespace.
105
105
* Whitespace is not allowed in tagNames and attributes.
106
106
* @param string
107
107
* @throws JSONException
@@ -113,7 +113,7 @@ public static void noSpace(String string) throws JSONException {
113
113
}
114
114
for (i = 0 ; i < length ; i += 1 ) {
115
115
if (Character .isWhitespace (string .charAt (i ))) {
116
- throw new JSONException ("'" + string +
116
+ throw new JSONException ("'" + string +
117
117
"' contains a space character." );
118
118
}
119
119
}
@@ -196,7 +196,7 @@ private static boolean parse(XMLTokener x, JSONObject context,
196
196
token = x .nextToken ();
197
197
if (name == null ) {
198
198
throw x .syntaxError ("Mismatched close tag " + token );
199
- }
199
+ }
200
200
if (!token .equals (name )) {
201
201
throw x .syntaxError ("Mismatched " + name + " and " + token );
202
202
}
@@ -229,7 +229,7 @@ private static boolean parse(XMLTokener x, JSONObject context,
229
229
if (!(token instanceof String )) {
230
230
throw x .syntaxError ("Missing value" );
231
231
}
232
- jsonobject .accumulate (string ,
232
+ jsonobject .accumulate (string ,
233
233
XML .stringToValue ((String )token ));
234
234
token = null ;
235
235
} else {
@@ -262,7 +262,7 @@ private static boolean parse(XMLTokener x, JSONObject context,
262
262
} else if (token instanceof String ) {
263
263
string = (String )token ;
264
264
if (string .length () > 0 ) {
265
- jsonobject .accumulate ("content" ,
265
+ jsonobject .accumulate ("content" ,
266
266
XML .stringToValue (string ));
267
267
}
268
268
@@ -274,7 +274,7 @@ private static boolean parse(XMLTokener x, JSONObject context,
274
274
context .accumulate (tagName , "" );
275
275
} else if (jsonobject .length () == 1 &&
276
276
jsonobject .opt ("content" ) != null ) {
277
- context .accumulate (tagName ,
277
+ context .accumulate (tagName ,
278
278
jsonobject .opt ("content" ));
279
279
} else {
280
280
context .accumulate (tagName , jsonobject );
@@ -295,7 +295,7 @@ private static boolean parse(XMLTokener x, JSONObject context,
295
295
* Try to convert a string into a number, boolean, or null. If the string
296
296
* can't be converted, return the string. This is much less ambitious than
297
297
* JSONObject.stringToValue, especially because it does not attempt to
298
- * convert plus forms, octal forms, hex forms, or E forms lacking decimal
298
+ * convert plus forms, octal forms, hex forms, or E forms lacking decimal
299
299
* points.
300
300
* @param string A String.
301
301
* @return A simple JSON value.
@@ -317,7 +317,7 @@ public static Object stringToValue(String string) {
317
317
return new Integer (0 );
318
318
}
319
319
320
- // If it might be a number, try converting it. If that doesn't work,
320
+ // If it might be a number, try converting it. If that doesn't work,
321
321
// return the string.
322
322
323
323
try {
@@ -347,7 +347,7 @@ public static Object stringToValue(String string) {
347
347
return string ;
348
348
}
349
349
350
-
350
+
351
351
/**
352
352
* Convert a well-formed (but not necessarily valid) XML string into a
353
353
* JSONObject. Some information may be lost in this transformation
@@ -505,4 +505,4 @@ public static String toString(Object object, String tagName)
505
505
}
506
506
}
507
507
}
508
- }
508
+ }
0 commit comments