Package org.thymeleaf.dom

Examples of org.thymeleaf.dom.Node


    List<Node> children = parent.getChildren();

    // Insert a whitespace gap between elements if available
    if (!children.isEmpty()) {
      Node whitespace = children.get(Math.min(insertionpoint, children.size() - 1));
      if (whitespace instanceof Text) {
        parent.insertChild(insertionpoint, whitespace.cloneNode(null, false));
        parent.insertChild(insertionpoint + 1, child);
        return;
      }
    }
    parent.insertChild(insertionpoint, child);
View Full Code Here


    try {
      NestableNode parent = element.getParent();
      parent.removeChild(element);
      ((AbstractGeneralTemplateWriter) templateWriter).writeNode(arguments, writer, parent);

      Node content = new Macro(writer.toString());
      CacheManager.INSTANCE.put(arguments, cacheName, Collections.singletonList(content));
    } catch (IOException e) {
      throw new TemplateOutputException("Error during creation of output", e);
    }
    return ProcessorResult.OK;
View Full Code Here

        sb.append(buildContentMap(arguments)).append(";\n  ");
        sb.append(getUncacheableDataFunction(arguments, element)).append(";\n");
        sb.append("</SCRIPT>");
               
        // Add contentNode to the document
        Node contentNode = new Macro(sb.toString());
        element.clearChildren();
        element.getParent().insertAfter(element, contentNode);
        element.getParent().removeChild(element);

        // Return OK
View Full Code Here

            }
           
            sb.append("</script>");
           
            // Add contentNode to the document
            Node contentNode = new Macro(sb.toString());
            element.clearChildren();
            element.getParent().insertAfter(element, contentNode);
            element.getParent().removeChild(element);
        } else {
            Log.warn("No trackers were found, not outputting Google Analytics script. Set the googleAnalytics.webPropertyId"
View Full Code Here

     * @return The next sibling element or {@code null}.
     */
    public static final Element getNextSiblingElement(Node node) {
     
      List<Node> siblings = node.getParent().getChildren();
      Node n = null;
     
      int index = siblings.indexOf(node) + 1;
      if(index>0 && index<siblings.size()) {
        n = siblings.get(index);
        while(!(n instanceof Element) && ++index < siblings.size()) {
View Full Code Here

     * @return The previous sibling element or {@code null}.
     */
    public static final Element getPreviousSiblingElement(Node node) {
     
      List<Node> siblings = node.getParent().getChildren();
      Node n = null;
     
      int index = siblings.indexOf(node) - 1;

      if(index>=0) {
        n = siblings.get(index);
View Full Code Here

     
      if(node instanceof Document) {
        doc = (Document) node;
      } else {
       
        Node parent = node;
        while(parent.hasParent()) {
          parent = parent.getParent();
         
          if(parent instanceof Document) {
            doc = (Document)parent;
            break;
          }
View Full Code Here

    int offset=0;
    int elementCount=0;

   
    while(elementCount<maxElementCount && startIndex+offset >=0 && startIndex+offset < children.size()) {
      Node child = children.get(startIndex+offset);
      offset+=step;
      if(child instanceof Element) {
        elementCount++;
      }
     
View Full Code Here

  }
 
  private int indexOf(List<Node> children, Element target) {
    int i;
    for(i=0; i<children.size(); i++) {
      Node node = children.get(i);
      if(node.equals(target)) {
        break;
      }
    }
   
    if(i>=children.size()) {
View Full Code Here

     *
     * @see <a href="http://www.w3.org/TR/css3-selectors/#adjacent-sibling-combinators">Adjacent sibling combinator</a>
     */
    private void addAdjacentSiblingElements() {
        for (Node node : nodes) {
            Node n = DOMHelper.getNextSiblingElement(node);
            if (n != null) {
                String tag = selector.getTagName();
                if (tagEquals(tag, DOMHelper.getNodeName(n)) || tag.equals(Selector.UNIVERSAL_TAG)) {
                    result.add(n);
                }
View Full Code Here

TOP

Related Classes of org.thymeleaf.dom.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.