MCPcopy Create free account
hub / github.com/MCBans/MCBans / toString

Method toString

src/main/java/com/mcbans/plugin/org/json/JSONML.java:305–377  ·  view source on GitHub ↗

Reverse the JSONML transformation, making an XML text from a JSONArray. @param ja A JSONArray. @return An XML string. @throws JSONException

(JSONArray ja)

Source from the content-addressed store, hash-verified

303 * @throws JSONException
304 */
305 public static String toString(JSONArray ja) throws JSONException {
306 int i;
307 JSONObject jo;
308 String key;
309 @SuppressWarnings("rawtypes")
310 Iterator keys;
311 int length;
312 Object object;
313 StringBuffer sb = new StringBuffer();
314 String tagName;
315 String value;
316
317 // Emit <tagName
318
319 tagName = ja.getString(0);
320 XML.noSpace(tagName);
321 tagName = XML.escape(tagName);
322 sb.append('<');
323 sb.append(tagName);
324
325 object = ja.opt(1);
326 if (object instanceof JSONObject) {
327 i = 2;
328 jo = (JSONObject)object;
329
330 // Emit the attributes
331
332 keys = jo.keys();
333 while (keys.hasNext()) {
334 key = keys.next().toString();
335 XML.noSpace(key);
336 value = jo.optString(key);
337 if (value != null) {
338 sb.append(' ');
339 sb.append(XML.escape(key));
340 sb.append('=');
341 sb.append('"');
342 sb.append(XML.escape(value));
343 sb.append('"');
344 }
345 }
346 } else {
347 i = 1;
348 }
349
350 //Emit content in body
351
352 length = ja.length();
353 if (i >= length) {
354 sb.append('/');
355 sb.append('>');
356 } else {
357 sb.append('>');
358 do {
359 object = ja.get(i);
360 i += 1;
361 if (object != null) {
362 if (object instanceof String) {

Callers

nothing calls this directly

Calls 13

noSpaceMethod · 0.95
escapeMethod · 0.95
keysMethod · 0.95
optStringMethod · 0.95
lengthMethod · 0.95
getMethod · 0.95
nextMethod · 0.80
equalsMethod · 0.80
getStringMethod · 0.45
appendMethod · 0.45
optMethod · 0.45
optStringMethod · 0.45

Tested by

no test coverage detected