You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ed...@apache.org on 2004/01/21 17:18:24 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/publication SiteTreeNodeImpl.java SiteTreeNode.java

edith       2004/01/21 08:18:24

  Modified:    src/java/org/apache/lenya/cms/publication
                        SiteTreeNodeImpl.java SiteTreeNode.java
  Log:
  acceptReserveSubtree method for the visitor pattern
  
  Revision  Changes    Path
  1.23      +33 -3     cocoon-lenya/src/java/org/apache/lenya/cms/publication/SiteTreeNodeImpl.java
  
  Index: SiteTreeNodeImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/SiteTreeNodeImpl.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SiteTreeNodeImpl.java	7 Jan 2004 13:22:42 -0000	1.22
  +++ SiteTreeNodeImpl.java	21 Jan 2004 16:18:24 -0000	1.23
  @@ -399,6 +399,36 @@
       }
   
       /**
  +     * (non-Javadoc)
  +     * @see org.apache.lenya.cms.publication.SiteTreeNode#acceptSubtree(org.apache.lenya.cms.publication.SiteTreeNodeVisitor)
  +     */
  +    public void acceptReverseSubtree(SiteTreeNodeVisitor visitor) throws DocumentException {
  +      List orderedNodes = this.postOrder();
  +      for (int i = 0; i < orderedNodes.size(); i++) {
  +          SiteTreeNode node = (SiteTreeNode)orderedNodes.get(i);
  +          node.accept(visitor);  
  +      }
  +    }
  +
  +    /**
  +     *  (non-Javadoc)
  +	 * @see org.apache.lenya.cms.publication.SiteTreeNode#postOrder()
  +	 */
  +	public List postOrder(){
  +        List list = new ArrayList();
  +        SiteTreeNode[] children = this.getChildren();
  +        if (children == null) {
  +            log.info("The node " + this.getId() + " has no children");
  +        } else {
  +            for (int i = 0; i < children.length; i++) {
  +                List orderedChildren = children[i].postOrder();
  +                list.addAll(orderedChildren);
  +            }
  +        }
  +        list.add(this);   
  +		return list;
  +    }
  +    /**
        * @see org.apache.lenya.cms.publication.SiteTreeNode#setLabel(org.apache.lenya.cms.publication.Label)
        */
       public void setLabel(Label label) {
  
  
  
  1.16      +20 -3     cocoon-lenya/src/java/org/apache/lenya/cms/publication/SiteTreeNode.java
  
  Index: SiteTreeNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/publication/SiteTreeNode.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SiteTreeNode.java	23 Sep 2003 13:46:02 -0000	1.15
  +++ SiteTreeNode.java	21 Jan 2004 16:18:24 -0000	1.16
  @@ -55,6 +55,8 @@
   */
   package org.apache.lenya.cms.publication;
   
  +import java.util.List;
  +
   /**
    * This interface is a wrapper around the more general w3c.Node which
    * hides some details which are irrelevant for site tree nodes. It basically
  @@ -206,10 +208,25 @@
       void acceptSubtree(SiteTreeNodeVisitor visitor) throws DocumentException;
   
       /**
  +     * Traverse in a reverse way the node ant its children and call the
  +     * accept method.
  +     * @param visitor The visitor.
  +     * 
  +     * @throws DocumentException if an error occurs
  +	 */
  +	void acceptReverseSubtree(SiteTreeNodeVisitor visitor) throws DocumentException; 
  +    /**
        * Sets a label of an this node. If the label does not exist, it is added.
        * Otherwise, the existing label is replaced.
        * 
        * @param label the label to add
        */
       void setLabel(Label label);
  +
  +	/**
  +     * Give a list of the children and this node in a post order way
  +	 * @return The list
  +	 */
  +	List postOrder();
  +    
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org