db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r830154 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/compile/
Date Tue, 27 Oct 2009 12:42:07 GMT
Author: kahatlen
Date: Tue Oct 27 12:42:04 2009
New Revision: 830154

URL: http://svn.apache.org/viewvc?rev=830154&view=rev
Log:
DERBY-4421: Allow visitors to process the nodes bottom-up

Added the method visitChildrenFirst() to the Visitor interface to
allow the visitor to specify whether they should walk the tree
top-down or bottom-up. Implemented the method in all existing visitors
and made it return false to preserve the current behaviour with
top-down walking.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTableNumbersVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CollectNodesVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLStatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReferencedTablesVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RemapCRsVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceWindowFuncCallsWithCRVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/Visitor.java Tue Oct 27 12:42:04 2009
@@ -65,6 +65,19 @@
 		throws StandardException;
 
 	/**
+	 * Method that is called to see if {@code visit()} should be called on
+	 * the children of {@code node} before it is called on {@code node} itself.
+	 * If this method always returns {@code true}, the visitor will walk the
+	 * tree bottom-up. If it always returns {@code false}, the tree is visited
+	 * top-down.
+	 *
+	 * @param node the top node of a sub-tree about to be visited
+	 * @return {@code true} if {@code node}'s children should be visited
+	 * before {@code node}, {@code false} otherwise
+	 */
+	boolean visitChildrenFirst(Visitable node);
+
+	/**
 	 * Method that is called to see
 	 * if query tree traversal should be
 	 * stopped before visiting all nodes.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTableNumbersVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTableNumbersVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTableNumbersVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTableNumbersVisitor.java Tue Oct 27 12:42:04 2009
@@ -223,4 +223,12 @@
 		return false;
 	}
 
+	/**
+	 * @see org.apache.derby.iapi.sql.compile.Visitor#visitChildrenFirst
+	 */
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 }	

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java Tue Oct 27 12:42:04 2009
@@ -375,22 +375,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable		returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (leftOperand != null && !v.stopTraversal())
 		{
@@ -401,8 +395,6 @@
 		{
 			rightOperandList = (ValueNodeList)rightOperandList.accept(v);
 		}
-			
-		return returnNode;
 	}
         
         /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java Tue Oct 27 12:42:04 2009
@@ -853,22 +853,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (leftOperand != null && !v.stopTraversal())
 		{
@@ -879,8 +873,6 @@
 		{
 			rightOperand = (ValueNode)rightOperand.accept(v);
 		}
-		
-		return returnNode;
 	}
 
         /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CallStatementNode.java Tue Oct 27 12:42:04 2009
@@ -239,29 +239,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (!v.stopTraversal())
 		{
 			methodCall = (JavaToSQLValueNode) methodCall.accept(v);
 		}
-
-		return returnNode;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Tue Oct 27 12:42:04 2009
@@ -975,29 +975,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (castOperand != null && !v.stopTraversal())
 		{
 			castOperand = (ValueNode)castOperand.accept(v);
 		}
-
-		return returnNode;
 	}
 
 	/** This method gets called by the parser to indiciate that this CAST node 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java Tue Oct 27 12:42:04 2009
@@ -379,23 +379,25 @@
 		}
 		return true;
 	}
-	public Visitable accept(Visitor v) throws StandardException 
+
+	/**
+	 * Accept the visitor for all visitable children of this node.
+	 *
+	 * @param v the visitor
+	 * @throws StandardException on error in the visitor
+	 */
+	void acceptChildren(Visitor v) throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-		
-		if (v.skipChildren(this) || v.stopTraversal())
-		{
-			return returnNode;
-		}
-		
+		super.acceptChildren(v);
+
 		int size = argumentsList.size();
 		for (int index = 0; index < size; index++)
 		{
 			argumentsList.setElementAt(
 					(QueryTreeNode)(argumentsList.elementAt(index)).accept(v), index);
 		}
-		return returnNode;
 	}
