Java Code Examples for javax.swing.text.SimpleAttributeSet#getAttribute()
The following examples show how to use
javax.swing.text.SimpleAttributeSet#getAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JHtmlLabel.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
private void cacheLinkElements() { this.linkCache = new ArrayList<>(); final View view = (View) this.getClientProperty("html"); //NOI18N if (view != null) { final HTMLDocument doc = (HTMLDocument) view.getDocument(); final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); while (it.isValid()) { final SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes(); final String link = (String) s.getAttribute(HTML.Attribute.HREF); if (link != null) { this.linkCache.add(new HtmlLinkAddress(link, it.getStartOffset(), it.getEndOffset())); } it.next(); } } }
Example 2
Source File: JHtmlLabel.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
private void cacheLinkElements() { this.linkCache = new ArrayList<HtmlLinkAddress>(); final View view = (View) this.getClientProperty("html"); if (view != null) { final HTMLDocument doc = (HTMLDocument) view.getDocument(); final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); while (it.isValid()) { final SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes(); final String link = (String) s.getAttribute(HTML.Attribute.HREF); if (link != null) { this.linkCache.add(new HtmlLinkAddress(link, it.getStartOffset(), it.getEndOffset())); } it.next(); } } }
Example 3
Source File: JHtmlLabel.java From netbeans-mmd-plugin with Apache License 2.0 | 6 votes |
private void cacheLinkElements() { this.linkCache = new ArrayList<HtmlLinkAddress>(); final View view = (View) this.getClientProperty("html"); if (view != null) { final HTMLDocument doc = (HTMLDocument) view.getDocument(); final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); while (it.isValid()) { final SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes(); final String link = (String) s.getAttribute(HTML.Attribute.HREF); if (link != null) { this.linkCache.add(new HtmlLinkAddress(link, it.getStartOffset(), it.getEndOffset())); } it.next(); } } }
Example 4
Source File: AbstractDetailsPanel.java From ghidra with Apache License 2.0 | 5 votes |
/** * Adds text to a string buffer as an html-formatted string, adding formatting information * as specified. * @param buffer the string buffer to add to * @param string the string to add * @param attributes the formatting instructions */ protected void insertHTMLString(StringBuilder buffer, String string, SimpleAttributeSet attributes) { if (string == null) { return; } buffer.append("<FONT COLOR=\""); Color foregroundColor = (Color) attributes.getAttribute(StyleConstants.Foreground); buffer.append(HTMLUtilities.toHexString(foregroundColor)); buffer.append("\" FACE=\""); buffer.append(attributes.getAttribute(StyleConstants.FontFamily).toString()); buffer.append("\">"); Boolean isBold = (Boolean) attributes.getAttribute(StyleConstants.Bold); isBold = (isBold == null) ? Boolean.FALSE : isBold; String text = HTMLUtilities.escapeHTML(string); if (isBold) { text = HTMLUtilities.bold(text); } buffer.append(text); buffer.append("</FONT>"); }
Example 5
Source File: ReporterResultTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void hyperlinkUpdate(final HyperlinkEvent e) { if (!HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { return; } BugTrackingAccessor accessor = Lookup.getDefault().lookup(BugTrackingAccessor.class); if (accessor != null){ AttributeSet ats = e.getSourceElement().getAttributes(); Object attribute = ats.getAttribute(HTML.getTag("a")); if (attribute instanceof SimpleAttributeSet) { SimpleAttributeSet attributeSet = (SimpleAttributeSet) attribute; Object bugId = attributeSet.getAttribute(HTML.getAttributeKey("id")); if (bugId != null){ try{ Integer.parseInt(bugId.toString()); LOG.log(Level.FINE, "Open issue {0}", bugId); accessor.openIssue(bugId.toString()); return; }catch(NumberFormatException nfe){ LOG.log(Level.INFO, "Invalid id attribute", nfe); } } } } else { LOG.log(Level.INFO, "Bugzilla Accessor not found"); } RP.post(new Runnable(){ @Override public void run() { HtmlBrowser.URLDisplayer.getDefault().showURL(e.getURL()); } }); }
Example 6
Source File: DocumentParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 7
Source File: DocumentParser.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 8
Source File: ExtendedStyledDocument.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
/** * Stores the given {@link String} line for the next batch update. If the number of elements * awaiting batch update are >= maxRows, will discard the oldest element. Call * {@link #executeBatch(int)} or {@link #executeBatchAppend()} to execute the batch update. * <p> * <strong>Attention:</strong> Every {@link String} is considered as one line so a line * separator will be added into the document after it. * </p> * <p> * This method is thread safe. * </p> * * @param str * the {@link String} to add to the document. * @param a * the style formatting settings */ public void appendLineForBatch(String str, SimpleAttributeSet a) { if (str == null || str.isEmpty()) { throw new IllegalArgumentException("str must not be null or empty!"); } if (!str.endsWith(System.lineSeparator())) { str += System.lineSeparator(); } char[] txt = str.toCharArray(); a = a != null ? (SimpleAttributeSet) a.copyAttributes() : new SimpleAttributeSet(); // set font family if not set if (a.getAttribute(StyleConstants.FontFamily) == null) { StyleConstants.setFontFamily(a, DEFAULT_FONT_FAMILY); } synchronized (LOCK) { // make sure batch size does not exceed maxRows *3 (*3 because we add the str and 2 line // separator tags) if (maxRows > 0) { while (listToInsert.size() >= maxRows * 3) { // remove element itself and both line separator elements) // we start at the beginning because we discard oldest first listToInsert.removeFirst(); listToInsert.removeFirst(); listToInsert.removeFirst(); lineLength.removeFirst(); } } // close previous paragraph tag, start new one, add text // yes the order is correct; no you cannot change to start/text/end // if you do, linebreaks get messed up listToInsert.add(new ElementSpec(new SimpleAttributeSet(), ElementSpec.EndTagType)); listToInsert.add(new ElementSpec(new SimpleAttributeSet(), ElementSpec.StartTagType)); listToInsert.add(new ElementSpec(a, ElementSpec.ContentType, txt, 0, txt.length)); // store length of each row we add lineLength.add(txt.length); } }
Example 9
Source File: DocumentParser.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 10
Source File: DocumentParser.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 11
Source File: DocumentParser.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 12
Source File: DocumentParser.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 13
Source File: DocumentParser.java From Java8CN with Apache License 2.0 | 4 votes |
/** * 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(); } } }
Example 14
Source File: DocumentParser.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 15
Source File: DocumentParser.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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(); } } }
Example 16
Source File: DocumentParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 17
Source File: DocumentParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 18
Source File: DocumentParser.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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(); } } }
Example 19
Source File: DocumentParser.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }
Example 20
Source File: DocumentParser.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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(); } } }