javax.swing.text.SimpleAttributeSet#getAttribute ( )源码实例Demo

下面列出了javax.swing.text.SimpleAttributeSet#getAttribute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans-mmd-plugin   文件: JHtmlLabel.java
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();
    }
  }
}
 
源代码2 项目: netbeans-mmd-plugin   文件: JHtmlLabel.java
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();
    }
  }
}
 
源代码3 项目: netbeans-mmd-plugin   文件: JHtmlLabel.java
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();
    }
  }
}
 
源代码4 项目: ghidra   文件: AbstractDetailsPanel.java
/**
 * 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>");
}
 
源代码5 项目: netbeans   文件: ReporterResultTopComponent.java
@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());
        }

    });
}
 
源代码6 项目: jdk8u-jdk   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码7 项目: dragonwell8_jdk   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码8 项目: TencentKona-8   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码9 项目: JDKSourceCode1.8   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码10 项目: openjdk-jdk8u   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码12 项目: Bytecoder   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码13 项目: openjdk-jdk9   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码14 项目: Java8CN   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码15 项目: hottub   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码16 项目: openjdk-8-source   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码17 项目: openjdk-8   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码18 项目: jdk8u_jdk   文件: DocumentParser.java
/**
 * 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();
        }
    }
}
 
源代码19 项目: rapidminer-studio   文件: ExtendedStyledDocument.java
/**
 * 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);
	}
}
 
源代码20 项目: jdk8u-dev-jdk   文件: DocumentParser.java
/**
 * 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();
        }
    }
}