+
 	/**
 	 * Preprocess an expression tree.  We do a number of transformations
 	 * here (including subqueries, IN lists, LIKE and BETWEEN) plus

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CollectNodesVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CollectNodesVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CollectNodesVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CollectNodesVisitor.java Tue Oct 27 12:42:04 2009
@@ -69,6 +69,11 @@
 		this.skipOverClass = skipOverClass;
 	}
 
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 	public boolean stopTraversal()
 	{
 		return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java Tue Oct 27 12:42:04 2009
@@ -718,22 +718,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (testCondition != null && !v.stopTraversal())
 		{
@@ -744,8 +738,6 @@
 		{
 			thenElseList = (ValueNodeList)thenElseList.accept(v);
 		}
-		
-		return returnNode;
 	}
         
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java Tue Oct 27 12:42:04 2009
@@ -391,34 +391,21 @@
 
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
-
-		if (!v.stopTraversal())
-		{
-			super.accept(v);
-		}
+		super.acceptChildren(v);
 
 		if (queryExpression != null && !v.stopTraversal())
 		{
 			queryExpression = (ResultSetNode)queryExpression.accept(v);
 		}
-
-		return returnNode;
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLStatementNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLStatementNode.java Tue Oct 27 12:42:04 2009
@@ -484,27 +484,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
+		super.acceptChildren(v);
 
 		if (resultSet != null && !v.stopTraversal())
 		{
 			resultSet = (ResultSetNode)resultSet.accept(v);
 		}
-
-		return this;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Tue Oct 27 12:42:04 2009
@@ -4587,26 +4587,17 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 	
 		throws StandardException
 	{
-
-	        Visitable returnNode = super.accept(v);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
-
-
+		super.acceptChildren(v);
 
 		if (nonStoreRestrictionList != null && !v.stopTraversal()) {
 			nonStoreRestrictionList.accept(v);
@@ -4623,8 +4614,6 @@
 		if (requalificationRestrictionList != null && !v.stopTraversal()) {
 			requalificationRestrictionList.accept(v);
 		}
-		
-		return returnNode;
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java Tue Oct 27 12:42:04 2009
@@ -1602,27 +1602,6 @@
 		isTransparent = true;
 	}
 
-	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
-	 * 
-	 * @param v the visitor
-	 *
-	 * @exception StandardException on error
-	 */
-	public Visitable accept(Visitor v) 
-		throws StandardException
-	{
-		int size = size();
-		for (int index = 0; index < size; index++)
-		{
-			FromTable fromTable = (FromTable) elementAt(index);
-			setElementAt((QueryTreeNode) fromTable.accept(v), index);
-		}
-
-		return this;
-	}
-
 
 	/**
 	 * Set windows field to the supplied value.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java Tue Oct 27 12:42:04 2009
@@ -1431,29 +1431,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (!v.stopTraversal())
 		{
 			methodCall = (MethodCallNode) methodCall.accept(v);
 		}
-
-		return returnNode;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByColumn.java Tue Oct 27 12:42:04 2009
@@ -140,26 +140,19 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.
+	 * Accept the visitor for all visitable children of this node.
 	 *
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v)
+	void acceptChildren(Visitor v)
 		throws StandardException {
 
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this)) {
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (columnExpression != null) {
 			columnExpression = (ValueNode)columnExpression.accept(v);
 		}
-
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasCorrelatedCRsVisitor.java Tue Oct 27 12:42:04 2009
@@ -106,6 +106,11 @@
 		return false;
 	}
 
+	public boolean visitChildrenFirst(Visitable v)
+	{
+		return false;
+	}
+
 	////////////////////////////////////////////////
 	//
 	// CLASS INTERFACE

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java Tue Oct 27 12:42:04 2009
@@ -111,6 +111,14 @@
 				skipOverClass.isInstance(node);
 	}
 
+	/**
+	 * Visit parent before children.
+	 */
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 	////////////////////////////////////////////////
 	//
 	// CLASS INTERFACE

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java Tue Oct 27 12:42:04 2009
@@ -131,6 +131,11 @@
 		return false;
 	}
 
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 	/**
 	 * Stop traversal if we found the target node
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashTableNode.java Tue Oct 27 12:42:04 2009
@@ -409,22 +409,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (searchPredicateList != null && !v.stopTraversal())
 		{
@@ -435,7 +429,5 @@
 		{
 			joinPredicateList = (PredicateList)joinPredicateList.accept(v);
 		}
-
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java Tue Oct 27 12:42:04 2009
@@ -412,29 +412,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (source != null && !v.stopTraversal())
 		{
 			source = (FromBaseTable)source.accept(v);
 		}
-
-		return returnNode;
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaToSQLValueNode.java Tue Oct 27 12:42:04 2009
@@ -338,29 +338,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (javaNode != null && !v.stopTraversal())
 		{
 			javaNode = (JavaValueNode)javaNode.accept(v);
 		}
-		
-		return returnNode;
 	}
         
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java Tue Oct 27 12:42:04 2009
@@ -1932,22 +1932,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (resultColumns != null && !v.stopTraversal())
 		{
@@ -1963,8 +1957,6 @@
 		{
 			usingClause = (ResultColumnList)usingClause.accept(v);
 		}
-
-		return returnNode;
 	}
 
 	// This method returns the table references in Join node, and this may be

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java Tue Oct 27 12:42:04 2009
@@ -1239,22 +1239,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable		returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		for (int parm = 0; 
 			!v.stopTraversal() && parm < methodParms.length; 
@@ -1265,7 +1259,5 @@
 				methodParms[parm] = (JavaValueNode)methodParms[parm].accept(v);
 			}
 		}
-
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java Tue Oct 27 12:42:04 2009
@@ -466,28 +466,20 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (receiver != null && !v.stopTraversal())
 		{
 			receiver = (JavaValueNode)receiver.accept(v);
 		}
-
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java Tue Oct 27 12:42:04 2009
@@ -501,28 +501,21 @@
 
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.
+	 * Accept the visitor for all visitable children of this node.
 	 *
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v)
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (expression != null && !v.stopTraversal())
 		{
 			expression = (ValueNode)expression.accept(v);
 		}
-		return returnNode;
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java Tue Oct 27 12:42:04 2009
@@ -810,29 +810,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (andNode != null && !v.stopTraversal())
 		{
 			andNode = (AndNode)andNode.accept(v);
 		}
-
-		return returnNode;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java Tue Oct 27 12:42:04 2009
@@ -1812,22 +1812,16 @@
 
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (restriction != null && !v.stopTraversal())
 		{
@@ -1838,8 +1832,6 @@
 		{
 			restrictionList = (PredicateList)restrictionList.accept(v);
 		}
-
-		return returnNode;
 	}
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Tue Oct 27 12:42:04 2009
@@ -688,17 +688,45 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept a visitor, and call {@code v.visit()} on child nodes as
+	 * necessary. Sub-classes should not override this method, but instead
+	 * override the {@link #acceptChildren(Visitor)} method.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	public final Visitable accept(Visitor v)
 		throws StandardException
 	{
-		return v.visit(this);
+		final boolean childrenFirst = v.visitChildrenFirst(this);
+		final boolean skipChildren = v.skipChildren(this);
+
+		if (childrenFirst && !skipChildren && !v.stopTraversal()) {
+			acceptChildren(v);
+		}
+
+		final Visitable ret = v.stopTraversal() ? this : v.visit(this);
+
+		if (!childrenFirst && !skipChildren && !v.stopTraversal()) {
+			acceptChildren(v);
+		}
+
+		return ret;
+	}
+
+	/**
+	 * Accept a visitor on all child nodes. All sub-classes that add fields
+	 * that should be visited, should override this method and call
+	 * {@code accept(v)} on all visitable fields, as well as
+	 * {@code super.acceptChildren(v)} to make sure all visitable fields
+	 * defined by the super-class are accepted too.
+	 *
+	 * @param v the visitor
+	 * @throws StandardException on errors raised by the visitor
+	 */
+	void acceptChildren(Visitor v) throws StandardException {
+		// no children
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java Tue Oct 27 12:42:04 2009
@@ -124,29 +124,21 @@
 
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable		returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
 			setElementAt((QueryTreeNode)((QueryTreeNode) elementAt(index)).accept(v), index);
 		}
