Package org.jsoup.nodes

Examples of org.jsoup.nodes.Node


    if (annotation != null)
      add(annotation);
   
    // handle no annotations being found
    if (previousEnd == 0){
      Node dataNode;
      if (parent.tagName().equals(titleTag) || parent.tagName().equals(textareaTag))
          dataNode = TextNode.createFromEncoded(text, baseUri);
        else // data not encoded but raw (for " in script)
          dataNode = new DataNode(text, baseUri);
        lines(dataNode, text);
View Full Code Here


  private boolean stackHasValidParent(Tag childTag) {
    if (stack.size() == 1 && childTag.equals(htmlTag))
      return true; // root is valid for html node

    for (int i = stack.size() - 1; i >= 0; i--) {
      Node n = stack.get(i);
      if (n instanceof Element)
        return true;
    }
    return false;
  }
View Full Code Here

    return false;
  }

  private Element popStackToSuitableContainer(Tag tag) {
    while (!stack.isEmpty() && !(stack.getLast() instanceof XmlDeclaration)) {
      Node lastNode = stack.getLast();
      if (lastNode instanceof Element) {
        Element last = (Element) lastNode;
        if (canContain(last.tag(), tag))
          return last;
        else
View Full Code Here

    // first check to see if stack contains this tag; if so pop to there, otherwise ignore
    int counter = 0;
    Element elToClose = null;
    for (int i = stack.size() - 1; i > 0; i--) {
      counter++;
      Node n = stack.get(i);
      if (n instanceof Element) {
        Element el = (Element) n;
        Tag elTag = el.tag();
        if (elTag.equals(bodyTag) || elTag.equals(headTag) || elTag.equals(htmlTag)) { // once in body, don't close past body
          break;
View Full Code Here

    return elToClose;
  }


  private <N extends Node> void add(N n) {
    Node last = null;

    if (stack.size() == 0) {
      if (n instanceof XmlDeclaration) {
        // only add the first/outermost doctype
        stack.add(n);
View Full Code Here

  }     

  public List<Node> findSiblings(Node node) {
      Validate.notNull(node);
   
      Node parent = node.parent();
      if (null == parent) return null;

      return parent.childNodes();              
  }
View Full Code Here

                text = helper.getMessage(key, paramMap);
            } catch (InvalidMessageException e) {
                logger.warn("failed to get the message. key=" + key, e);
                text = '!' + key + '!';
            }
            Node node;
            if (text.startsWith(ExtNodeConstants.MSG_NODE_ATTRVALUE_TEXT_PREFIX)) {
                node = ElementUtil.text(text.substring(ExtNodeConstants.MSG_NODE_ATTRVALUE_TEXT_PREFIX.length()));
            } else if (text.startsWith(ExtNodeConstants.MSG_NODE_ATTRVALUE_HTML_PREFIX)) {
                node = ElementUtil.parseAsSingle(text.substring(ExtNodeConstants.MSG_NODE_ATTRVALUE_HTML_PREFIX.length()));
            } else {
View Full Code Here

                text = helper.getMessage(key, paramMap);
            } catch (InvalidMessageException e) {
                logger.warn("failed to get the message. key=" + key, e);
                text = '!' + key + '!';
            }
            Node node;
            if (text.startsWith(ExtNodeConstants.MSG_NODE_ATTRVALUE_TEXT_PREFIX)) {
                node = ElementUtil.text(text.substring(ExtNodeConstants.MSG_NODE_ATTRVALUE_TEXT_PREFIX.length()));
            } else if (text.startsWith(ExtNodeConstants.MSG_NODE_ATTRVALUE_HTML_PREFIX)) {
                node = ElementUtil.parseAsSingle(text.substring(ExtNodeConstants.MSG_NODE_ATTRVALUE_HTML_PREFIX.length()));
            } else {
View Full Code Here

                text = helper.getMessage(key, paramMap);
            } catch (InvalidMessageException e) {
                logger.warn("failed to get the message. key=" + key, e);
                text = '!' + key + '!';
            }
            Node node;
            if (text.startsWith(ExtNodeConstants.MSG_NODE_ATTRVALUE_TEXT_PREFIX)) {
                node = ElementUtil.text(text.substring(ExtNodeConstants.MSG_NODE_ATTRVALUE_TEXT_PREFIX.length()));
            } else if (text.startsWith(ExtNodeConstants.MSG_NODE_ATTRVALUE_HTML_PREFIX)) {
                node = ElementUtil.parseAsSingle(text.substring(ExtNodeConstants.MSG_NODE_ATTRVALUE_HTML_PREFIX.length()));
            } else {
View Full Code Here

    /**
     * Start a depth-first traverse of the root and all of its descendants.
     * @param root the root node point to traverse.
     */
    public void traverse(Node root) {
        Node node = root;
        int depth = 0;
       
        while (node != null) {
            visitor.head(node, depth);
            if (node.childNodeSize() > 0) {
                node = node.childNode(0);
                depth++;
            } else {
                while (node.nextSibling() == null && depth > 0) {
                    visitor.tail(node, depth);
                    node = node.parent();
                    depth--;
                }
                visitor.tail(node, depth);
                if (node == root)
                    break;
                node = node.nextSibling();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jsoup.nodes.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.