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

Method parse

src/main/java/com/volmit/adapt/util/XML.java:144–300  ·  view source on GitHub ↗

Scan the content following the named tag, attaching it to the context. @param x The XMLTokener containing the source string. @param context The JSONObject that will include the new material. @param name The tag name. @return true if the close tag is processed.

(XMLTokener x, JSONObject context, String name)

Source from the content-addressed store, hash-verified

142 * @return true if the close tag is processed.
143 */
144 private static boolean parse(XMLTokener x, JSONObject context, String name) throws JSONException {
145 char c;
146 int i;
147 JSONObject jsonobject = null;
148 String string;
149 String tagName;
150 Object token;
151
152 // Test for and skip past these forms:
153 // <!-- ... -->
154 // <! ... >
155 // <![ ... ]]>
156 // <? ... ?>
157 // Report errors for these forms:
158 // <>
159 // <=
160 // <<
161
162 token = x.nextToken();
163
164 // <!
165
166 if (token == BANG) {
167 c = x.next();
168 if (c == '-') {
169 if (x.next() == '-') {
170 x.skipPast("-->");
171 return false;
172 }
173 x.back();
174 } else if (c == '[') {
175 token = x.nextToken();
176 if ("CDATA".equals(token)) {
177 if (x.next() == '[') {
178 string = x.nextCDATA();
179 if (string.length() > 0) {
180 context.accumulate("content", string);
181 }
182 return false;
183 }
184 }
185 throw x.syntaxError("Expected 'CDATA['");
186 }
187 i = 1;
188 do {
189 token = x.nextMeta();
190 if (token == null) {
191 throw x.syntaxError("Missing '>' after '<!'.");
192 } else if (token == LT) {
193 i += 1;
194 } else if (token == GT) {
195 i -= 1;
196 }
197 } while (i > 0);
198 return false;
199 } else if (token == QUEST) {
200
201 // <?

Callers 1

toJSONObjectMethod · 0.95

Calls 14

accumulateMethod · 0.95
stringToValueMethod · 0.95
lengthMethod · 0.95
optMethod · 0.95
skipPastMethod · 0.80
backMethod · 0.80
nextCDATAMethod · 0.80
syntaxErrorMethod · 0.80
nextMetaMethod · 0.80
nextContentMethod · 0.80
nextMethod · 0.65
nextTokenMethod · 0.45

Tested by

no test coverage detected