-		
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReferencedTablesVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReferencedTablesVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReferencedTablesVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReferencedTablesVisitor.java Tue Oct 27 12:42:04 2009
@@ -91,6 +91,11 @@
 			    node instanceof ResultSetNode);
 	}
 
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 	public boolean stopTraversal()
 	{
 		return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RemapCRsVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RemapCRsVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RemapCRsVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RemapCRsVisitor.java Tue Oct 27 12:42:04 2009
@@ -93,6 +93,11 @@
 		return (node instanceof SubqueryNode);
 	}
 
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 	public boolean stopTraversal()
 	{
 		return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java Tue Oct 27 12:42:04 2009
@@ -116,6 +116,11 @@
 				skipOverClass.isInstance(node);
 	}
 	
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
 	public boolean stopTraversal()
 	{
 		return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceWindowFuncCallsWithCRVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceWindowFuncCallsWithCRVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceWindowFuncCallsWithCRVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceWindowFuncCallsWithCRVisitor.java Tue Oct 27 12:42:04 2009
@@ -97,6 +97,16 @@
 	/**
 	 * Vistor override.
 	 * @return false
+	 * @see Visitor#visitChildrenFirst
+	 */
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
+
+	/**
+	 * Vistor override.
+	 * @return false
 	 * @see Visitor#skipChildren
 	 */
 	public boolean stopTraversal()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Tue Oct 27 12:42:04 2009
@@ -1534,28 +1534,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 	
 		if (expression != null && !v.stopTraversal())
 		{
 			setExpression( (ValueNode)expression.accept(v) );
 		}
-		return returnNode;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Tue Oct 27 12:42:04 2009
@@ -1601,28 +1601,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (resultColumns != null && !v.stopTraversal())
 		{
 			resultColumns = (ResultColumnList)resultColumns.accept(v);
 		}
-		return returnNode;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java Tue Oct 27 12:42:04 2009
@@ -496,28 +496,20 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (value != null && !v.stopTraversal())
 		{
 			value = (ValueNode)value.accept(v);
 		}
-
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Tue Oct 27 12:42:04 2009
@@ -2344,27 +2344,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v)
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
-
-		if (!v.stopTraversal())
-		{
-			super.accept(v);
-		}
+		super.acceptChildren(v);
 
 		if (fromList != null && !v.stopTraversal())
 		{
@@ -2384,8 +2373,6 @@
 		if (havingClause != null && !v.stopTraversal()) {
 			havingClause = (ValueNode)havingClause.accept(v);
 		}
-		
-		return returnNode;
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java Tue Oct 27 12:42:04 2009
@@ -609,28 +609,20 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (childResult != null && !v.stopTraversal())
 		{
 			childResult = (ResultSetNode)childResult.accept(v);
 		}
-
-		return returnNode;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Tue Oct 27 12:42:04 2009
@@ -2194,29 +2194,23 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v)
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
+		super.acceptChildren(v);
 
 		/* shortcut if we've already done it
 		 */
 		if ((v instanceof HasCorrelatedCRsVisitor) && doneCorrelationCheck) 
 		{
 			((HasCorrelatedCRsVisitor) v).setHasCorrelatedCRs(foundCorrelation);
-			return returnNode;
-		}
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
+			return;
 		}
 
 		if (resultSet != null && !v.stopTraversal())
