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

Method parse

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

Parse XML values and store them in a JSONArray. @param x The XMLTokener containing the source string. @param arrayForm true if array form, false if object form. @param ja The JSONArray that is containing the current tag or null if we are at the outermost level. @return A JSONArray if

(XMLTokener x, boolean arrayForm, 
            JSONArray ja)

Source from the content-addressed store, hash-verified

46 * @throws JSONException
47 */
48 private static Object parse(XMLTokener x, boolean arrayForm,
49 JSONArray ja) throws JSONException {
50 String attribute;
51 char c;
52 String closeTag = null;
53 int i;
54 JSONArray newja = null;
55 JSONObject newjo = null;
56 Object token;
57 String tagName = null;
58
59 // Test for and skip past these forms:
60 // <!-- ... -->
61 // <![ ... ]]>
62 // <! ... >
63 // <? ... ?>
64
65 while (true) {
66 token = x.nextContent();
67 if (token == XML.LT) {
68 token = x.nextToken();
69 if (token instanceof Character) {
70 if (token == XML.SLASH) {
71
72 // Close tag </
73
74 token = x.nextToken();
75 if (!(token instanceof String)) {
76 throw new JSONException(
77 "Expected a closing name instead of '" +
78 token + "'.");
79 }
80 if (x.nextToken() != XML.GT) {
81 throw x.syntaxError("Misshaped close tag");
82 }
83 return token;
84 } else if (token == XML.BANG) {
85
86 // <!
87
88 c = x.next();
89 if (c == '-') {
90 if (x.next() == '-') {
91 x.skipPast("-->");
92 }
93 x.back();
94 } else if (c == '[') {
95 token = x.nextToken();
96 if (token.equals("CDATA") && x.next() == '[') {
97 if (ja != null) {
98 ja.put(x.nextCDATA());
99 }
100 } else {
101 throw x.syntaxError("Expected 'CDATA['");
102 }
103 } else {
104 i = 1;
105 do {

Callers 2

toJSONArrayMethod · 0.95
toJSONObjectMethod · 0.95

Calls 15

putMethod · 0.95
putMethod · 0.95
accumulateMethod · 0.95
stringToValueMethod · 0.95
lengthMethod · 0.95
lengthMethod · 0.95
nextContentMethod · 0.80
syntaxErrorMethod · 0.80
nextMethod · 0.80
skipPastMethod · 0.80
backMethod · 0.80
equalsMethod · 0.80

Tested by

no test coverage detected