You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2013/06/28 06:32:09 UTC

svn commit: r1497644 [2/4] - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/loader/ iapi/sql/compile/ impl/sql/compile/

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java Fri Jun 28 04:32:08 2013
@@ -137,7 +137,7 @@ public final class InListOperatorNode ex
                 new BinaryRelationalOperatorNode(
 						C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
 						leftOperand, 
-						(ValueNode) rightOperandList.elementAt(0),
+                        rightOperandList.elementAt(0),
                         false,
 						getContextManager());
 			/* Set type info for the operator node */
@@ -257,9 +257,8 @@ public final class InListOperatorNode ex
 				rightOperandList.sortInAscendingOrder(judgeODV);
 				isOrdered = true;
 
-				ValueNode minValue = (ValueNode)rightOperandList.elementAt(0);
-				ValueNode maxValue =
-					(ValueNode)rightOperandList.elementAt(
+                ValueNode minValue = rightOperandList.elementAt(0);
+                ValueNode maxValue = rightOperandList.elementAt(
 						rightOperandList.size() - 1);
 
 				/* Handle the degenerate case where the min and the max
@@ -305,7 +304,7 @@ public final class InListOperatorNode ex
 			 * the list.  This is arbitrary and should not matter in the
 			 * big picture.
 			 */
-			ValueNode srcVal = (ValueNode) rightOperandList.elementAt(0);
+            ValueNode srcVal = rightOperandList.elementAt(0);
             ParameterNode pNode = new ParameterNode(
                     0,
 					null, // default value
@@ -373,9 +372,8 @@ public final class InListOperatorNode ex
             // Iterate through the entire list of values to find out
             // what the dominant type is.
             ClassFactory cf = getClassFactory();
-            int sz = rightOperandList.size();
-            for (int i = 0; i < sz; i++) {
-                ValueNode vn = (ValueNode) rightOperandList.elementAt(i);
+
+            for (ValueNode vn : rightOperandList) {
                 targetType = targetType.getDominantType(
                         vn.getTypeServices(), cf);
             }
@@ -439,7 +437,7 @@ public final class InListOperatorNode ex
         leftBCO = new BinaryRelationalOperatorNode(
 						C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
 						leftClone,
-                        (ValueNode)rightOperandList.elementAt(0),
+                        rightOperandList.elementAt(0),
                         false,
 						getContextManager());
 		/* Set type info for the operator node */
@@ -455,7 +453,7 @@ public final class InListOperatorNode ex
             rightBCO = new BinaryRelationalOperatorNode(
 							C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE,
 							leftClone,
-							(ValueNode) rightOperandList.elementAt(elemsDone),
+                            rightOperandList.elementAt(elemsDone),
                             false,
 							getContextManager());
 			/* Set type info for the operator node */
@@ -484,12 +482,11 @@ public final class InListOperatorNode ex
     boolean selfReference(ColumnReference cr)
 		throws StandardException
 	{
-		int size = rightOperandList.size();
-		for (int i = 0; i < size; i++)
+        for (ValueNode vn : rightOperandList)
 		{
-			ValueNode vn = (ValueNode) rightOperandList.elementAt(i);
-			if (vn.getTablesReferenced().get(cr.getTableNumber()))
+            if (vn.getTablesReferenced().get(cr.getTableNumber())) {
 				return true;
+            }
 		}
 		return false;
 	}
@@ -642,7 +639,7 @@ public final class InListOperatorNode ex
 			}
 
 			setArrayMethod.getField(arrayField); // first arg
-			((ValueNode) rightOperandList.elementAt(index)).generateExpression(acb, setArrayMethod);
+            rightOperandList.elementAt(index).generateExpression(acb, setArrayMethod);
 			setArrayMethod.upCast(ClassName.DataValueDescriptor); // second arg
 			setArrayMethod.setArrayElement(index);
 		}
@@ -716,7 +713,7 @@ public final class InListOperatorNode ex
 							  ((i == 0) ? 4 : 3);
 			for (int j = 0; j < numVals; j++)
 			{
-				ValueNode vn = (ValueNode) rightOperandList.elementAt(currentOpnd++);
+                ValueNode vn = rightOperandList.elementAt(currentOpnd++);
 				vn.generateExpression(acb, mb);
 				mb.upCast(ClassName.DataValueDescriptor);
 			}

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -401,7 +401,8 @@ class IndexToBaseRowNode extends FromTab
 
 		for (int index = 0; index < rclSize; index++)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
+            ResultColumn rc = resultColumns.elementAt(index);
+
 			if (indexReferencedCols != null && rc.getExpression() instanceof VirtualColumnNode)
 			{
 				// Column is coming from index

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java Fri Jun 28 04:32:08 2013
@@ -47,7 +47,6 @@ import org.apache.derby.iapi.sql.execute
 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
 import org.apache.derby.iapi.store.access.TransactionController;
 import org.apache.derby.iapi.types.RowLocation;
-import org.apache.derby.iapi.util.ReuseFactory;
 import org.apache.derby.iapi.util.StringUtil;
 import org.apache.derby.impl.sql.execute.FKInfo;
 import org.apache.derby.vti.DeferModification;
@@ -76,8 +75,8 @@ import org.apache.derby.vti.DeferModific
  */
 public final class InsertNode extends DMLModStatementNode
 {
-	public		ResultColumnList	targetColumnList;
-            boolean             deferred;
+    private     ResultColumnList    targetColumnList;
+    private     boolean             deferred;
 	public		ValueNode			checkConstraints;
 	public		Properties			targetProperties;
 	public		FKInfo				fkInfo;
@@ -145,7 +144,7 @@ public final class InsertNode extends DM
 	 *
 	 * @return	This object as a String
 	 */
-
+    @Override
 	public String toString()
 	{
 		if (SanityManager.DEBUG)
@@ -166,6 +165,7 @@ public final class InsertNode extends DM
 		}
 	}
 
+    @Override
     String statementToString()
 	{
 		return "INSERT";
@@ -177,7 +177,7 @@ public final class InsertNode extends DM
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
+    @Override
     void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
@@ -228,7 +228,7 @@ public final class InsertNode extends DM
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
 	public void bindStatement() throws StandardException
 	{
 		// We just need select privilege on the expressions
@@ -397,8 +397,7 @@ public final class InsertNode extends DM
 			int targetSize = targetColumnList.size();
 			for (int index = 0; index < targetSize; index++)
 			{
-				int position =
-					((ResultColumn) (targetColumnList.elementAt(index))).
+                int position = targetColumnList.elementAt(index).
 												columnDescriptor.getPosition();
 
 				if (index != position-1)
@@ -602,6 +601,7 @@ public final class InsertNode extends DM
 		return resultSet;
 	}
 
+    @Override
 	int getPrivType()
 	{
 		return Authorizer.INSERT_PRIV;
@@ -614,6 +614,7 @@ public final class InsertNode extends DM
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	public boolean referencesSessionSchema()
 		throws StandardException
 	{
@@ -715,6 +716,7 @@ public final class InsertNode extends DM
 	 *
 	 * @exception StandardException		Thrown on failure
 	 */
+    @Override
     public ConstantAction makeConstantAction() throws StandardException
 	{
 
@@ -817,7 +819,7 @@ public final class InsertNode extends DM
      * down to the source result set, before calling super.optimizeStatement.
      * </p>
 	 */
-
+    @Override
 	public void optimizeStatement() throws StandardException
 	{
 		// Push the order by list down to the ResultSet
@@ -883,6 +885,7 @@ public final class InsertNode extends DM
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     void generate(ActivationClassBuilder acb, MethodBuilder mb)
 							throws StandardException
 	{
@@ -964,6 +967,7 @@ public final class InsertNode extends DM
 	 *
 	 * @return the type of statement
 	 */
+    @Override
 	protected final int getStatementType()
 	{
 		return StatementType.INSERT;
@@ -976,7 +980,7 @@ public final class InsertNode extends DM
 	 *
 	 * @return the type of statement
 	 */
-	static final int getStatementType(Properties targetProperties)
+    static int getStatementType(Properties targetProperties)
 	{
 		int retval = StatementType.INSERT;
 
@@ -1032,6 +1036,7 @@ public final class InsertNode extends DM
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -209,18 +209,15 @@ class JoinNode extends TableOperatorNode
 		 * implement full outer join.
 		 */
 		// Walk joinPredicates backwards due to possible deletes
-		for (int index = joinPredicates.size() - 1; index >= 0; index --)
+        for (int i = joinPredicates.size() - 1; i >= 0; i --)
 		{
-			JBitSet	  curBitSet;
-			Predicate predicate;
+            Predicate p = joinPredicates.elementAt(i);
 
-			predicate = (Predicate) joinPredicates.elementAt(index);
-			if (! predicate.getPushable())
+            if (joinPredicates.elementAt(i).getPushable())
 			{
-				continue;
-			}
-			joinPredicates.removeElementAt(index);
-			getRightPredicateList().addElement(predicate);
+                joinPredicates.removeElementAt(i);
+                getRightPredicateList().addElement(p);
+            }
 		}
 
 		rightResultSet = optimizeSource(
@@ -607,10 +604,8 @@ class JoinNode extends TableOperatorNode
 		 */
 		if (resultColumns != null)
 		{
-			int rclSize = resultColumns.size();
-			for (int index = 0; index < rclSize; index++)
+            for (ResultColumn rc : resultColumns)
 			{
-				ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
 				VirtualColumnNode vcn = (VirtualColumnNode) rc.getExpression();
 				if (resultColumn == vcn.getSourceColumn())
 				{
@@ -852,15 +847,13 @@ class JoinNode extends TableOperatorNode
 			 * We need to bind the CRs a side at a time to ensure that
 			 * we don't find an bogus ambiguous column reference. (Bug 377)
 			 */
-           joinClause = new BooleanConstantNode(true, cm);
+            joinClause = new BooleanConstantNode(true, cm);
 
-			int usingSize = usingClause.size();
-			for (int index = 0; index < usingSize; index++)
+            for (ResultColumn rc : usingClause)
 			{
 				BinaryComparisonOperatorNode equalsNode;
 				ColumnReference leftCR;
 				ColumnReference rightCR;
-				ResultColumn	rc = (ResultColumn) usingClause.elementAt(index);
 
 				/* Create and bind the left CR */
 				fromListParam.insertElementAt(leftResultSet, 0);
@@ -983,8 +976,7 @@ class JoinNode extends TableOperatorNode
     private static List<String> extractColumnNames(ResultColumnList rcl) {
         ArrayList<String> names = new ArrayList<String>();
 
-        for (int i = 0; i < rcl.size(); i++) {
-            ResultColumn rc = (ResultColumn) rcl.elementAt(i);
+        for (ResultColumn rc : rcl) {
             names.add(rc.getName());
         }
 
@@ -1221,16 +1213,14 @@ class JoinNode extends TableOperatorNode
 		// Walk outerPredicateList backwards due to possible deletes
 		for (int index = outerPredicateList.size() - 1; index >= 0; index --)
 		{
-			JBitSet	  curBitSet;
-			Predicate predicate;
+            Predicate predicate = outerPredicateList.elementAt(index);
 
-			predicate = (Predicate) outerPredicateList.elementAt(index);
 			if (! predicate.getPushable())
 			{
 				continue;
 			}
 
-			curBitSet = predicate.getReferencedSet();
+            JBitSet curBitSet = predicate.getReferencedSet();
 			
 			/* Do we have a match? */
 			if (leftReferencedTableMap.contains(curBitSet))
@@ -1278,16 +1268,14 @@ class JoinNode extends TableOperatorNode
 		// Walk outerPredicateList backwards due to possible deletes
 		for (int index = outerPredicateList.size() - 1; index >= 0; index --)
 		{
-			JBitSet	  curBitSet;
-			Predicate predicate;
+            Predicate predicate = outerPredicateList.elementAt(index);
 
-			predicate = (Predicate) outerPredicateList.elementAt(index);
-			if (! predicate.getPushable())
+            if (! predicate.getPushable())
 			{
 				continue;
 			}
 
-			curBitSet = predicate.getReferencedSet();
+            JBitSet curBitSet = predicate.getReferencedSet();
 			
 			/* Do we have a match? */
 			if (rightReferencedTableMap.contains(curBitSet))
@@ -1335,16 +1323,14 @@ class JoinNode extends TableOperatorNode
 		// Walk outerPredicateList backwards due to possible deletes
 		for (int index = outerPredicateList.size() - 1; index >= 0; index --)
 		{
-			JBitSet	  curBitSet;
-			Predicate predicate;
+            Predicate predicate = outerPredicateList.elementAt(index);
 
-			predicate = (Predicate) outerPredicateList.elementAt(index);
 			if (! predicate.getPushable())
 			{
 				continue;
 			}
 
-			curBitSet = predicate.getReferencedSet();
+            JBitSet curBitSet = predicate.getReferencedSet();
 			
 			/* Do we have a match? */
 			JBitSet innerBitSet = (JBitSet) rightReferencedTableMap.clone();

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -169,11 +169,12 @@ abstract class MethodCallNode extends Ja
 	  *
 	  *	@return	the Classes of our parameters
 	  */
-	public	Class[]	getMethodParameterClasses() 
+    public  Class<?>[]  getMethodParameterClasses()
 	{ 
 		ClassInspector ci = getClassFactory().getClassInspector();
 
-		Class[]	parmTypeClasses = new Class[methodParms.length];
+        Class<?>[]  parmTypeClasses = new Class<?>[methodParms.length];
+
 		for (int i = 0; i < methodParms.length; i++)
 		{
 			String className = methodParameterTypes[i];
@@ -911,7 +912,7 @@ abstract class MethodCallNode extends Ja
             {
                 // allow subtypes of ResultSet too
                 try {
-                    Class actualType = classInspector.getClass( typeName );
+                    Class<?> actualType = classInspector.getClass( typeName );
 
                     foundCorrectType = ResultSet.class.isAssignableFrom( actualType );
                 }
@@ -1229,6 +1230,7 @@ abstract class MethodCallNode extends Ja
 		return isParam;
 	}
 
+    @SuppressWarnings("fallthrough")
 	static  String	getObjectTypeName( JSQLType jsqlType, TypeCompilerFactory tcf )
 		throws StandardException
 	{

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -373,7 +373,7 @@ class NonStaticMethodCallNode extends Me
 		** Refer to the field holding the receiver, if there is any.
 		*/
 
-		Class declaringClass = method.getDeclaringClass();
+        Class<?> declaringClass = method.getDeclaringClass();
 		
 		/*
 		** If it's an interface, generate an interface method call, if it's a static,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java Fri Jun 28 04:32:08 2013
@@ -604,10 +604,11 @@ class NormalizeResultSetNode extends Sin
         
 		if (targetResultColumnList != null) {
 		    int size = Math.min(targetRCL.size(), resultColumns.size());
-		    for (int index = 0; index < size; index++) {
-			ResultColumn sourceRC = (ResultColumn) resultColumns.elementAt(index);
-			ResultColumn resultColumn = (ResultColumn) targetRCL.elementAt(index);
-			sourceRC.setType(resultColumn.getTypeServices());
+
+            for (int index = 0; index < size; index++) {
+                ResultColumn sourceRC = resultColumns.elementAt(index);
+                ResultColumn resultColumn = targetRCL.elementAt(index);
+                sourceRC.setType(resultColumn.getTypeServices());
 		    }
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java Fri Jun 28 04:32:08 2013
@@ -48,7 +48,7 @@ import org.apache.derby.iapi.util.JBitSe
  * and the last column in the list is the least significant.
  *
  */
-class OrderByList extends OrderedColumnList
+class OrderByList extends OrderedColumnList<OrderByColumn>
 						implements RequiredRowOrdering {
 
 	private boolean allAscending = true;
@@ -77,7 +77,7 @@ class OrderByList extends OrderedColumnL
      * @param cm The context manager
     */
    OrderByList(ResultSetNode rs, ContextManager cm) {
-       super(cm);
+       super(OrderByColumn.class, cm);
        setNodeType(C_NodeTypes.ORDER_BY_LIST);
        this.isTableValueCtorOrdering =
                 (rs instanceof UnionNode &&
@@ -114,9 +114,11 @@ class OrderByList extends OrderedColumnL
 		@param position	The column to get from the list
 	 */
     OrderByColumn getOrderByColumn(int position) {
-		if (SanityManager.DEBUG)
-		SanityManager.ASSERT(position >=0 && position < size());
-		return (OrderByColumn) elementAt(position);
+        if (SanityManager.DEBUG) {
+            SanityManager.ASSERT(position >=0 && position < size());
+        }
+
+        return elementAt(position);
 	}
 
 	/**
@@ -132,17 +134,14 @@ class OrderByList extends OrderedColumnL
 		/* Remember the target for use in optimization */
 		resultToSort = target;
 
-		int size = size();
-
 		/* Only 1012 columns allowed in ORDER BY clause */
-		if (size > Limits.DB2_MAX_ELEMENTS_IN_ORDER_BY)
+        if (size() > Limits.DB2_MAX_ELEMENTS_IN_ORDER_BY)
 		{
 			throw StandardException.newException(SQLState.LANG_TOO_MANY_ELEMENTS);
 		}
 
-		for (int index = 0; index < size; index++)
+        for (OrderByColumn obc : this)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(index);
 			obc.bindOrderByColumn(target, this);
 
 			/*
@@ -174,9 +173,8 @@ class OrderByList extends OrderedColumnL
 	 */
 	void closeGap(int gap)
 	{
-		for (int index = 0; index < size(); index++)
+        for (OrderByColumn obc : this)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(index);
 			obc.collapseAddedColumnGap(gap);
 		}
 	}
@@ -194,10 +192,8 @@ class OrderByList extends OrderedColumnL
 		/* Remember the target for use in optimization */
 		resultToSort = target;
 
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (OrderByColumn obc : this)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(index);
 			obc.pullUpOrderByColumn(target);
 		}
 
@@ -229,8 +225,8 @@ class OrderByList extends OrderedColumnL
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			if (((OrderByColumn) elementAt(index)).getResultColumn() !=
-				(ResultColumn) sourceRCL.elementAt(index))
+            if (elementAt(index).getResultColumn() !=
+                sourceRCL.elementAt(index))
 			{
 				return false;
 			}
@@ -246,10 +242,8 @@ class OrderByList extends OrderedColumnL
 	 */
 	void resetToSourceRCs()
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (OrderByColumn obc : this)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(index);
 			obc.resetToSourceRC();
 		}
 	}
@@ -268,10 +262,8 @@ class OrderByList extends OrderedColumnL
         ResultColumnList newRCL = new ResultColumnList(getContextManager());
 
 		/* The new RCL starts with the ordering columns */
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (OrderByColumn obc : this)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(index);
 			newRCL.addElement(obc.getResultColumn());
 			resultColumns.removeElement(obc.getResultColumn());
 		}
@@ -296,9 +288,7 @@ class OrderByList extends OrderedColumnL
 			 loc >= 0;
 			 loc--)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(loc);
-
-			if (obc.constantColumn(whereClause))
+            if (elementAt(loc).constantColumn(whereClause))
 			{
 				removeElementAt(loc);
 			}
@@ -316,12 +306,12 @@ class OrderByList extends OrderedColumnL
 		/* Walk the list backwards so we can remove elements safely */
 		for (int loc = size() - 1; loc > 0; loc--)
 		{
-			OrderByColumn obc = (OrderByColumn) elementAt(loc);
+            OrderByColumn obc = elementAt(loc);
 			int           colPosition = obc.getColumnPosition();
 
 			for (int inner = 0; inner < loc; inner++)
 			{
-				OrderByColumn prev_obc = (OrderByColumn) elementAt(inner);
+                OrderByColumn prev_obc = elementAt(inner);
 				if (colPosition == prev_obc.getColumnPosition())
 				{
 					removeElementAt(loc);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumnList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumnList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumnList.java Fri Jun 28 04:32:08 2013
@@ -30,10 +30,12 @@ import org.apache.derby.impl.sql.execute
  * List of OrderedColumns
  *
  */
-public abstract class OrderedColumnList extends QueryTreeNodeVector
+public abstract class OrderedColumnList<E extends OrderedColumn>
+    extends QueryTreeNodeVector<E>
 {
-    public OrderedColumnList(ContextManager cm) {
-        super(cm);
+    public OrderedColumnList(Class<E> eltClass,
+            ContextManager cm) {
+        super(eltClass, cm);
     }
 
 	/**
@@ -61,7 +63,7 @@ public abstract class OrderedColumnList 
 
 		for (int i = 0; i < numCols; i++)
 		{
-			OrderedColumn oc = (OrderedColumn) elementAt(i);
+            OrderedColumn oc = elementAt(i);
 
 			// order by (lang) positions are 1-based,
 			// order items (store) are 0-based.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java Fri Jun 28 04:32:08 2013
@@ -55,7 +55,7 @@ import org.apache.derby.iapi.util.JBitSe
  *
  */
 
-class PredicateList extends QueryTreeNodeVector
+class PredicateList extends QueryTreeNodeVector<Predicate>
                     implements OptimizablePredicateList
 {
 	private int	numberOfStartPredicates;
@@ -64,7 +64,7 @@ class PredicateList extends QueryTreeNod
 
     PredicateList(ContextManager cm)
 	{
-        super(cm);
+        super(Predicate.class, cm);
         setNodeType(C_NodeTypes.PREDICATE_LIST);
 	}
 
@@ -88,7 +88,7 @@ class PredicateList extends QueryTreeNod
 	 */
 	public final void removeOptPredicate(int predCtr) throws StandardException
 	{
-		Predicate predicate = (Predicate) remove(predCtr);
+        Predicate predicate = removeElementAt(predCtr);
 
         if (predicate.isStartKey())
             numberOfStartPredicates--;
@@ -170,10 +170,8 @@ class PredicateList extends QueryTreeNod
 		** in the index to an expression that does not contain a reference
 		** to the table in question.  Let's look for that.
 		*/
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate pred : this)
 		{
-			Predicate	pred = (Predicate) elementAt(index);
 			RelationalOperator relop = pred.getRelop();
 
 			/* InListOperatorNodes, while not relational operators, may still
@@ -293,13 +291,12 @@ class PredicateList extends QueryTreeNod
 	/** @see OptimizablePredicateList#markAllPredicatesQualifiers */
 	public void markAllPredicatesQualifiers()
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			((Predicate) elementAt(index)).markQualifier();
+            p.markQualifier();
 		}
 
-		numberOfQualifiers = size;
+        numberOfQualifiers = size();
 	}
 
 	/**
@@ -318,7 +315,7 @@ class PredicateList extends QueryTreeNod
 		{
 			AndNode			andNode;
 			Predicate		predicate;
-			predicate = (Predicate) elementAt(index);
+            predicate = elementAt(index);
 			//We are not looking at constant comparison predicate.
 			if (predicate.getReferencedMap().hasSingleBitSet())
 			{
@@ -351,14 +348,9 @@ class PredicateList extends QueryTreeNod
 													  boolean isNullOkay)
 							throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate predicate : this)
 		{
-			AndNode			andNode;
-			Predicate		predicate;
-			predicate = (Predicate) elementAt(index);
-
-            andNode = predicate.getAndNode();
+            AndNode andNode = predicate.getAndNode();
 
 			// skip non-equality predicates
 			ValueNode opNode = andNode.getLeftOperand();
@@ -383,13 +375,8 @@ class PredicateList extends QueryTreeNod
 										  int columnNumber)
 					throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate predicate : this)
 		{
-			AndNode			andNode;
-			Predicate		predicate;
-			predicate = (Predicate) elementAt(index);
-
 			// This method is used by HashJoinStrategy to determine if
 			// there are any equality predicates that can be used to
 			// perform a hash join (see the findHashKeyColumns()
@@ -404,7 +391,7 @@ class PredicateList extends QueryTreeNod
 				continue;
 			}
 
-            andNode = predicate.getAndNode();
+            AndNode andNode = predicate.getAndNode();
 
 			ValueNode opNode = andNode.getLeftOperand();
 
@@ -451,10 +438,8 @@ class PredicateList extends QueryTreeNod
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			Predicate		predicate = (Predicate) elementAt(index);
-			AndNode			andNode;
-
-            andNode = predicate.getAndNode();
+            Predicate predicate = elementAt(index);
+            AndNode andNode = predicate.getAndNode();
 
 			// skip non-equality predicates
 			ValueNode opNode = andNode.getLeftOperand();
@@ -490,24 +475,19 @@ class PredicateList extends QueryTreeNod
 										boolean coveringIndexScan)
 						throws StandardException
 	{
-		boolean[]	deletes;
 		int[]		baseColumnPositions;
 		boolean[]	isAscending;
 		int			size = size();
 		Predicate[]	usefulPredicates = new Predicate[size];
 		int			usefulCount = 0;
-		Predicate	predicate;
-
 
 		/*
 		** Clear all the scan flags for this predicate list, so that the
 		** flags that get set are only for the given conglomerate.
 		*/
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			predicate = (Predicate) elementAt(index);
-
-			predicate.clearScanFlags();
+            p.clearScanFlags();
 		}
 
 		/*
@@ -541,7 +521,7 @@ class PredicateList extends QueryTreeNod
 
 			for (int index = 0; index < size; index++)
 			{
-				Predicate	pred = (Predicate) elementAt(index);
+                Predicate pred = elementAt(index);
 
 				/*
 				** Skip over it if it's not a relational operator (this includes
@@ -647,9 +627,8 @@ class PredicateList extends QueryTreeNod
 		** Create an array of useful predicates.  Also, count how many
 		** useful predicates there are.
 		*/
-		for (int index = 0; index < size; index++)
+        for (Predicate pred : this)
 		{
-			Predicate pred = (Predicate) elementAt(index);
 			ColumnReference indexCol = null;
 			int			indexPosition;
 			RelationalOperator relop = pred.getRelop();
@@ -1037,7 +1016,7 @@ class PredicateList extends QueryTreeNod
 		 */
 		for (int index = size() - 1; index >= 0; index--)
 		{
-			Predicate	pred = (Predicate) elementAt(index);
+            Predicate pred = elementAt(index);
 
 			// Transfer each non-qualifier
 			if (!pred.isRelationalOpPredicate() ||
@@ -1062,11 +1041,9 @@ class PredicateList extends QueryTreeNod
     void categorize()
 		throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			((Predicate) elementAt(index)).categorize();
+            p.categorize();
 		}
 	}
 
@@ -1089,7 +1066,7 @@ class PredicateList extends QueryTreeNod
 		{
 			AndNode			nextAnd;
 			/* Look at the current predicate from the predicate list */
-			nextAnd = ((Predicate) elementAt(index)).getAndNode();
+            nextAnd = elementAt(index).getAndNode();
 
 			if ((nextAnd.getLeftOperand().isBooleanTrue()) &&
 				(nextAnd.getRightOperand().isBooleanTrue()))
@@ -1139,7 +1116,7 @@ class PredicateList extends QueryTreeNod
 		for (int index = size() - 1; index >= 0; index--)
 		{
 			/* Look at the current predicate from the predicate list */
-			nextAnd = ((Predicate) elementAt(index)).getAndNode();
+            nextAnd = elementAt(index).getAndNode();
 
 			// Skip over the predicate if it is not a constant expression
 			if (! nextAnd.isConstantExpression())
@@ -1233,7 +1210,7 @@ class PredicateList extends QueryTreeNod
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			nextAnd = ((Predicate) elementAt(index)).getAndNode();
+            nextAnd = elementAt(index).getAndNode();
 
 			/* We can skip over TRUE AND TRUE */
 			if ((nextAnd.getLeftOperand().isBooleanTrue()) &&
@@ -1293,15 +1270,10 @@ class PredicateList extends QueryTreeNod
 	 */
     void remapColumnReferencesToExpressions() throws StandardException
 	{
-		Predicate		pred;
-
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			pred = (Predicate) elementAt(index);
-
-			pred.setAndNode((AndNode) 
-						pred.getAndNode().remapColumnReferencesToExpressions());
+            p.setAndNode(
+                (AndNode)p.getAndNode().remapColumnReferencesToExpressions());
 		}
 	}
 
@@ -1367,39 +1339,30 @@ class PredicateList extends QueryTreeNod
 	 */
     void xorReferencedSet(JBitSet fromMap)
 	{
-		Predicate		predicate;
-
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			predicate = (Predicate) elementAt(index);
-
 			if (SanityManager.DEBUG)
 			{
 				SanityManager.ASSERT(
-					fromMap.size() == predicate.getReferencedSet().size(),
+                    fromMap.size() == p.getReferencedSet().size(),
 					"fromMap.size() (" + fromMap.size() + 
 					") does not equal predicate.getReferencedSet().size() (" +
-					predicate.getReferencedSet().size());
+                    p.getReferencedSet().size());
 			}
 			
-			predicate.getReferencedSet().xor(fromMap);
+            p.getReferencedSet().xor(fromMap);
 		}
 	}
 
 	private void countScanFlags()
 	{
-		Predicate		predicate;
-
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			predicate = (Predicate) elementAt(index);
-			if (predicate.isStartKey())
+            if (p.isStartKey())
 				numberOfStartPredicates++;
-			if (predicate.isStopKey())
+            if (p.isStopKey())
 				numberOfStopPredicates++;
-			if (predicate.isQualifier())
+            if (p.isQualifier())
 				numberOfQualifiers++;
 		}
 	}
@@ -1437,8 +1400,7 @@ class PredicateList extends QueryTreeNod
 		 */
 		for (int index = size() - 1; index >= 0; index--)
 		{
-			Predicate	predicate;
-			predicate = (Predicate) elementAt(index);
+            Predicate predicate = elementAt(index);
 
             CollectNodesVisitor<ColumnReference> getCRs =
                 new CollectNodesVisitor<ColumnReference>(ColumnReference.class);
@@ -1614,11 +1576,9 @@ class PredicateList extends QueryTreeNod
         CollectNodesVisitor<ColumnReference> collectCRs =
             new CollectNodesVisitor<ColumnReference>(ColumnReference.class);
 
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			Predicate predicate = (Predicate) elementAt(index);
-			predicate.getAndNode().accept(collectCRs);
+            p.getAndNode().accept(collectCRs);
 		}
 
         for (ColumnReference ref : collectCRs.getList())
@@ -1660,11 +1620,9 @@ class PredicateList extends QueryTreeNod
     boolean     resultColTable)
 		throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-            AndNode and = ((Predicate) elementAt(index)).getAndNode();
-			and.checkTopPredicatesForEqualsConditions(
+            p.getAndNode().checkTopPredicatesForEqualsConditions(
 				tableNumber, eqOuterCols, tableNumbers, tableColMap,
 				resultColTable);
 		}
@@ -1677,11 +1635,9 @@ class PredicateList extends QueryTreeNod
 	 */
 	 boolean allPushable()
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate p : this)
 		{
-			Predicate		predicate = (Predicate) elementAt(index);
-			if (! predicate.getPushable())
+            if (! p.getPushable())
 			{
 				return false;
 			}
@@ -1699,8 +1655,7 @@ class PredicateList extends QueryTreeNod
      boolean allReference(FromBaseTable fbt) {
          int tableNumber = fbt.getTableNumber();
 
-         for (int i = 0; i < size(); i++) {
-             Predicate p = (Predicate) elementAt(i);
+         for (Predicate p : this) {
              if (!p.getReferencedSet().get(tableNumber)) {
                  return false;
              }
@@ -1728,7 +1683,7 @@ class PredicateList extends QueryTreeNod
 		// Walk the list backwards because of possible deletes
 		for (int index = size() - 1; index >= 0; index--)
 		{
-			Predicate predicate = (Predicate) elementAt(index);
+            Predicate predicate = elementAt(index);
 			if (! predicate.getPushable())
 			{
 				continue;
@@ -1774,12 +1729,10 @@ class PredicateList extends QueryTreeNod
 		 * CRs from the subquery and decrement their 
 		 * nesting level.
 		 */
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate predicate : this)
 		{
 			ColumnReference cr1 = null;
 			ColumnReference cr2 = null;
-			Predicate predicate = (Predicate) elementAt(index);
 			ValueNode vn = predicate.getAndNode().getLeftOperand();
 
   			if (vn instanceof BinaryOperatorNode)
@@ -1882,10 +1835,8 @@ class PredicateList extends QueryTreeNod
 		/* Pull the equijoin clauses, putting each one in the list for
 		 * each of the tables being joined.
 		 */
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate predicate : this)
 		{
-			Predicate predicate = (Predicate) elementAt(index);
 			ValueNode vn = predicate.getAndNode().getLeftOperand();
 
 			if (! (vn.isBinaryEqualsOperatorNode()))
@@ -1936,7 +1887,7 @@ class PredicateList extends QueryTreeNod
 			ArrayList<Predicate> movePreds = new ArrayList<Predicate>();
 			for (int jcIndex = outerJCL.size() - 1; jcIndex >= 0; jcIndex--)
 			{
-				Predicate predicate = (Predicate) outerJCL.elementAt(jcIndex);
+                Predicate predicate = outerJCL.elementAt(jcIndex);
 				if (predicate.getEquivalenceClass() != -1)
 				{
 					outerJCL.removeElementAt(jcIndex);
@@ -1962,7 +1913,8 @@ class PredicateList extends QueryTreeNod
 				/* Assign an equivalence class to those Predicates 
 				 * that have not already been assigned an equivalence class.
 				 */
-				Predicate outerP = (Predicate) outerJCL.elementAt(outerIndex);
+                Predicate outerP = outerJCL.elementAt(outerIndex);
+
 				if (outerP.getEquivalenceClass() == -1)
 				{
 					outerP.setEquivalenceClass(cc.getNextEquivalenceClass());
@@ -1994,12 +1946,11 @@ class PredicateList extends QueryTreeNod
 				 * in the chain/equivalence class
 				 */
 				PredicateList middleJCL = joinClauses[middleTableNumber];
-				for (int middleIndex = 0; middleIndex < middleJCL.size(); middleIndex++)
+                for (Predicate middleP : middleJCL)
 				{
 					/* Skip those Predicates that have already been
 					 * assigned a different equivalence class.
 					 */
-					Predicate middleP = (Predicate) middleJCL.elementAt(middleIndex);
 					if (middleP.getEquivalenceClass() != -1 &&
 						middleP.getEquivalenceClass() != outerEC)
 					{
@@ -2061,7 +2012,7 @@ class PredicateList extends QueryTreeNod
 					int innerIndex = 0;
 					for ( ; innerIndex < innerJCL.size(); innerIndex++)
 					{
-						innerP = (Predicate) innerJCL.elementAt(innerIndex);
+                        innerP = innerJCL.elementAt(innerIndex);
 
 						// Skip over predicates with other equivalence classes
 						if (innerP.getEquivalenceClass() != -1 &&
@@ -2204,10 +2155,8 @@ class PredicateList extends QueryTreeNod
         PredicateList searchClauses = new PredicateList(getContextManager());
 		RelationalOperator	equalsNode = null;
 
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate predicate : this)
 		{
-			Predicate		predicate = (Predicate) elementAt(index);
 			AndNode			andNode = predicate.getAndNode();
 
 			// Skip anything that's not a RelationalOperator
@@ -2281,13 +2230,12 @@ class PredicateList extends QueryTreeNod
 		 * NOTE: We can append to the searchClauses while walking
 		 * them, thus we cannot cache the value of size().
 		 */
-		for (int scIndex = 0; scIndex < searchClauses.size(); scIndex++)
+        for (Predicate searchClause : searchClauses)
 		{
 			ColumnReference searchCR;
 			DataValueDescriptor searchODV = null;
-			RelationalOperator ro = (RelationalOperator)
-                    (((Predicate) searchClauses.elementAt(scIndex)).
-                    getAndNode()).getLeftOperand();
+            RelationalOperator ro =
+               (RelationalOperator)(searchClause.getAndNode()).getLeftOperand();
 
 			// Find the ColumnReference and constant value, if any, in the search clause
 			if (ro instanceof UnaryComparisonOperatorNode)
@@ -2311,8 +2259,7 @@ class PredicateList extends QueryTreeNod
 			int colNumber = searchCR.getColumnNumber();
 
 			// Look for any equijoin clauses of interest
-			int ejcSize = equijoinClauses.size();
-			for (int ejcIndex = 0; ejcIndex < ejcSize; ejcIndex++)
+            for (Predicate predicate : equijoinClauses)
 			{
 				/* Skip the current equijoin clause if it has already been used
 				 * when adding a new search clause of the same type
@@ -2321,7 +2268,6 @@ class PredicateList extends QueryTreeNod
 				 * fact that a search clause was added because multiple search clauses
 				 * can get added when preprocessing LIKE and BETWEEN.
 				 */
-				Predicate predicate = (Predicate) equijoinClauses.elementAt(ejcIndex);
 				if (predicate.transitiveSearchClauseAdded(ro))
 				{
 					continue;
@@ -2361,12 +2307,11 @@ class PredicateList extends QueryTreeNod
 				boolean match = false;
                 ColumnReference searchCR2;
                 RelationalOperator ro2;
-				int scSize = searchClauses.size();
-				for (int scIndex2 = 0; scIndex2 < scSize; scIndex2++)
+
+                for (Predicate sc : searchClauses)
 				{
 					DataValueDescriptor currODV = null;
-                    ro2 = (RelationalOperator)(((Predicate) searchClauses.
-                            elementAt(scIndex2)).getAndNode()).getLeftOperand();
+                    ro2 = (RelationalOperator)sc.getAndNode().getLeftOperand();
 
 					// Find the ColumnReference in the search clause
 					if (ro2 instanceof UnaryComparisonOperatorNode)
@@ -2423,7 +2368,7 @@ class PredicateList extends QueryTreeNod
                     //             /   \
                     //       roClone    true
                     //
-                   ValueNode trueNode =
+                    ValueNode trueNode =
                             new BooleanConstantNode(true, getContextManager());
                     AndNode newAnd =
                             new AndNode(roClone, trueNode, getContextManager());
@@ -2454,7 +2399,7 @@ class PredicateList extends QueryTreeNod
 		 */
 		for (int index = size() - 1; index >= 0; index--)
 		{
-			Predicate predicate = (Predicate) elementAt(index);
+            Predicate predicate = elementAt(index);
 
 			if (predicate.transitiveSearchClauseAdded(equalsNode))
 			{
@@ -2477,7 +2422,7 @@ class PredicateList extends QueryTreeNod
 		int outer = size() - 1;
 		while (outer >= 0)
 		{
-			Predicate predicate = (Predicate) elementAt(outer);
+            Predicate predicate = elementAt(outer);
 			int equivalenceClass = predicate.getEquivalenceClass();
 
 			if (equivalenceClass == -1)
@@ -2489,7 +2434,7 @@ class PredicateList extends QueryTreeNod
 			// Walk the rest of the list backwards.
 			for (int inner = outer - 1; inner >= 0; inner--)
 			{
-				Predicate innerPredicate = (Predicate) elementAt(inner);
+                Predicate innerPredicate = elementAt(inner);
 				if (innerPredicate.getEquivalenceClass() == equivalenceClass)
 				{
 					/* Only 1 predicate per column can be marked as a start
@@ -2564,7 +2509,7 @@ class PredicateList extends QueryTreeNod
 		 */
 		for (int index = size() - 1; index >= 0; index--)
 		{
-			predicate = (Predicate) elementAt(index);
+            predicate = elementAt(index);
 
 			if (SanityManager.DEBUG)
 			{
@@ -2620,11 +2565,8 @@ class PredicateList extends QueryTreeNod
 	{
 		PredicateList	theOtherList = (PredicateList) otherList;
 
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate predicate : this)
 		{
-			Predicate predicate = (Predicate) elementAt(index);
-
 			/*
 			** Clear all of the scan flags since they may be different
 			** when the new list is re-classified
@@ -2666,14 +2608,15 @@ class PredicateList extends QueryTreeNod
 	 */
 	public boolean isRedundantPredicate(int predNum)
 	{
-		Predicate pred = (Predicate) elementAt(predNum);
+        Predicate pred = elementAt(predNum);
 		if (pred.getEquivalenceClass() == -1)
 		{
 			return false;
 		}
 		for (int index = 0; index < predNum; index++)
 		{
-			if ( ((Predicate) elementAt(index)).getEquivalenceClass() == pred.getEquivalenceClass())
+            if (elementAt(index).getEquivalenceClass() ==
+                pred.getEquivalenceClass())
 			{
 				return true;
 			}
@@ -2721,7 +2664,7 @@ class PredicateList extends QueryTreeNod
 		 */
 		for (int index = size - 1; index >= 0; index--)
 		{
-			Predicate pred = ((Predicate) elementAt(index));
+            Predicate pred = elementAt(index);
 
 			if ( ! pred.isStartKey() )
 				continue;
@@ -2772,11 +2715,9 @@ class PredicateList extends QueryTreeNod
                 generateIndexableRow(acb, numberOfStopPredicates);
 
 			int	colNum = 0;
-			int size = size();
-			for (int index = 0; index < size; index++)
-			{
-				Predicate pred = ((Predicate) elementAt(index));
 
+            for (Predicate pred : this)
+            {
 				if ( ! pred.isStopKey() )
 					continue;
 
@@ -2817,7 +2758,7 @@ class PredicateList extends QueryTreeNod
 		 */
 		for (int index = size - 1; index >= 0; index--)
 		{
-			Predicate pred = ((Predicate) elementAt(index));
+            Predicate pred = elementAt(index);
 
 			if ( ! pred.isStopKey() )
 				continue;
@@ -2919,7 +2860,7 @@ class PredicateList extends QueryTreeNod
 	{
 		for (int index = size() - 1; index >= 0; index--)
 		{
-			Predicate pred = (Predicate)elementAt(index);
+            Predicate pred = elementAt(index);
 
 			// Don't do anything if it's not an IN-list probe predicate.
 			if (!pred.isInListProbePredicate())
@@ -2942,7 +2883,7 @@ class PredicateList extends QueryTreeNod
 			{
 				for (int i = 0; i < index; i++)
 				{
-					if (((Predicate)elementAt(i)).isInListProbePredicate())
+                    if (elementAt(i).isInListProbePredicate())
 					{
 						SanityManager.THROWASSERT("Found multiple probe " +
 							"predicates for IN-list when only one was " +
@@ -3061,7 +3002,7 @@ class PredicateList extends QueryTreeNod
         int num_of_or_conjunctions = 0;
         for (int i = 0; i < numberOfQualifiers; i++)
         {
-            if (((Predicate) elementAt(i)).isOrList())
+            if (elementAt(i).isOrList())
             {
                 num_of_or_conjunctions++;
             }
@@ -3077,8 +3018,8 @@ class PredicateList extends QueryTreeNod
         // AND clauses.
 
         consMB.getField(qualField);             // 1st arg allocateQualArray
-        consMB.push((int) 0);                   // 2nd arg allocateQualArray
-        consMB.push((int) numberOfQualifiers - num_of_or_conjunctions);  // 3rd arg allocateQualArray
+        consMB.push(0);                   // 2nd arg allocateQualArray
+        consMB.push(numberOfQualifiers - num_of_or_conjunctions);  // 3rd arg allocateQualArray
 
         consMB.callMethod(
             VMOpcode.INVOKESTATIC,
@@ -3109,7 +3050,7 @@ class PredicateList extends QueryTreeNod
 		for (int index = 0; index < size; index++)
 		{
 
-			Predicate pred = ((Predicate) elementAt(index));
+            Predicate pred = elementAt(index);
 
 			if (!pred.isQualifier())
             {
@@ -3160,7 +3101,7 @@ class PredicateList extends QueryTreeNod
             for (int index = qualNum; index < size; index++, and_idx++)
             {
 
-                Predicate pred = ((Predicate) elementAt(index));
+                Predicate pred = elementAt(index);
 
                 if (SanityManager.DEBUG)
                 {
@@ -3194,8 +3135,8 @@ class PredicateList extends QueryTreeNod
                 // clause.  ie. (a = 1 or b = 2), will allocate a 2 entry array.
 
                 consMB.getField(qualField);        // 1st arg allocateQualArray
-                consMB.push((int) and_idx);        // 2nd arg allocateQualArray
-                consMB.push((int) a_list.size());  // 3rd arg allocateQualArray
+                consMB.push(and_idx);        // 2nd arg allocateQualArray
+                consMB.push(a_list.size());  // 3rd arg allocateQualArray
 
                 consMB.callMethod(
                     VMOpcode.INVOKESTATIC, 
@@ -3272,11 +3213,9 @@ class PredicateList extends QueryTreeNod
             sortList[i] = new PredicateList(getContextManager());
 
 		int predIndex;
-		int size = size();
-		for (predIndex = 0; predIndex < size; predIndex++)
-		{
-			Predicate pred = (Predicate) elementAt(predIndex);
 
+        for (Predicate pred : this)
+        {
 			if (! pred.isQualifier())
 			{
 				sortList[QUALIFIER_ORDER_NON_QUAL].addElement(pred);
@@ -3365,11 +3304,9 @@ class PredicateList extends QueryTreeNod
 			LocalField rowField = generateIndexableRow(acb, numberOfStartPredicates);
 
 			int	colNum = 0;
-			int size = size();
-			for (int index = 0; index < size; index++)
-			{
-				Predicate pred = ((Predicate) elementAt(index));
 
+            for (Predicate pred : this)
+            {
 				if ( ! pred.isStartKey() )
 					continue;
 
@@ -3413,11 +3350,9 @@ class PredicateList extends QueryTreeNod
 		 * start and stop positions when a predicate is
 		 * a start key iff it is a stop key.
 		 */
-		int size = size();
-		for (int index = 0; index < size; index++)
-		{
-			Predicate pred = ((Predicate) elementAt(index));
 
+        for (Predicate pred : this)
+        {
 			if ( (pred.isStartKey() && (! pred.isStopKey())) ||
 				 (pred.isStopKey() && (! pred.isStartKey())))
 			{
@@ -3631,10 +3566,8 @@ class PredicateList extends QueryTreeNod
 		/*
 		** Walk this list
 		*/
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (Predicate pred : this)
 		{
-			Predicate	pred = (Predicate) elementAt(index);
 			RelationalOperator relop = pred.getRelop();
 
 			if (pred.isRelationalOpPredicate())
@@ -3699,11 +3632,9 @@ class PredicateList extends QueryTreeNod
 		 * the probe predicate are sorted in DESCENDING order
 		 * at execution time.
 		 */
-		int size = size();
 		OrderByList orderBy = (OrderByList)ordering;
-		for (int index = 0; index < size; index++)
+        for (Predicate pred : this)
 		{
-			Predicate pred = (Predicate) elementAt(index);
 			if (!pred.isInListProbePredicate())
 				continue;
 
@@ -3752,7 +3683,7 @@ class PredicateList extends QueryTreeNod
 				continue;
 
 			/* to workingPredicates only add useful predicates... */
-			workingPredicates.addOptPredicate((Predicate)elementAt(i));
+            workingPredicates.addOptPredicate(elementAt(i));
 		}
 
 		int numWorkingPredicates = workingPredicates.size();
@@ -3802,7 +3733,7 @@ class PredicateList extends QueryTreeNod
 
 			for (int j = 0; j < numWorkingPredicates; j++)
 			{
-				Predicate pred = (Predicate)workingPredicates.elementAt(j);
+                Predicate pred = workingPredicates.elementAt(j);
 
 				int ip = pred.hasEqualOnColumnList(baseColumnList, 
 												   optTable);

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -822,10 +822,13 @@ class ProjectRestrictNode extends Single
         restrictionList = new PredicateList(getContextManager());
         /* For non-base table, we remove first 2 lists from requal list to avoid adding duplicates.
          */
-		for (int i = 0; i < searchRestrictionList.size(); i++)
-			requalificationRestrictionList.removeOptPredicate((Predicate) searchRestrictionList.elementAt(i));
-		for (int i = 0; i < joinQualifierList.size(); i++)
-			requalificationRestrictionList.removeOptPredicate((Predicate) joinQualifierList.elementAt(i));
+        for (Predicate p : searchRestrictionList) {
+            requalificationRestrictionList.removeOptPredicate(p);
+        }
+
+        for (Predicate p : joinQualifierList) {
+            requalificationRestrictionList.removeOptPredicate(p);
+        }
 
 		joinQualifierList.transferNonQualifiers(this, restrictionList); //purify joinQual list
 		requalificationRestrictionList.copyPredicatesToOtherList(restrictionList); //any residual
@@ -1787,8 +1790,8 @@ class ProjectRestrictNode extends Single
 		}
 
 		HashSet<BaseColumnNode> columns = new HashSet<BaseColumnNode>();
-		for (int i = 0; i < resultColumns.size(); i++) {
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
+
+        for (ResultColumn rc : resultColumns) {
 			BaseColumnNode bc = rc.getBaseColumnNode();
 			if (bc == null) return false;
 			columns.add(bc);

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -22,10 +22,12 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.compile.Visitor;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.Visitable;
 
 /**
  * QueryTreeNodeVector is the root class for all lists of query tree nodes.
@@ -34,12 +36,15 @@ import org.apache.derby.iapi.services.co
  *
  */
 
-abstract class QueryTreeNodeVector extends QueryTreeNode
+class QueryTreeNodeVector<E extends QueryTreeNode> extends QueryTreeNode
+                                                   implements Iterable<E>
 {
-	private final ArrayList<QueryTreeNode> v = new ArrayList<QueryTreeNode>();
+    private final ArrayList<E> v = new ArrayList<E>();
+    final Class<E> eltClass; // needed for cast in #acceptChildren
 
-    QueryTreeNodeVector(ContextManager cm) {
+    QueryTreeNodeVector(Class<E> eltClass, ContextManager cm) {
         super(cm);
+        this.eltClass = eltClass;
     }
 
 	public final int size()
@@ -47,48 +52,43 @@ abstract class QueryTreeNodeVector exten
 		return v.size();
 	}
 
-	final QueryTreeNode elementAt(int index)
+    final E elementAt(int index)
 	{
         return v.get(index);
 	}
 
-	final void addElement(QueryTreeNode qt)
+    void addElement(E qt)
 	{
 		v.add(qt);
 	}
 
-	final void removeElementAt(int index)
+    final E removeElementAt(int index)
 	{
-		v.remove(index);
+        return v.remove(index);
 	}
 
-	final void removeElement(QueryTreeNode qt)
+    final void removeElement(E qt)
 	{
 		v.remove(qt);
 	}
 
-	final Object remove(int index)
-	{
-        return v.remove(index);
-	}
-
-	final int indexOf(QueryTreeNode qt)
+    final int indexOf(E qt)
 	{
 		return v.indexOf(qt);
 	}
 
-	final void setElementAt(QueryTreeNode qt, int index)
+    final void setElementAt(E qt, int index)
 	{
 		v.set(index, qt);
 	}
 
-	void destructiveAppend(QueryTreeNodeVector qtnv)
+    final void destructiveAppend(QueryTreeNodeVector<E> qtnv)
 	{
 		nondestructiveAppend(qtnv);
 		qtnv.removeAllElements();
 	}
 
-	void nondestructiveAppend(QueryTreeNodeVector qtnv)
+    final void nondestructiveAppend(QueryTreeNodeVector<E> qtnv)
 	{
         v.addAll(qtnv.v);
 	}
@@ -98,7 +98,7 @@ abstract class QueryTreeNodeVector exten
 		v.clear();
 	}
 
-	final void insertElementAt(QueryTreeNode qt, int index)
+    final void insertElementAt(E qt, int index)
 	{
 		v.add(index, qt);
 	}
@@ -114,7 +114,7 @@ abstract class QueryTreeNodeVector exten
 		if (SanityManager.DEBUG) {
 			for (int index = 0; index < size(); index++) {
 				debugPrint(formatNodeString("[" + index + "]:", depth));
-                QueryTreeNode elt = elementAt(index);
+                E elt = elementAt(index);
 				elt.treePrint(depth);
 			}
 		}
@@ -137,7 +137,13 @@ abstract class QueryTreeNodeVector exten
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-            setElementAt((QueryTreeNode)(elementAt(index)).accept(v), index);
+            Visitable vbl = elementAt(index).accept(v);
+            setElementAt(eltClass.cast(vbl), index);
 		}
 	}
+
+    /* Iterable interface */
+    public final Iterator<E> iterator() {
+        return v.iterator();
+    }
 }

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -33,7 +33,7 @@ import org.apache.derby.iapi.sql.compile
 class ReplaceAggregatesWithCRVisitor implements Visitor
 {
 	private ResultColumnList rcl;
-	private Class skipOverClass;
+    private Class<?> skipOverClass;
 	private int tableNumber;
 
 	/**
@@ -50,7 +50,7 @@ class ReplaceAggregatesWithCRVisitor imp
 	}
 
     ReplaceAggregatesWithCRVisitor(
-        ResultColumnList rcl, int tableNumber, Class skipOverClass)
+        ResultColumnList rcl, int tableNumber, Class<?> skipOverClass)
 	{
 		this.rcl = rcl;
 		this.tableNumber = tableNumber;
@@ -66,7 +66,7 @@ class ReplaceAggregatesWithCRVisitor imp
 	 * @param rcl the result column list
 	 * @param nodeToSkip don't examine anything below nodeToSkip
 	 */
-    ReplaceAggregatesWithCRVisitor(ResultColumnList rcl, Class nodeToSkip)
+    ReplaceAggregatesWithCRVisitor(ResultColumnList rcl, Class<?> nodeToSkip)
 	{
 		this.rcl = rcl;
 		this.skipOverClass = nodeToSkip;

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -32,7 +32,7 @@ import org.apache.derby.iapi.sql.compile
 class ReplaceWindowFuncCallsWithCRVisitor implements Visitor
 {
 	private ResultColumnList rcl;
-	private Class skipOverClass;
+    private Class<?> skipOverClass;
 	private int tableNumber;
 
 	/**
@@ -46,7 +46,7 @@ class ReplaceWindowFuncCallsWithCRVisito
 	 */
     ReplaceWindowFuncCallsWithCRVisitor(ResultColumnList rcl,
 											int tableNumber,
-											Class skipOverClass)
+                                            Class<?> skipOverClass)
 	{
 		this.rcl = rcl;
 		this.tableNumber = tableNumber;

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -703,7 +703,7 @@ class ResultColumn extends ValueNode
 	 * @exception StandardException		Thrown on error
 	 */
     @Override
-    ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
+    ResultColumn bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 				throws StandardException
 	{
 		/*
@@ -980,7 +980,7 @@ class ResultColumn extends ValueNode
 	 * @exception StandardException		Thrown on error
 	 */
     @Override
-    ValueNode preprocess(int numTables,
+    ResultColumn preprocess(int numTables,
 								FromList outerFromList,
 								SubqueryList outerSubqueryList,
 								PredicateList outerPredicateList) 
@@ -1724,6 +1724,7 @@ class ResultColumn extends ValueNode
 	/**
 	 * @exception StandardException		Thrown on error
 	 */
+    @SuppressWarnings("fallthrough")
 	private DataValueDescriptor convertConstant(TypeId toTypeId, int maxWidth,
 			DataValueDescriptor constantValue)
 		throws StandardException