@@ -2228,7 +2222,6 @@
 		{
 			leftOperand = (ValueNode)leftOperand.accept(v);
 		}
-		return returnNode;
 	}
 
 	private boolean isIN()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java Tue Oct 27 12:42:04 2009
@@ -80,4 +80,9 @@
 				false:
 				skipOverClass.isInstance(node);
 	}
+
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java Tue Oct 27 12:42:04 2009
@@ -946,22 +946,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		if (v.skipChildren(this))
-		{
-			return v.visit(this);
-		}
-
-		Visitable returnNode = super.accept(v);
+		super.acceptChildren(v);
 
 		if (leftResultSet != null && !v.stopTraversal())
 		{
@@ -971,7 +965,6 @@
 		{
 			rightResultSet = (ResultSetNode)rightResultSet.accept(v);
 		}
-		return returnNode;
 	}
 
 	/** 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java Tue Oct 27 12:42:04 2009
@@ -464,22 +464,16 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-	
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (receiver != null && !v.stopTraversal())
 		{
@@ -495,8 +489,6 @@
 		{
 			rightOperand = (ValueNode)rightOperand.accept(v);
 		}
-		
-		return returnNode;
 	}
 	/**
 	 * Bind trim expression. 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java Tue Oct 27 12:42:04 2009
@@ -743,29 +743,21 @@
 	}
 
 	/**
-	 * Accept a visitor, and call v.visit()
-	 * on child nodes as necessary.  
+	 * Accept the visitor for all visitable children of this node.
 	 * 
 	 * @param v the visitor
 	 *
 	 * @exception StandardException on error
 	 */
-	public Visitable accept(Visitor v) 
+	void acceptChildren(Visitor v)
 		throws StandardException
 	{
-		Visitable returnNode = v.visit(this);
-
-		if (v.skipChildren(this))
-		{
-			return returnNode;
-		}
+		super.acceptChildren(v);
 
 		if (operand != null && !v.stopTraversal())
 		{
 			operand = (ValueNode)operand.accept(v);
 		}
-
-		return returnNode;
 	}
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java Tue Oct 27 12:42:04 2009
@@ -204,4 +204,9 @@
     {
         return false;
     } // end of skipChildren
+
+    public boolean visitChildrenFirst(Visitable node)
+    {
+        return false;
+    }
 } // end of class VTIDeferModPolicy

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java?rev=830154&r1=830153&r2=830154&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VerifyAggregateExpressionsVisitor.java Tue Oct 27 12:42:04 2009
@@ -145,4 +145,9 @@
 	{
 		return false;
 	}
+
+	public boolean visitChildrenFirst(Visitable node)
+	{
+		return false;
+	}
 }	



Mime
View raw message