Search in sources :

Example 1 with ChangedCharSetException

use of javax.swing.text.ChangedCharSetException in project jdk8u_jdk by JetBrains.

the class DocumentParser method handleEmptyTag.

/**
     * Handle Empty Tag.
     */
protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException {
    Element elem = tag.getElement();
    if (elem == dtd.meta && !ignoreCharSet) {
        SimpleAttributeSet atts = getAttributes();
        if (atts != null) {
            String content = (String) atts.getAttribute(HTML.Attribute.CONTENT);
            if (content != null) {
                if ("content-type".equalsIgnoreCase((String) atts.getAttribute(HTML.Attribute.HTTPEQUIV))) {
                    if (!content.equalsIgnoreCase("text/html") && !content.equalsIgnoreCase("text/plain")) {
                        throw new ChangedCharSetException(content, false);
                    }
                } else if ("charset".equalsIgnoreCase((String) atts.getAttribute(HTML.Attribute.HTTPEQUIV))) {
                    throw new ChangedCharSetException(content, true);
                }
            }
        }
    }
    if (inbody != 0 || elem == dtd.meta || elem == dtd.base || elem == dtd.isindex || elem == dtd.style || elem == dtd.link) {
        if (debugFlag) {
            if (tag.fictional()) {
                debug("Empty Tag: " + tag.getHTMLTag() + " pos: " + getCurrentPos());
            } else {
                debug("Empty Tag: " + tag.getHTMLTag() + " attributes: " + getAttributes() + " pos: " + getCurrentPos());
            }
        }
        if (tag.fictional()) {
            SimpleAttributeSet attrs = new SimpleAttributeSet();
            attrs.addAttribute(HTMLEditorKit.ParserCallback.IMPLIED, Boolean.TRUE);
            callback.handleSimpleTag(tag.getHTMLTag(), attrs, getBlockStartPosition());
        } else {
            callback.handleSimpleTag(tag.getHTMLTag(), getAttributes(), getBlockStartPosition());
            flushAttributes();
        }
    }
}
Also used : SimpleAttributeSet(javax.swing.text.SimpleAttributeSet) ChangedCharSetException(javax.swing.text.ChangedCharSetException)

Aggregations

ChangedCharSetException (javax.swing.text.ChangedCharSetException)1 SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)1