Package org.jsoup.nodes

Examples of org.jsoup.nodes.Node


    public static final class IsEmpty extends Evaluator {
    @Override
    public boolean matches(Element root, Element element) {
          List<Node> family = element.childNodes();
          for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
          return true;
    }
View Full Code Here


      SimpleLogger.debug("Book is an exception - not creating index link (no stichwort.htm*)");
      return;
    }
    Element indexLink = findFirstElement(Selector.TOC_HEADING_2).clone();
    String fileExtension = ".htm";
    Node ankerNode = null;
    for (Node node : indexLink.childNodes()) {
      if (node.hasAttr("href")) {
        ankerNode = node.clone();
        if (ankerNode.attr("href").contains(".html"))
          fileExtension = ".html";
        break;
      }
    }
    if (ankerNode == null)
      throw new RuntimeException(
        "Cannot create index link because no cloneable TOC node has been found (should never happen)"
      );
    ankerNode.attr("href", "stichwort" + fileExtension);
    ((Element) ankerNode).text("Index");
    bodyTag.appendChild(ankerNode);
  }
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.parentNode();
                    depth--;
                }
                visitor.tail(node, depth);
                if (node == root)
                    break;
                node = node.nextSibling();
            }
        }
    }
View Full Code Here

    public static final class IsEmpty extends Evaluator {
    @Override
    public boolean matches(Element root, Element element) {
          List<Node> family = element.childNodes();
          for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
          return true;
    }
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

            Map<String, Object> paramMap = getMessageParams(attributes, helper, key, externalizeParamKeys);
            String text;
            text = helper.getMessageWithDefault(key, defaultMsg, paramMap);

            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

            Map<String, Object> paramMap = getMessageParams(attributes, helper, key, externalizeParamKeys);
            String text;
            text = helper.getMessageWithDefault(key, defaultMsg, paramMap);

            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

        Comment comment = new Comment(commentToken.getData(), baseUri);
        insertNode(comment);
    }

    void insert(Token.Character characterToken) {
        Node node;
        // characters in script and style go in as datanodes, not text nodes
        if (StringUtil.in(currentElement().tagName(), "script", "style"))
            node = new DataNode(characterToken.getData(), baseUri);
        else
            node = new TextNode(characterToken.getData(), baseUri);
View Full Code Here

   */
  public String getWholeText(Element cell) {
      String text = null;
      List<Node> childNodes = cell.childNodes();
      if (childNodes.size() > 0) {
          Node childNode = childNodes.get(0);
          if (childNode instanceof TextNode) {
              text = ((TextNode)childNode).getWholeText();
          }
      }
      if (text == null) {
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.