MCPcopy Index your code
hub / github.com/VolmitSoftware/Adapt / parse

Method parse

src/main/java/com/volmit/adapt/util/JSONML.java:43–220  ·  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. @retu

(XMLTokener x, boolean arrayForm, JSONArray ja)

Source from the content-addressed store, hash-verified

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

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
moreMethod · 0.80
syntaxErrorMethod · 0.80
nextContentMethod · 0.80
skipPastMethod · 0.80
backMethod · 0.80
nextCDATAMethod · 0.80

Tested by

no test coverage detected