コード例 #1
0
ファイル: Element.java プロジェクト: asiachrispy/achris
 /**
  * Get this element's child data nodes. The list is unmodifiable but the data nodes may be
  * manipulated.
  *
  * <p>This is effectively a filter on {@link #childNodes()} to get Data nodes.
  *
  * @return child data nodes. If this element has no data nodes, returns an empty list.
  * @see #data()
  */
 public List<DataNode> dataNodes() {
   List<DataNode> dataNodes = new ArrayList<DataNode>();
   for (Node node : childNodes) {
     if (node instanceof DataNode) dataNodes.add((DataNode) node);
   }
   return Collections.unmodifiableList(dataNodes);
 }
コード例 #2
0
ファイル: Element.java プロジェクト: asiachrispy/achris
 /**
  * Get this element's child text nodes. The list is unmodifiable but the text nodes may be
  * manipulated.
  *
  * <p>This is effectively a filter on {@link #childNodes()} to get Text nodes.
  *
  * @return child text nodes. If this element has no text nodes, returns an empty list.
  *     <p>For example, with the input HTML: {@code <p>One <span>Two</span> Three <br> Four</p>}
  *     with the {@code p} element selected:
  *     <ul>
  *       <li>{@code p.text()} = {@code "One Two Three Four"}
  *       <li>{@code p.ownText()} = {@code "One Three Four"}
  *       <li>{@code p.children()} = {@code Elements[<span>, <br>]}
  *       <li>{@code p.childNodes()} = {@code List<Node>["One ", <span>, " Three ", <br>, " Four"]}
  *       <li>{@code p.textNodes()} = {@code List<TextNode>["One ", " Three ", " Four"]}
  *     </ul>
  */
 public List<TextNode> textNodes() {
   List<TextNode> textNodes = new ArrayList<TextNode>();
   for (Node node : childNodes) {
     if (node instanceof TextNode) textNodes.add((TextNode) node);
   }
   return Collections.unmodifiableList(textNodes);
 }