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)
| 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 | // <? |
no test coverage detected