1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
160 debug("Start Tag: " + tag.getHTMLTag() + " pos: " + getCurrentPos());
161 } else {
162 debug("Start Tag: " + tag.getHTMLTag() + " attributes: " +
163 getAttributes() + " pos: " + getCurrentPos());
164 }
165 }
166 if (tag.fictional()) {
167 SimpleAttributeSet attrs = new SimpleAttributeSet();
168 attrs.addAttribute(HTMLEditorKit.ParserCallback.IMPLIED,
169 Boolean.TRUE);
170 callback.handleStartTag(tag.getHTMLTag(), attrs,
171 getBlockStartPosition());
172 } else {
173 callback.handleStartTag(tag.getHTMLTag(), getAttributes(),
174 getBlockStartPosition());
175 flushAttributes();
176 }
177 }
178
179
180 protected void handleComment(char text[]) {
181 if (debugFlag) {
182 debug("comment: ->" + new String(text) + "<-"
183 + " pos: " + getCurrentPos());
184 }
185 callback.handleComment(text, getBlockStartPosition());
186 }
187
188 /**
189 * Handle Empty Tag.
190 */
191 protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException {
192
193 Element elem = tag.getElement();
194 if (elem == dtd.meta && !ignoreCharSet) {
195 SimpleAttributeSet atts = getAttributes();
196 if (atts != null) {
197 String content = (String)atts.getAttribute(HTML.Attribute.CONTENT);
198 if (content != null) {
199 if ("content-type".equalsIgnoreCase((String)atts.getAttribute(HTML.Attribute.HTTPEQUIV))) {
200 if (!content.equalsIgnoreCase("text/html") &&
240 } else if (elem == dtd.title) {
241 intitle--;
242 seentitle = true;
243 } else if (elem == dtd.head) {
244 inhead--;
245 } else if (elem == dtd.style) {
246 instyle--;
247 } else if (elem == dtd.script) {
248 inscript--;
249 }
250 if (debugFlag) {
251 debug("End Tag: " + tag.getHTMLTag() + " pos: " + getCurrentPos());
252 }
253 callback.handleEndTag(tag.getHTMLTag(), getBlockStartPosition());
254
255 }
256
257 /**
258 * Handle Text.
259 */
260 protected void handleText(char data[]) {
261 if (data != null) {
262 if (inscript != 0) {
263 callback.handleComment(data, getBlockStartPosition());
264 return;
265 }
266 if (inbody != 0 || ((instyle != 0) ||
267 ((intitle != 0) && !seentitle))) {
268 if (debugFlag) {
269 debug("text: ->" + new String(data) + "<-" + " pos: " + getCurrentPos());
270 }
271 callback.handleText(data, getBlockStartPosition());
272 }
273 }
274 }
275
276 /*
277 * Error handling.
278 */
279 protected void handleError(int ln, String errorMsg) {
280 if (debugFlag) {
|
1 /*
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
160 debug("Start Tag: " + tag.getHTMLTag() + " pos: " + getCurrentPos());
161 } else {
162 debug("Start Tag: " + tag.getHTMLTag() + " attributes: " +
163 getAttributes() + " pos: " + getCurrentPos());
164 }
165 }
166 if (tag.fictional()) {
167 SimpleAttributeSet attrs = new SimpleAttributeSet();
168 attrs.addAttribute(HTMLEditorKit.ParserCallback.IMPLIED,
169 Boolean.TRUE);
170 callback.handleStartTag(tag.getHTMLTag(), attrs,
171 getBlockStartPosition());
172 } else {
173 callback.handleStartTag(tag.getHTMLTag(), getAttributes(),
174 getBlockStartPosition());
175 flushAttributes();
176 }
177 }
178
179
180 protected void handleComment(char[] text) {
181 if (debugFlag) {
182 debug("comment: ->" + new String(text) + "<-"
183 + " pos: " + getCurrentPos());
184 }
185 callback.handleComment(text, getBlockStartPosition());
186 }
187
188 /**
189 * Handle Empty Tag.
190 */
191 protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException {
192
193 Element elem = tag.getElement();
194 if (elem == dtd.meta && !ignoreCharSet) {
195 SimpleAttributeSet atts = getAttributes();
196 if (atts != null) {
197 String content = (String)atts.getAttribute(HTML.Attribute.CONTENT);
198 if (content != null) {
199 if ("content-type".equalsIgnoreCase((String)atts.getAttribute(HTML.Attribute.HTTPEQUIV))) {
200 if (!content.equalsIgnoreCase("text/html") &&
240 } else if (elem == dtd.title) {
241 intitle--;
242 seentitle = true;
243 } else if (elem == dtd.head) {
244 inhead--;
245 } else if (elem == dtd.style) {
246 instyle--;
247 } else if (elem == dtd.script) {
248 inscript--;
249 }
250 if (debugFlag) {
251 debug("End Tag: " + tag.getHTMLTag() + " pos: " + getCurrentPos());
252 }
253 callback.handleEndTag(tag.getHTMLTag(), getBlockStartPosition());
254
255 }
256
257 /**
258 * Handle Text.
259 */
260 protected void handleText(char[] data) {
261 if (data != null) {
262 if (inscript != 0) {
263 callback.handleComment(data, getBlockStartPosition());
264 return;
265 }
266 if (inbody != 0 || ((instyle != 0) ||
267 ((intitle != 0) && !seentitle))) {
268 if (debugFlag) {
269 debug("text: ->" + new String(data) + "<-" + " pos: " + getCurrentPos());
270 }
271 callback.handleText(data, getBlockStartPosition());
272 }
273 }
274 }
275
276 /*
277 * Error handling.
278 */
279 protected void handleError(int ln, String errorMsg) {
280 if (debugFlag) {
|