org.jdom2.Element.getContent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.jdom2.Element.getContent()方法的一些代码示例,展示了Element.getContent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getContent()方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:getContent

Element.getContent介绍

[英]This returns the full content of the element as a List which may contain objects of type Text, Element, Comment, ProcessingInstruction, CDATA, and EntityRef. The List returned is "live" in document order and modifications to it affect the element's actual contents. Whitespace content is returned in its entirety.

Sequential traversal through the List is best done with an Iterator since the underlying implement of List.size() may require walking the entire list.
[中]这将以列表的形式返回元素的完整内容,其中可能包含类型为TextElementCommentProcessingInstructionCDATAEntityRef的对象。返回的列表在文档顺序上是“活动”的,对它的修改会影响元素的实际内容。空白内容全部返回。
通过列表的顺序遍历最好使用迭代器完成,因为列表的底层实现是这样的。size()可能需要遍历整个列表。

代码示例

代码示例来源:origin: org.jdom/jdom

@Override
public List<Content> cloneContent() {
  final int size = getContentSize();
  final List<Content> list = new ArrayList<Content>(size);
  for (int i = 0; i < size; i++) {
    final Content child = getContent(i);
    list.add(child.clone());
  }
  return list;
}

代码示例来源:origin: org.jdom/jdom

/**
   * Returns the content of a JDOM Element detached from it.
   *
   * @param  elt   the element to get the content from.
   *
   * @return a (possibly empty) list of JDOM nodes, detached from
   *         their parent.
   */
  private List<Content> getDetachedContent(Element elt) {
    List<Content> content = elt.getContent();
    List<Content> nodes   = new ArrayList<Content>(content.size());
    while (content.size() != 0)
    {
      Content o = content.remove(0);
      nodes.add(o);
    }
    return (nodes);
  }
}

代码示例来源:origin: org.jdom/jdom

private final void recurseElementText(Element element, StringBuilder sb) {
  for (Iterator<?> it = element.getContent().iterator(); it.hasNext(); ) {
    Content c = (Content)it.next();
    if (c instanceof Element) {
      recurseElementText((Element)c, sb);
    } else if (c instanceof Text) {
      sb.append(((Text)c).getText());
    }
  }
}

代码示例来源:origin: org.jdom/jdom

