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 2003/08/08 10:19:58 UTC

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

edith       2003/08/08 01:19:58

  Modified:    src/java/org/apache/lenya/cms/publication SiteTreeNode.java
                        SiteTreeNodeImpl.java
  Log:
  accpet method for the visitable sitetreenode (Visitor pattern)
  
  Revision  Changes    Path
  1.7       +21 -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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SiteTreeNode.java	25 Jul 2003 16:43:45 -0000	1.6
  +++ SiteTreeNode.java	8 Aug 2003 08:19:58 -0000	1.7
  @@ -137,6 +137,24 @@
   	 */
       boolean hasLink();
   
  +	/**
  +	 * Get the sitetreenodes, which are children of this node
  +	 * @return the children.
  +	 */
   	SiteTreeNode[] getChildren();
   	
  +	/**
  +	 * Call the visit method of the visitor, that mean
  +	 * the operation that shall be perfoemed on this node
  +	 * (Visitor pattern)
  +	 * @param visitor The visitor.
  +	 */
  +	void accept (SiteTreeNodeVisitor visitor);
  +	
  +	/**
  +	 * Traverse the node ant its children and call the
  +	 * accept method.
  +	 * @param visitor The visitor.
  +	 */
  +	void acceptSubtree (SiteTreeNodeVisitor visitor);
   }
  
  
  
  1.12      +31 -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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SiteTreeNodeImpl.java	25 Jul 2003 16:43:45 -0000	1.11
  +++ SiteTreeNodeImpl.java	8 Aug 2003 08:19:58 -0000	1.12
  @@ -325,6 +325,10 @@
               return false;
           }
       }
  +	/**
  +	 * (non-Javadoc)
  +	 * @see org.apache.lenya.cms.publication.SiteTreeNode#getChildren()
  +	 */
   	public SiteTreeNode[] getChildren() {
   		List childElements = new ArrayList();
           
  @@ -338,5 +342,29 @@
   
   		return (SiteTreeNode[]) childElements.toArray(new SiteTreeNode[childElements.size()]);
   	}
  +
  +	/**
  +	 * (non-Javadoc)
  +	 * @see org.apache.lenya.cms.publication.SiteTreeNode#accept(org.apache.lenya.cms.publication.SiteTreeNodeVisitor)
  +	 */
  +	public void accept (SiteTreeNodeVisitor visitor) {
  +		visitor.visitSiteTreeNode(this);
  +	}
   	
  +	/**
  +	 * (non-Javadoc)
  +	 * @see org.apache.lenya.cms.publication.SiteTreeNode#acceptSubtree(org.apache.lenya.cms.publication.SiteTreeNodeVisitor)
  +	 */
  +	public void acceptSubtree (SiteTreeNodeVisitor visitor) {
  +		this.accept(visitor);
  +        SiteTreeNode[] children = this.getChildren();
  +		if (children == null) {
  +			log.info("The node " + this.getId() + " has no children");
  +			return;
  +		} else {
  +			for (int i=0; i<children.length; i++) {
  +				children[i].acceptSubtree(visitor);
  +			}	
  +		}
  +	}
   }
  
  
  

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