descending = ((Element)ret).getContent().iterator();
if (ssize >= stack.length) {
  stack = ArrayCopy.copyOf(stack, ssize + 16);

代码示例来源:origin: org.jdom/jdom

/**
 * Returns the XPath 1.0 string value of this element, which is the
 * complete, ordered content of all text node descendants of this element
 * (i&#46;e&#46; the text that's left after all references are resolved
 * and all other markup is stripped out.)
 *
 * @return a concatentation of all text node descendants
 */
@Override
public String getValue() {
  final StringBuilder buffer = new StringBuilder();
  for (Content child : getContent()) {
    if (child instanceof Element || child instanceof Text) {
      buffer.append(child.getValue());
    }
  }
  return buffer.toString();
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will handle printing out an <code>{@link
 * Element}</code>'s content only, not including its tag, and attributes.
 * This can be useful for printing the content of an element that contains
 * HTML, like "&lt;description&gt;JDOM is
 * &lt;b&gt;fun&gt;!&lt;/description&gt;".
 * 
 * @param element
 *        <code>Element</code> to output.
 * @param out
 *        <code>Writer</code> to use.
 * @throws IOException
 *         - if there's any problem writing.
 * @throws NullPointerException
 *         if the specified content is null.
 */
public final void outputElementContent(Element element, Writer out)
    throws IOException {
  myProcessor.process(out, myFormat, element.getContent());
  out.flush();
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will handle printing out an <code>{@link
 * Element}</code>'s content only, not including its tag, and attributes.
 * This can be useful for printing the content of an element that contains
 * HTML, like "&lt;description&gt;JDOM is
 * &lt;b&gt;fun&gt;!&lt;/description&gt;".
 * 
 * @param element
 *        <code>Element</code> to output.
 * @param out
 *        <code>XMLStreamWriter</code> to use.
 * @throws XMLStreamException
 *         - if there's any problem writing.
 * @throws NullPointerException
 *         if the specified content is null.
 */
public final void outputElementContent(Element element, XMLStreamWriter out)
    throws XMLStreamException {
  myProcessor.process(out, myFormat, element.getContent());
  out.flush();
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will handle printing out an <code>{@link
 * Element}</code>'s content only, not including its tag, and attributes.
 * This can be useful for printing the content of an element that contains
 * HTML, like "&lt;description&gt;JDOM is
 * &lt;b&gt;fun&gt;!&lt;/description&gt;".
 * 
 * @param element
 *        <code>Element</code> to output.
 * @param out
 *        <code>XMLEventConsumer</code> to use.
 * @throws XMLStreamException
 *         - if there's any problem writing.
 * @throws NullPointerException
 *         if the specified content is null.
 */
public final void outputElementContent(Element element, XMLEventConsumer out)
    throws XMLStreamException {
  myProcessor.process(out, myFormat, myEventFactory, element.getContent());
  //out.flush();
}

代码示例来源:origin: org.jdom/jdom

final FilterList<E> list = (FilterList<E>)getContent(filter);
list.sort(comparator);

代码示例来源:origin: org.jdom/jdom

pnt.getContent(Filters.text()); // CDATA
return getPositionPath(content, sibs, "text()", buffer);
  pnt.getContent(Filters.comment());
return getPositionPath(content, sibs, "comment()", buffer);
  pnt.getContent(Filters.processinginstruction());
return getPositionPath(content, sibs,
    "processing-instruction()", buffer);
    .singletonList(nsa) : pnt.getContent();
return getPositionPath(content, sibs, "node()", buffer);

代码示例来源:origin: org.jdom/jdom

final List<Content> content = element.getContent();

代码示例来源:origin: org.jdom/jdom

try {
  final List<Content> content = element.getContent();

代码示例来源:origin: org.jdom/jdom

element.getQualifiedName(), atts);
final List<Content> content = element.getContent();

代码示例来源:origin: rometools/rome

private Element getFirstContent(final Element element, final String name) {
  final List<Element> filterList = element.getContent(new ContentFilter(name));
  Element firstContent = null;
  if (filterList != null && !filterList.isEmpty()) {
    firstContent = filterList.get(0);
  }
  return firstContent;
}

代码示例来源:origin: org.jdom/jdom

final List<Content> content = element.getContent();

代码示例来源:origin: rometools/rome

protected String getXmlInnerText(final Element e) {
    final StringBuffer sb = new StringBuffer();
    final XMLOutputter xo = new XMLOutputter();
    final List<Content> children = e.getContent();
    sb.append(xo.outputString(children));

    return sb.toString();
  }
}

代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-rss

protected String getXmlInnerText(Element e) {
    StringBuffer sb = new StringBuffer();
    XMLOutputter xo = new XMLOutputter();
    List children = e.getContent();
    sb.append(xo.outputString(children));
    
    return sb.toString();
  }
}

代码示例来源:origin: rometools/rome

protected String getXmlInnerText(final Element e) {
    final StringBuffer sb = new StringBuffer();
    final XMLOutputter xo = new XMLOutputter();
    final List<Content> children = e.getContent();
    sb.append(xo.outputString(children));
    return sb.toString();
  }
}

代码示例来源:origin: org.jdom/jdom

final List<Content> content = element.getContent();

代码示例来源:origin: rometools/rome

private void parseUpdates(final Element historyChild, final History history, final Locale locale) {
  final List<Element> updatedChildren = historyChild.getContent(new ContentFilter(Update.NAME));
  for (final Element updateChild : updatedChildren) {
    final Update update = new Update();
    update.setBy(parseStringAttribute(updateChild, Update.BY_ATTRIBUTE));
    update.setWhen(parseDateAttribute(updateChild, Update.WHEN_ATTRIBUTE, locale));
    history.addUpdate(update);
  }
}

相关文章

微信公众号

最新文章

更多