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 [3/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/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java Fri Jun 28 04:32:08 2013
@@ -65,7 +65,7 @@ import org.apache.derby.iapi.util.JBitSe
  * @see ResultColumn
  */
 
-class ResultColumnList extends QueryTreeNodeVector
+class ResultColumnList extends QueryTreeNodeVector<ResultColumn>
 {
 	/* Is this the ResultColumnList for an index row? */
 	protected boolean indexRow;
@@ -107,7 +107,7 @@ class ResultColumnList extends QueryTree
 	private int initialListSize = 0;
 
     ResultColumnList(ContextManager cm) {
-        super(cm);
+        super(ResultColumn.class, cm);
         setNodeType(C_NodeTypes.RESULT_COLUMN_LIST);
 	}
 
@@ -145,11 +145,10 @@ class ResultColumnList extends QueryTree
 		** so the new virtual column ids start at the original size
 		** of this list, plus one.
 		*/
-		int otherSize = resultColumns.size();
-		for (int index = 0; index < otherSize; index++)
+        for (ResultColumn rc : resultColumns)
 		{
 			/* ResultColumns are 1-based */
-			((ResultColumn) resultColumns.elementAt(index)).setVirtualColumnId(newID);
+            rc.setVirtualColumnId(newID);
 			newID++;
 		}
 
@@ -181,7 +180,7 @@ class ResultColumnList extends QueryTree
 		{
 			// this wraps the cast needed, 
 			// and the 0-based nature of the Vectors.
-			ResultColumn rc = (ResultColumn)elementAt(position-1);
+            ResultColumn rc = elementAt(position-1);
 			if (rc.getColumnPosition() == position)
 			{
 				return rc;
@@ -194,7 +193,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 			if (rc.getColumnPosition() == position)
 			{
 				return rc;
@@ -226,7 +225,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = size() - 1; index >= 0; index--)
 		{
-            ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 			if (!(rc.getExpression() instanceof ColumnReference))
 			{
 				// If the rc's expression isn't a column reference then
@@ -290,11 +289,8 @@ class ResultColumnList extends QueryTree
 
     ResultColumn getResultColumn(String columnName, boolean markIfReferenced )
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn resultColumn : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-
 			if (columnName.equals( resultColumn.getName()) )
 			{
                 /* Mark ResultColumn as referenced and return it */
@@ -334,7 +330,7 @@ class ResultColumnList extends QueryTree
 
         for (int index = 0; index < size; index++)
         {
-            ResultColumn resultColumn = (ResultColumn)elementAt(index);
+            ResultColumn resultColumn = elementAt(index);
             ResultColumn rc = resultColumn;
 
             while (rc != null) {
@@ -453,7 +449,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
+            ResultColumn resultColumn = elementAt(index);
 
 			/* If the column's table name is non-null, then we have found a match
 			 * only if the RC's table name is non-null and the same as the
@@ -505,14 +501,11 @@ class ResultColumnList extends QueryTree
 								boolean considerGeneratedColumns)
 		throws StandardException
 	{
-		int				size = size();
 		ResultColumn	retRC = null;
 		String			columnName = cr.getColumnName();
 
-		for (int index = 0; index < size; index++)
+        for (ResultColumn resultColumn : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-
 			if (columnName.equals( resultColumn.getName()))
 			{
 				if (resultColumn.isGenerated() && !considerGeneratedColumns) {
@@ -581,7 +574,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			resultColumn = (ResultColumn) elementAt(index);
+            resultColumn = elementAt(index);
 
 			/* The order by column is qualified, then it is okay to consider
 			 * this RC if:
@@ -590,7 +583,7 @@ class ResultColumnList extends QueryTree
 			 *	o  The RC is not qualified, but its expression is a ColumnReference
 			 *	   from the same table (as determined by the tableNumbers).
 			 */
-                        boolean columnNameMatches;
+            boolean columnNameMatches;
 			if (tableName != null)
 			{
                 ValueNode rcExpr = resultColumn.getExpression();
@@ -661,8 +654,9 @@ class ResultColumnList extends QueryTree
 	 */
 	private void collapseVirtualColumnIdGap(int gap)
 	{
-		for (int index = 0; index < size(); index++)
-			((ResultColumn) elementAt(index)).collapseVirtualColumnIdGap(gap);
+        for (ResultColumn rc : this) {
+            rc.collapseVirtualColumnIdGap(gap);
+        }
 	}
 
 
@@ -708,7 +702,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			resultColumn = (ResultColumn) elementAt(index);
+            resultColumn = elementAt(index);
 
 			// We may be checking on "ORDER BY T.A" against "SELECT *".
 			// exposedName will not be null and "*" will not have an expression
@@ -791,10 +785,10 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn thisResultColumn = (ResultColumn) elementAt(index);
-			ResultColumn nameListResultColumn =
-				(ResultColumn) nameList.elementAt(index);
-			thisResultColumn.setName(nameListResultColumn.getName());
+            ResultColumn thisResultColumn = elementAt(index);
+            ResultColumn nameListResultColumn = nameList.elementAt(index);
+
+            thisResultColumn.setName(nameListResultColumn.getName());
 			thisResultColumn.setNameGenerated(nameListResultColumn.isNameGenerated());
 		}
 	}
@@ -822,10 +816,8 @@ class ResultColumnList extends QueryTree
 		int size = size();
  		for (int index = 0; index < size; index++)
 		{
-			ValueNode vn = (ValueNode) elementAt(index);
-			vn = ((ResultColumn) vn ).bindExpression(
-												fromList, subqueryList, 
-                                                aggregates);
+            ResultColumn vn = elementAt(index);
+            vn = vn.bindExpression(fromList, subqueryList, aggregates);
 			setElementAt(vn, index);
 		}
 	}
@@ -841,10 +833,9 @@ class ResultColumnList extends QueryTree
     void bindResultColumnsToExpressions()
 					throws StandardException
 	{
-		int size = size();
- 		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			((ResultColumn) elementAt(index) ).bindResultColumnToExpression();
+            rc.bindResultColumnToExpression();
 		}
 	}
 
@@ -864,9 +855,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
-			rc.bindResultColumnByName(
+            elementAt(index).bindResultColumnByName(
 						targetTableDescriptor,
 						index + 1
 					);
@@ -898,7 +887,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 
 			rc.bindResultColumnByName(
 						targetTableDescriptor,
@@ -951,7 +940,7 @@ class ResultColumnList extends QueryTree
 		for (int index = 0; index < size; index++)
 		{
 			ResultColumn matchRC;
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 
 			/* Verify that this column's name is unique within the list */
 			String colName = rc.getName();
@@ -1021,7 +1010,7 @@ class ResultColumnList extends QueryTree
 			** Add one to the iterator index, because iterator indexes start at zero,
 			** and column numbers start at one.
 			*/
-			((ResultColumn) elementAt(index) ).bindResultColumnByPosition(
+            elementAt(index).bindResultColumnByPosition(
 						targetTableDescriptor,
 						index + 1);
 		}
@@ -1051,7 +1040,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
+            ResultColumn resultColumn = elementAt(index);
 			setElementAt(resultColumn.preprocess(numTables,
 												 outerFromList,
 												 outerSubqueryList,
@@ -1073,9 +1062,9 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn	otherRC = (ResultColumn) toStore.elementAt(index);
+            ResultColumn    otherRC = toStore.elementAt(index);
 
-			((ResultColumn) elementAt(index) ).checkStorableExpression(otherRC);
+            elementAt(index).checkStorableExpression(otherRC);
 		}
 	}
 
@@ -1097,12 +1086,9 @@ class ResultColumnList extends QueryTree
 
 		int ssCount = 0;
 		boolean[] isSS = new boolean[heapColCount];//Should be table length.
-		int size = size();
 
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			if (rc.getTypeId().streamStorable())
 			{
                 //System.out.println("    streamStorable=true");
@@ -1136,11 +1122,9 @@ class ResultColumnList extends QueryTree
 	void checkStorableExpressions()
 			throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			((ResultColumn) elementAt(index) ).checkStorableExpression();
+            rc.checkStorableExpression();
 		}
 	}
 
@@ -1219,7 +1203,7 @@ class ResultColumnList extends QueryTree
 		    // generate statements of the form
 			// fieldX.setColumn(columnNumber, (DataValueDescriptor) columnExpr);
 			// and add them to exprFun.
-			rc = (ResultColumn) elementAt(index);
+            rc = elementAt(index);
 
 			/* If we are not generating nulls, then we can skip this RC if
 			 * it is simply propagating a column from the source result set.
@@ -1249,7 +1233,6 @@ class ResultColumnList extends QueryTree
 					//We are talking about column c as in "select c"
 					ResultColumnList jnRCL = 
 							rc.getJoinResultSet().getResultColumns();
-					ResultColumn joinColumn;
 					int joinResultSetNumber = 
 							rc.getJoinResultSet().getResultSetNumber();
 
@@ -1258,8 +1241,8 @@ class ResultColumnList extends QueryTree
 					// column to generate the code explained above
 					int virtualColumnIdRightTable = -1;
 					int virtualColumnIdLeftTable = -1;
-					for (int i=0; i< jnRCL.size(); i++) {
-						joinColumn = (ResultColumn) jnRCL.elementAt(i);
+
+                    for (ResultColumn joinColumn : jnRCL) {
 						if (joinColumn.getName().equals(rc.getUnderlyingOrAliasName())) {
 							if (joinColumn.isRightOuterJoinUsingClause())
 								virtualColumnIdRightTable = joinColumn.getVirtualColumnId();
@@ -1447,9 +1430,8 @@ class ResultColumnList extends QueryTree
 		ExecRow				row = getExecutionFactory().getValueRow( columnCount );
 		int					position = 1;
 
-		for (int index = 0; index < columnCount; index++)
+        for (ResultColumn rc : this)
 		{
-		    ResultColumn rc = (ResultColumn) elementAt(index);
 			DataTypeDescriptor dataType = rc.getTypeServices();
 			DataValueDescriptor dataValue = dataType.getNull();
 
@@ -1527,9 +1509,7 @@ class ResultColumnList extends QueryTree
         // Get the index of the first column to set in the row template.
         int colNum = (referencedCols == null) ? 0 : referencedCols.anySetBit();
 
-        for (int i = 0; i < size(); i++) {
-            ResultColumn rc = (ResultColumn) elementAt(i);
-
+        for (ResultColumn rc : this) {
             ValueNode sourceExpr = rc.getExpression();
 
             if (sourceExpr instanceof CurrentRowLocationNode) {
@@ -1666,7 +1646,7 @@ class ResultColumnList extends QueryTree
 		/* First walk result column list looking for *'s to expand */
 		for (int index = 0; index < size(); index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 			if (rc instanceof AllResultColumn)
 			{
 				expanded = true;
@@ -1724,7 +1704,7 @@ class ResultColumnList extends QueryTree
 			for (int index = 0; index < size; index++)
 			{
 				/* Vectors are 0-based, VirtualColumnIds are 1-based. */
-				((ResultColumn) elementAt(index)).setVirtualColumnId(index + 1);
+                elementAt(index).setVirtualColumnId(index + 1);
 			}
 		}
 	}
@@ -1738,13 +1718,9 @@ class ResultColumnList extends QueryTree
     void nameAllResultColumns()
 		throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-
-			resultColumn.guaranteeColumnName();
+            rc.guaranteeColumnName();
 		}
 	}
 
@@ -1766,12 +1742,8 @@ class ResultColumnList extends QueryTree
 	boolean columnTypesAndLengthsMatch()
 		throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn resultColumn : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-
 			/* Skip over generated columns */
 			if (resultColumn.isGenerated())
 			{
@@ -1797,9 +1769,9 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
+            ResultColumn resultColumn = elementAt(index);
 
-			ResultColumn otherResultColumn = (ResultColumn) otherRCL.elementAt(index);
+            ResultColumn otherResultColumn = otherRCL.elementAt(index);
 
 			/* Skip over generated columns */
 			if (resultColumn.isGenerated() || otherResultColumn.isGenerated())
@@ -1846,7 +1818,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn thisColumn = (ResultColumn) elementAt(index);
+            ResultColumn thisColumn = elementAt(index);
             ResultColumn referencedColumn;
 
 			/*
@@ -1870,7 +1842,7 @@ class ResultColumnList extends QueryTree
 				return false;
 			}
 
-			ResultColumn childColumn = (ResultColumn) childRCL.elementAt(index);
+            ResultColumn childColumn = childRCL.elementAt(index);
 
 			if (referencedColumn != childColumn)
 			{
@@ -1893,25 +1865,14 @@ class ResultColumnList extends QueryTree
     ResultColumnList copyListAndObjects()
 					throws StandardException
 	{
-		ResultColumn	 newResultColumn;
-		ResultColumn	 origResultColumn;
-		ResultColumnList newList;
-
-		/* Create the new ResultColumnList */
-        newList = new ResultColumnList(getContextManager());
+        ResultColumnList newList = new ResultColumnList(getContextManager());
 
 		/* Walk the current list - for each ResultColumn in the list, make a copy
 		 * and add it to the new list.
 		 */
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn origResultColumn: this)
 		{
-			origResultColumn = (ResultColumn) elementAt(index);
-
-			newResultColumn = origResultColumn.cloneMe();
-
-			newList.addResultColumn(newResultColumn);
+            newList.addResultColumn(origResultColumn.cloneMe());
 		}
         newList.copyOrderBySelect(this);
 		return newList;
@@ -1973,15 +1934,12 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-
-			/* dts = resultColumn.getExpression().getTypeServices(); */
-			DataTypeDescriptor dts = resultColumn.getTypeServices();
+            ResultColumn resultColumn = elementAt(index);
 
 			/* Vectors are 0-based, VirtualColumnIds are 1-based */
             resultColumn.expression = new VirtualColumnNode(
                     sourceResultSet,
-                    (ResultColumn)sourceResultColumnList.elementAt(index),
+                    sourceResultColumnList.elementAt(index),
                     index + 1,
                     getContextManager());
 
@@ -2002,11 +1960,8 @@ class ResultColumnList extends QueryTree
 	 */
     void adjustVirtualColumnIds(int adjust)
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn resultColumn : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
 			resultColumn.adjustVirtualColumnId(adjust);
 			if (SanityManager.DEBUG)
 			{
@@ -2035,12 +1990,10 @@ class ResultColumnList extends QueryTree
     void    doProjection() throws StandardException
 	{
 		int				numDeleted = 0;
-		int size = size();
         ResultColumnList deletedRCL = new ResultColumnList(getContextManager());
-		for (int index = 0; index < size; index++)
-		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
 
+        for (ResultColumn resultColumn : this)
+        {
 			/* RC's for FromBaseTables are marked as referenced during binding.
 			 * For other nodes, namely JoinNodes, we need to go 1 level
 			 * down the RC/VCN chain to see if the RC is referenced.  This is
@@ -2074,7 +2027,7 @@ class ResultColumnList extends QueryTree
 		// Go back and delete the RCs to be delete from the list
 		for (int index = 0; index < deletedRCL.size(); index++)
 		{
-			removeElement((ResultColumn) deletedRCL.elementAt(index));
+            removeElement(deletedRCL.elementAt(index));
 		}
 	}
 
@@ -2088,17 +2041,14 @@ class ResultColumnList extends QueryTree
     String verifyUniqueNames(boolean errForGenCols)
 					throws StandardException
 	{
-		int size = size();
-        HashSet<String> seenNames = new HashSet<String>(size + 2, 0.999f);
-		ResultColumn rc;
+        HashSet<String> seenNames = new HashSet<String>(size() + 2, 0.999f);
 
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			rc = (ResultColumn) elementAt(index);
 			if (errForGenCols && rc.isNameGenerated())
 				throw StandardException.newException(SQLState.LANG_DB2_VIEW_REQUIRES_COLUMN_NAMES);
 			/* Verify that this column's name is unique within the list */
-			String colName = ((ResultColumn) elementAt(index)).getName();
+            String colName = rc.getName();
             boolean alreadySeen = !seenNames.add(colName);
 
 			if (alreadySeen)
@@ -2155,11 +2105,8 @@ class ResultColumnList extends QueryTree
 
 	void rejectParameters() throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
 			rc.rejectParameter();
 		}
 	}
@@ -2234,11 +2181,9 @@ class ResultColumnList extends QueryTree
 	 */
     void setResultSetNumber(int resultSetNumber)
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			((ResultColumn) elementAt(index)).setResultSetNumber(resultSetNumber);
+            rc.setResultSetNumber(resultSetNumber);
 		}
 	}
 
@@ -2249,11 +2194,9 @@ class ResultColumnList extends QueryTree
 	 */
     void setRedundant()
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			((ResultColumn) elementAt(index)).setRedundant();
+            rc.setRedundant();
 		}
 	}
 
@@ -2270,12 +2213,8 @@ class ResultColumnList extends QueryTree
             ExecPreparedStatement cursorStmt, String cursorName)
 			throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn resultColumn : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-
 			if (resultColumn.updated() &&
                     !cursorStmt.isUpdateColumn(resultColumn.getName()))
 			{
@@ -2338,8 +2277,8 @@ class ResultColumnList extends QueryTree
 		for (int index = 0; index < size; index++)
 		{
 			ColumnReference newCR;
-			ResultColumn thisRC = (ResultColumn) elementAt(index);
-			ResultColumn otherRC = (ResultColumn) otherRCL.elementAt(index);
+            ResultColumn thisRC = elementAt(index);
+            ResultColumn otherRC = otherRCL.elementAt(index);
 			ValueNode	 thisExpr = thisRC.getExpression();
 			ValueNode	 otherExpr = otherRC.getExpression();
 
@@ -2482,8 +2421,8 @@ class ResultColumnList extends QueryTree
 		int size = visibleSize();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn thisRC = (ResultColumn) elementAt(index);
-			ResultColumn otherRC = (ResultColumn) otherRCL.elementAt(index);
+            ResultColumn thisRC = elementAt(index);
+            ResultColumn otherRC = otherRCL.elementAt(index);
 
 			if (! thisRC.getTypeServices().isExactTypeAndLengthMatch(
 												otherRC.getTypeServices() ))
@@ -2505,12 +2444,8 @@ class ResultColumnList extends QueryTree
 	 */
 	public	boolean updateOverlaps(int[] columns)
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			if ( ! rc.updated())
 				continue;
 
@@ -2547,7 +2482,7 @@ class ResultColumnList extends QueryTree
 		*/
 		for (int index = 0; index < size; index++)
 		{
-			result[index] = (ResultColumn) elementAt(index);
+            result[index] = elementAt(index);
 		}
 
 		/*
@@ -2668,8 +2603,8 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn	bindingRC = (ResultColumn) bindingRCL.elementAt(index);
-			ResultColumn	thisRC = (ResultColumn) elementAt(index);
+            ResultColumn    bindingRC = bindingRCL.elementAt(index);
+            ResultColumn    thisRC = elementAt(index);
 
 			thisRC.typeUntypedNullExpression(bindingRC);
 		}
@@ -2680,11 +2615,9 @@ class ResultColumnList extends QueryTree
 	 */
 	void markUpdated()
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			((ResultColumn) elementAt(index)).markUpdated();
+            rc.markUpdated();
 		}
 	}
 
@@ -2699,13 +2632,12 @@ class ResultColumnList extends QueryTree
 	 */
 	void markUpdatableByCursor()
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
 			//determine if the column is a base column and not a derived column
-			if (((ResultColumn) elementAt(index)).getSourceTableName() != null)
-				((ResultColumn) elementAt(index)).markUpdatableByCursor();
+            if (rc.getSourceTableName() != null) {
+                rc.markUpdatableByCursor();
+            }
 		}
 	}
 	
@@ -2718,11 +2650,9 @@ class ResultColumnList extends QueryTree
 	 */
     String verifyCreateConstraintColumnList(TableElementList tel)
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			String colName = ((ResultColumn) elementAt(index)).getName();
+            String colName = rc.getName();
 
 			if (! tel.containsColumnName(colName))
 			{
@@ -2756,7 +2686,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			columnNames[index] = ((ResultColumn) elementAt(index)).getName();
+            columnNames[index] = elementAt(index).getName();
 		}
 	}
 
@@ -2772,12 +2702,8 @@ class ResultColumnList extends QueryTree
 	{
 		ResultColumn	parentRC = null;
 
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn	rc =  (ResultColumn) elementAt(index);
-
 			if (rc.getExpression() instanceof ColumnReference)
 			{
 				ColumnReference	cr = (ColumnReference) rc.getExpression();
@@ -2813,16 +2739,9 @@ class ResultColumnList extends QueryTree
 	 */
 	void markUpdated(ResultColumnList updateColumns)
 	{
-		ResultColumn	updateColumn;
-		ResultColumn	resultColumn;
-
-		int size = updateColumns.size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn updateColumn : updateColumns)
 		{
-			updateColumn = (ResultColumn) updateColumns.elementAt(index);
-
-			resultColumn = getResultColumn(updateColumn.getName());
+            ResultColumn resultColumn = getResultColumn(updateColumn.getName());
 
 			/*
 			** This ResultColumnList may not be bound yet - for update
@@ -2940,12 +2859,8 @@ class ResultColumnList extends QueryTree
     boolean isCloneable()
 	{
 		boolean retcode = true;
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn	rc =  (ResultColumn) elementAt(index);
-
 			if (! rc.getExpression().isCloneable())
 			{
 				retcode = false;
@@ -2964,11 +2879,8 @@ class ResultColumnList extends QueryTree
 	 */
     void remapColumnReferencesToExpressions() throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			// The expression may be null if this column is an identity
 			// column generated always. If the expression is not null, it
 			// is a ColumnReference; we call through to the ColumnReference
@@ -3008,10 +2920,8 @@ class ResultColumnList extends QueryTree
 
 		if (SanityManager.DEBUG)
 		{
-		int size = size();
-		for (int index = 0; index < size; index++)
+            for (ResultColumn rc : this)
 			{
-				ResultColumn	rc = (ResultColumn) elementAt(index);
 				ValueNode	 	expr = rc.getExpression();
 				DataTypeDescriptor rcDTS = rc.getTypeServices();
 				DataTypeDescriptor exDTS = expr.getTypeServices();
@@ -3068,10 +2978,8 @@ class ResultColumnList extends QueryTree
 	{
 		int numReferenced = 0;
 
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
 			if (rc.isReferenced())
 			{
 				numReferenced++;
@@ -3092,7 +3000,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 
 			if (rc.isReferenced())
 			{
@@ -3112,7 +3020,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 
 			if ( name.equals( rc.getName() ) )
 			{
@@ -3138,11 +3046,9 @@ class ResultColumnList extends QueryTree
     void recordColumnReferences(boolean[] colArray1, JBitSet[] tableColMap,
 			int tableNumber)
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
 			int columnNumber;
-			ResultColumn rc = (ResultColumn) elementAt(index);
 
 			if (! (rc.getExpression() instanceof ColumnReference))
 			{
@@ -3170,10 +3076,8 @@ class ResultColumnList extends QueryTree
 	{
 		int tableNumber = -1;
 
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
 			ValueNode vn = rc.getExpression();
 			if (! (vn instanceof ColumnReference))
 			{
@@ -3200,11 +3104,8 @@ class ResultColumnList extends QueryTree
 	 */
     void clearColumnReferences()
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			if (rc.isReferenced())
 			{
 				rc.setUnreferenced();
@@ -3219,11 +3120,8 @@ class ResultColumnList extends QueryTree
 	 */
     void copyReferencedColumnsToNewList(ResultColumnList targetList)
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			if (rc.isReferenced())
 			{
 				targetList.addElement(rc);
@@ -3240,10 +3138,8 @@ class ResultColumnList extends QueryTree
     void copyColumnsToNewList(
         ResultColumnList targetList, FormatableBitSet copyList)
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
 			if (copyList.isSet(rc.getColumnPosition())) 
 			{
 				targetList.addElement(rc);
@@ -3263,7 +3159,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 			if (rc.isReferenced())
 			{
 				colMap.set(index);
@@ -3279,20 +3175,16 @@ class ResultColumnList extends QueryTree
      */
     void pullVirtualIsReferenced()
     {
-        int size = size();
-        for( int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
         {
-            ResultColumn rc = (ResultColumn) elementAt(index);
             rc.pullVirtualIsReferenced();
         }
     } // end of pullVirtualIsReferenced
 
     void clearTableNames()
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
 			rc.clearTableName();
 		}
 	}
@@ -3336,10 +3228,10 @@ class ResultColumnList extends QueryTree
     int getTotalColumnSize()
 	{
 		int colSize = 0;
-		int size = size();
-		for (int index = 0; index < size; index++)
+
+        for (ResultColumn rc : this)
 		{
-			colSize += ((ResultColumn) elementAt(index)).getMaximumColumnSize();
+            colSize += rc.getMaximumColumnSize();
 		}
 		return colSize;
 	}
@@ -3501,12 +3393,9 @@ class ResultColumnList extends QueryTree
     void markAllUnreferenced()
 				throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-			resultColumn.setUnreferenced();
+            rc.setUnreferenced();
 		}
 	}
 
@@ -3521,14 +3410,8 @@ class ResultColumnList extends QueryTree
 	 */
 	boolean allExpressionsAreColumns(ResultSetNode sourceRS)
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn	resultColumn;
-			ValueNode		expr;
-
-			resultColumn = (ResultColumn) elementAt(index);
 			//DERBY-4631
 			//Following if condition if true means that the 
 			// ResultColumn is a join column for a RIGHT OUTER
@@ -3539,10 +3422,11 @@ class ResultColumnList extends QueryTree
 			// By returning false here, we allow Derby to generate
 			// code for functionality equivalent to COALESCE to
 			// determine join column's value. 
-			if (resultColumn.isRightOuterJoinUsingClause())
+            if (rc.isRightOuterJoinUsingClause())
 				return false;
 			
-			expr = resultColumn.getExpression();
+            ValueNode expr = rc.getExpression();
+
 			if (! (expr instanceof VirtualColumnNode) &&
 				! (expr instanceof ColumnReference))
 			{
@@ -3604,7 +3488,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			resultColumn = (ResultColumn) elementAt(index);
+            resultColumn = elementAt(index);
 			if (resultColumn.getExpression() instanceof VirtualColumnNode)
 			{
 				VirtualColumnNode vcn = (VirtualColumnNode) resultColumn.getExpression();
@@ -3657,12 +3541,9 @@ class ResultColumnList extends QueryTree
 	 * @throws StandardException */
     void setNullability(boolean nullability) throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
-			resultColumn.setNullability(nullability);
+            rc.setNullability(nullability);
 		}
 	}
 
@@ -3712,7 +3593,7 @@ class ResultColumnList extends QueryTree
 	
 		for (index = 0; index < size; index++)
 		{
-			ResultColumn oldCol = (ResultColumn) elementAt(index);
+            ResultColumn oldCol = elementAt(index);
 			if (oldCol.isReferenced())
 			{
 				/* Skip RCs whose expression is not a BCN
@@ -3778,7 +3659,7 @@ class ResultColumnList extends QueryTree
 		int size = size();
 		for (index = 0; index < size; index++)
 		{
-			ResultColumn oldCol = (ResultColumn) elementAt(index);
+            ResultColumn oldCol = elementAt(index);
 			if (oldCol.isReferenced())
 			{
 				newCols.addResultColumn(oldCol);
@@ -3808,10 +3689,8 @@ class ResultColumnList extends QueryTree
 	 */
 	void removeJoinColumns(ResultColumnList joinColumns)
 	{
-		int jcSize = joinColumns.size();
-		for (int index = 0; index < jcSize; index++)
+        for (ResultColumn joinRC : joinColumns)
 		{
-			ResultColumn joinRC = (ResultColumn) joinColumns.elementAt(index);
 			String columnName = joinRC.getName();
 
 			// columnName should always be non-null
@@ -3848,10 +3727,8 @@ class ResultColumnList extends QueryTree
 		/* Find all of the join columns and put them 1st on the
 		 * new RCL.
 		 */
-		int jcSize = joinColumns.size();
-		for (int index = 0; index < jcSize; index++)
+        for (ResultColumn joinRC : joinColumns)
 		{
-			ResultColumn joinRC = (ResultColumn) joinColumns.elementAt(index);
 			String columnName = joinRC.getName();
 
 			// columnName should always be non-null
@@ -3885,7 +3762,7 @@ class ResultColumnList extends QueryTree
 		for (int index = 0; index < size; index++)
 		{
 			/* ResultColumns are 1-based */
-			((ResultColumn) elementAt(index)).setVirtualColumnId(index + 1);
+            elementAt(index).setVirtualColumnId(index + 1);
 		}
 	}
 
@@ -3899,12 +3776,8 @@ class ResultColumnList extends QueryTree
 	 */
 	boolean reusableResult()
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			if ((rc.getExpression() instanceof ConstantNode) ||
 				(rc.getExpression() instanceof AggregateNode))
 			{
@@ -3934,7 +3807,7 @@ class ResultColumnList extends QueryTree
 
 		for ( int index = 0; index < size; index++ )
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt( index );
+            ResultColumn resultColumn = elementAt( index );
 			columnName = resultColumn.getName();
 			cd = td.getColumnDescriptor( columnName );
 
@@ -3964,7 +3837,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn resultColumn = (ResultColumn) elementAt(index);
+            ResultColumn resultColumn = elementAt(index);
 			strings[index] = resultColumn.getName();
 		}
 		return strings;
@@ -3989,7 +3862,7 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 
 			if (rc.isDefaultColumn())
 			{
@@ -4007,7 +3880,7 @@ class ResultColumnList extends QueryTree
 				}
 				else if (index < tcl.size())
 				{
-					ResultColumn trc = (ResultColumn) tcl.elementAt(index);
+                    ResultColumn trc = tcl.elementAt(index);
 					cd = ttd.getColumnDescriptor(trc.getName());
 				}
 
@@ -4069,12 +3942,8 @@ class ResultColumnList extends QueryTree
 	void checkForInvalidDefaults()
 		throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
-
 			if (rc.isAutoincrementGenerated())
 				continue;
 
@@ -4093,11 +3962,8 @@ class ResultColumnList extends QueryTree
 	void verifyAllOrderable() 
 		throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : this)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
 			rc.verifyOrderable();
 		}
 	}
@@ -4175,9 +4041,9 @@ class ResultColumnList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			ResultColumn rc = (ResultColumn) elementAt(index);
+            ResultColumn rc = elementAt(index);
 			ResultColumn sourceRC = 
-				(ResultColumn)((sourceRSRCL == null) ? null : sourceRSRCL.elementAt(index));
+                (sourceRSRCL == null) ? null : sourceRSRCL.elementAt(index);
 			ColumnDescriptor cd = rc.getTableColumnDescriptor();
 
             if ( (cd != null) && cd.hasGenerationClause() )
@@ -4244,7 +4110,7 @@ class ResultColumnList extends QueryTree
 		boolean inVisibleRange = false;
 		for (int i = sz - 1; i >= 0; i--) 
 		{
-			ResultColumn rc = (ResultColumn) elementAt(i);
+            ResultColumn rc = elementAt(i);
 			if (rc.isGenerated()) 
 			{
 				if (SanityManager.DEBUG) {
@@ -4269,7 +4135,7 @@ class ResultColumnList extends QueryTree
 		int numGenerated = 0;
 		int sz = size();
 		for (int i = sz - 1; i >= 0; i--) {
-			ResultColumn rc = (ResultColumn) elementAt(i);
+            ResultColumn rc = elementAt(i);
 			if (rc.isGenerated() && rc.isGroupingColumn())
 			{
 				numGenerated++;
@@ -4286,7 +4152,7 @@ class ResultColumnList extends QueryTree
 		int sz = size();
 		for (int i = sz - 1; i >= 0; i--) 
 		{
-			ResultColumn rc = (ResultColumn) elementAt(i);
+            ResultColumn rc = elementAt(i);
 			if (rc.isGenerated() && rc.isGroupingColumn()) 
 			{
 				removeElementAt(i);

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -32,7 +32,6 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
 import org.apache.derby.iapi.sql.ResultDescription;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.OptimizableList;
@@ -114,7 +113,7 @@ public abstract class ResultSetNode exte
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
+    @Override
     void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
@@ -299,10 +298,11 @@ public abstract class ResultSetNode exte
         // sub-class. For all other nodes, just go through the result columns
         // and set the type for dynamic parameters.
         for (int i = 0; i < resultColumns.size(); i++) {
-            ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
+            ResultColumn rc = resultColumns.elementAt(i);
             ValueNode re = rc.getExpression();
+
             if (re != null && re.requiresTypeFromContext()) {
-                ResultColumn typeCol = (ResultColumn) typeColumns.elementAt(i);
+                ResultColumn typeCol = typeColumns.elementAt(i);
                 re.setType(typeCol.getTypeServices());
             }
         }
@@ -413,7 +413,7 @@ public abstract class ResultSetNode exte
 		}
 		else
 		{
-			resultColumn = (ResultColumn) resultColumns.elementAt(0);
+            resultColumn = resultColumns.elementAt(0);
 	
 			/* Nothing to do if query is already select TRUE ... */
             if (resultColumn.getExpression().isBooleanTrue() &&
@@ -859,7 +859,7 @@ public abstract class ResultSetNode exte
 	{
 		for (int i=0; i<resultColumns.size(); i++)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
+            ResultColumn rc = resultColumns.elementAt(i);
 			if (rc.isNameGenerated())
 				rc.setName(Integer.toString(i+1));
 		}
@@ -1212,9 +1212,8 @@ public abstract class ResultSetNode exte
 			}
 		}
 
-		defaultTree = ((ResultColumn) 
-							((CursorNode) qt).getResultSetNode().getResultColumns().elementAt(0)).
-									getExpression();
+        defaultTree = ((CursorNode) qt).getResultSetNode().getResultColumns().
+                elementAt(0).getExpression();
 
 		lcc.popCompilerContext(newCC);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RevokeRoleNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RevokeRoleNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RevokeRoleNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RevokeRoleNode.java Fri Jun 28 04:32:08 2013
@@ -78,7 +78,8 @@ class RevokeRoleNode extends DDLStatemen
 	{
 		if (SanityManager.DEBUG) {
             StringBuilder sb1 = new StringBuilder();
-			for( Iterator it = roles.iterator(); it.hasNext();) {
+
+            for( Iterator<?> it = roles.iterator(); it.hasNext();) {
 				if( sb1.length() > 0) {
 					sb1.append( ", ");
 				}
@@ -86,13 +87,15 @@ class RevokeRoleNode extends DDLStatemen
 			}
 
             StringBuilder sb2 = new StringBuilder();
-			for( Iterator it = grantees.iterator(); it.hasNext();) {
+
+            for( Iterator<?> it = grantees.iterator(); it.hasNext();) {
 				if( sb2.length() > 0) {
 					sb2.append( ", ");
 				}
 				sb2.append( it.next().toString());
 			}
-			return (super.toString() +
+
+            return (super.toString() +
 					sb1.toString() +
 					" FROM: " +
 					sb2.toString() +

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowOrderingImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowOrderingImpl.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowOrderingImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowOrderingImpl.java Fri Jun 28 04:32:08 2013
@@ -23,6 +23,7 @@ package org.apache.derby.impl.sql.compil
 
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.ListIterator;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.compile.Optimizable;
@@ -299,12 +300,13 @@ class RowOrderingImpl implements RowOrde
 	 * Remove all optimizables with the given table number from the
      * given list of optimizables.
 	 */
-    private void removeOptimizable(int tableNumber, ArrayList list)
+    private void removeOptimizable(int tableNumber, ArrayList<Optimizable> list)
 	{
-        Iterator it = list.iterator();
+        ListIterator<Optimizable> it = list.listIterator();
+
         while (it.hasNext())
 		{
-            Optimizable optTable = (Optimizable) it.next();
+            Optimizable optTable = it.next();
 
             if (optTable.hasTableNumber()
                     && (optTable.getTableNumber() == tableNumber)) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java Fri Jun 28 04:32:08 2013
@@ -727,15 +727,12 @@ class RowResultSetNode extends FromTable
 		int rclSize = resultColumns.size();
 		for (int index = 0; index < rclSize; index++)
 		{
-			ResultColumn	rc = (ResultColumn) resultColumns.elementAt(index);
-
+            ResultColumn rc = resultColumns.elementAt(index);
 			ValueNode re = rc.getExpression();
 
 			if (re.requiresTypeFromContext())
 			{
-				ResultColumn	typeCol =
-					(ResultColumn) typeColumns.elementAt(index);
-
+                ResultColumn typeCol = typeColumns.elementAt(index);
 				/*
 				** We found a ? - set its type to the type of the
 				** corresponding column of the target table.
@@ -780,8 +777,7 @@ class RowResultSetNode extends FromTable
 				// still a normailzation step when the value is inserted into the table.
 				// That will set the correct length and perform truncation checks etc.
 
-				ResultColumn	typeCol =
-					(ResultColumn) typeColumns.elementAt(index);
+                ResultColumn typeCol = typeColumns.elementAt(index);
 
 				TypeId colTypeId = typeCol.getTypeId();
 
@@ -817,10 +813,8 @@ class RowResultSetNode extends FromTable
 			}
 			else if (re instanceof BitConstantNode)
 			{
-				ResultColumn	typeCol =
-					(ResultColumn) typeColumns.elementAt(index);
-
-				TypeId colTypeId = typeCol.getTypeId();
+                ResultColumn typeCol   = typeColumns.elementAt(index);
+                TypeId       colTypeId = typeCol.getTypeId();
 
 				if (colTypeId.isBitTypeId()) {
 

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -409,10 +409,8 @@ class SelectNode extends ResultSetNode
 			return null;
 
 		// Loop through the result columns looking for a match
-		int rclSize = resultColumns.size();
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : resultColumns)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
 			if (! (rc.getExpression() instanceof ColumnReference))
 				return null;
 
@@ -878,9 +876,8 @@ class SelectNode extends ResultSetNode
     void verifySelectStarSubquery(FromList outerFromList, int subqueryType)
 					throws StandardException
 	{
-        for (int i = 0; i < resultColumns.size(); i++) {
-            if (!((ResultColumn)resultColumns.elementAt(i)
-                     instanceof AllResultColumn) ) {
+        for (ResultColumn rc : resultColumns) {
+            if (!(rc instanceof AllResultColumn)) {
                 continue;
             }
 
@@ -896,9 +893,7 @@ class SelectNode extends ResultSetNode
              * the qualification is a valid exposed name.  NOTE: The exposed
              * name can come from an outer query block.
              */
-            String fullTableName =
-                ((AllResultColumn)resultColumns.elementAt(i)).
-                getFullTableName();
+            String fullTableName = ((AllResultColumn)rc).getFullTableName();
 
             if (fullTableName != null) {
                 if (fromList.getFromTableByName
@@ -971,7 +966,7 @@ class SelectNode extends ResultSetNode
             if (SanityManager.DEBUG) {
                 SanityManager.ASSERT(
                     orderByList.size() == resultColumns.visibleSize());
-                OrderByColumn obc = (OrderByColumn)orderByList.elementAt(0);
+                OrderByColumn obc = orderByList.elementAt(0);
                 SanityManager.ASSERT(
                     obc.getExpression() instanceof NumericConstantNode);
                 try {
@@ -1527,7 +1522,7 @@ class SelectNode extends ResultSetNode
 		ResultSetNode		prnRSN;
 
         prnRSN = new ProjectRestrictNode(
-                (ResultSetNode)fromList.elementAt(0),   /* Child ResultSet */
+                fromList.elementAt(0),   /* Child ResultSet */
                 resultColumns,      /* Projection */
                 whereClause,            /* Restriction */
                 wherePredicates,/* Restriction as PredicateList */
@@ -1582,8 +1577,7 @@ class SelectNode extends ResultSetNode
 					SQLState.LANG_WINDOW_LIMIT_EXCEEDED);
 			}
 
-            WindowDefinitionNode wn =
-                    (WindowDefinitionNode)windows.elementAt(0);
+            WindowDefinitionNode wn = windows.elementAt(0);
 
             WindowResultSetNode wrsn = new WindowResultSetNode(
 					prnRSN,
@@ -1815,15 +1809,12 @@ class SelectNode extends ResultSetNode
 										  boolean permuteOrdering)
 		throws StandardException
 	{
-		int rclSize = resultColumns.size();
-
 		/* Not ordered if RCL contains anything other than a ColumnReference
 		 * or a ConstantNode.
 		 */
 		int numCRs = 0;
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : resultColumns)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
 			if (rc.getExpression() instanceof ColumnReference)
 			{
 				numCRs++;
@@ -1844,9 +1835,8 @@ class SelectNode extends ResultSetNode
 
 		// Now populate the CR array and see if ordered
 		int crsIndex = 0;
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : resultColumns)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
 			if (rc.getExpression() instanceof ColumnReference)
 			{
 				crs[crsIndex++] = (ColumnReference) rc.getExpression();
@@ -1923,8 +1913,10 @@ class SelectNode extends ResultSetNode
 			// Iterate backwards because we might be deleting entries.
 			for (int i = wherePredicates.size() - 1; i >= 0; i--)
 			{
-				if (((Predicate)wherePredicates.elementAt(i)).isScopedForPush())
+                if (wherePredicates.elementAt(i).isScopedForPush())
+                {
 					wherePredicates.removeOptPredicate(i);
+                }
 			}
 		}
 
@@ -2160,7 +2152,7 @@ class SelectNode extends ResultSetNode
 			 * and create new VirtualColumnNodes for the original's 
 			 * ResultColumn.expressions.
 			 */
-			leftResultSet = (ResultSetNode) fromList.elementAt(0);
+            leftResultSet = fromList.elementAt(0);
 			leftRCList = leftResultSet.getResultColumns();
 			leftResultSet.setResultColumns(leftRCList.copyListAndObjects());
 			leftRCList.genVirtualColumnNodes(leftResultSet, leftResultSet.resultColumns);
@@ -2170,7 +2162,7 @@ class SelectNode extends ResultSetNode
 			 * ResultColumn.expressions and increment the virtualColumnIds.
 			 * (Right gets appended to left, so only right's ids need updating.)
 			 */
-			rightResultSet = (ResultSetNode) fromList.elementAt(1);
+            rightResultSet = fromList.elementAt(1);
 			rightRCList = rightResultSet.getResultColumns();
 			rightResultSet.setResultColumns(rightRCList.copyListAndObjects());
 			rightRCList.genVirtualColumnNodes(rightResultSet, rightResultSet.resultColumns);
@@ -2425,7 +2417,7 @@ class SelectNode extends ResultSetNode
 		throws StandardException
 	{
 		ColumnReference additionalCR = null;
-		ResultColumn	rc = (ResultColumn) getResultColumns().elementAt(0);
+        ResultColumn rc = getResultColumns().elementAt(0);
 
 		/* Figure out if we have an additional ColumnReference
 		 * in an equality comparison.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java Fri Jun 28 04:32:08 2013
@@ -730,8 +730,7 @@ abstract class SetOperatorNode extends T
 		{
 			if (types[i] == null)
 			{
-				ResultColumn rc =
-					(ResultColumn) rrsn.getResultColumns().elementAt(i);
+                ResultColumn rc = rrsn.getResultColumns().elementAt(i);
 				if ( ! (rc.getExpression().requiresTypeFromContext()))
 				{
 					types[i] = rc.getExpression().getTypeServices();
@@ -763,9 +762,10 @@ abstract class SetOperatorNode extends T
 		*/
 		ResultColumnList rrcl = rrsn.getResultColumns();
 		int rrclSize = rrcl.size();
+
 		for (int index = 0; index < rrclSize; index++)
 		{
-			ResultColumn	rc = (ResultColumn) rrcl.elementAt(index);
+            ResultColumn rc = rrcl.elementAt(index);
 
 			if (rc.getExpression().requiresTypeFromContext())
 			{
@@ -825,7 +825,7 @@ abstract class SetOperatorNode extends T
             if (SanityManager.DEBUG) {
                 SanityManager.ASSERT(
                     orderByList.size() == resultColumns.visibleSize());
-                OrderByColumn obc = (OrderByColumn)orderByList.elementAt(0);
+                OrderByColumn obc = orderByList.elementAt(0);
                 SanityManager.ASSERT(
                     obc.getExpression() instanceof NumericConstantNode);
                 try {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java Fri Jun 28 04:32:08 2013
@@ -21,6 +21,7 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.sql.ParameterMetaData;
 import java.util.List;
@@ -1374,9 +1375,13 @@ class StaticMethodCallNode extends Metho
 
 						// is the underlying type for the OUT/INOUT parameter primitive.
                         // if this is a varargs arg then we have to strip off another array level
-                        Class   cellType = ((java.lang.reflect.Method) method).getParameterTypes()[ getRoutineArgIdx( i ) ].
-                            getComponentType();
-                        if ( isVararg( i ) ) { cellType = cellType.getComponentType(); }
+                        Class<?> cellType = ((Method) method).
+                                getParameterTypes()[ getRoutineArgIdx( i ) ].
+                                getComponentType();
+
+                        if ( isVararg( i ) ) {
+                            cellType = cellType.getComponentType();
+                        }
 						boolean isPrimitive = cellType.isPrimitive();
 
 						if (isNumericType) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java Fri Jun 28 04:32:08 2013
@@ -32,10 +32,10 @@ import org.apache.derby.iapi.sql.diction
  *
  */
 
-class SubqueryList extends QueryTreeNodeVector
+class SubqueryList extends QueryTreeNodeVector<SubqueryNode>
 {
     SubqueryList(ContextManager cm) {
-        super(cm);
+        super(SubqueryNode.class, cm);
         setNodeType(C_NodeTypes.SUBQUERY_LIST);
     }
 
@@ -68,13 +68,9 @@ class SubqueryList extends QueryTreeNode
 							PredicateList outerPredicateList) 
 				throws StandardException
 	{
-		SubqueryNode	subqueryNode;
-
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			subqueryNode = (SubqueryNode) elementAt(index);
-			subqueryNode.preprocess(numTables, outerFromList,
+            sqn.preprocess(numTables, outerFromList,
 									outerSubqueryList,
 									outerPredicateList);
 		}
@@ -93,12 +89,9 @@ class SubqueryList extends QueryTreeNode
     void optimize(DataDictionary dataDictionary, double outerRows)
 			throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			SubqueryNode	subqueryNode;
-			subqueryNode = (SubqueryNode) elementAt(index);
-			subqueryNode.optimize(dataDictionary, outerRows);
+            sqn.optimize(dataDictionary, outerRows);
 		}
 	}
 
@@ -112,12 +105,9 @@ class SubqueryList extends QueryTreeNode
     void modifyAccessPaths()
 			throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			SubqueryNode	subqueryNode;
-			subqueryNode = (SubqueryNode) elementAt(index);
-			subqueryNode.modifyAccessPaths();
+            sqn.modifyAccessPaths();
 		}
 	}
 
@@ -134,18 +124,14 @@ class SubqueryList extends QueryTreeNode
     boolean referencesTarget(String name, boolean baseTable)
 		throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			SubqueryNode	subqueryNode;
-
-			subqueryNode = (SubqueryNode) elementAt(index);
-			if (subqueryNode.isMaterializable())
+            if (sqn.isMaterializable())
 			{
 				continue;
 			}
 
-			if (subqueryNode.getResultSet().referencesTarget(name, baseTable))
+            if (sqn.getResultSet().referencesTarget(name, baseTable))
 			{
 				return true;
 			}
@@ -165,14 +151,9 @@ class SubqueryList extends QueryTreeNode
 	public boolean referencesSessionSchema()
 		throws StandardException
 	{
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			SubqueryNode	subqueryNode;
-
-			subqueryNode = (SubqueryNode) elementAt(index);
-
-			if (subqueryNode.getResultSet().referencesSessionSchema())
+            if (sqn.getResultSet().referencesSessionSchema())
 			{
 				return true;
 			}
@@ -191,14 +172,9 @@ class SubqueryList extends QueryTreeNode
     void setPointOfAttachment(int pointOfAttachment)
 		throws StandardException
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			SubqueryNode	subqueryNode;
-
-			subqueryNode = (SubqueryNode) elementAt(index);
-			subqueryNode.setPointOfAttachment(pointOfAttachment);
+            sqn.setPointOfAttachment(pointOfAttachment);
 		}
 	}
 
@@ -211,29 +187,22 @@ class SubqueryList extends QueryTreeNode
 	 */
 	void decrementLevel(int decrement)
 	{
-		int size = size();
-
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			((SubqueryNode) elementAt(index)).getResultSet().decrementLevel(decrement);
+            sqn.getResultSet().decrementLevel(decrement);
 		}
 	}
 
 	/**
      * Mark all of the subqueries in this 
      * list as being part of a having clause,
-     * so we can avoid flattenning later.
+     * so we can avoid flattening later.
 	 * 
 	 */
     void markHavingSubqueries() {
-	    int size = size();
-	    
-	    for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 	    {
-	        SubqueryNode    subqueryNode;
-
-	        subqueryNode = (SubqueryNode) elementAt(index);
-	        subqueryNode.setHavingSubquery(true);
+            sqn.setHavingSubquery(true);
 	    }
 	}
 
@@ -242,13 +211,9 @@ class SubqueryList extends QueryTreeNode
 	 * so we can avoid flattening later if needed.
 	 */
     void markWhereSubqueries() {
-		int size = size();
-		for (int index = 0; index < size; index++)
+        for (SubqueryNode sqn : this)
 		{
-			SubqueryNode    subqueryNode;
-
-			subqueryNode = (SubqueryNode) elementAt(index);
-			subqueryNode.setWhereSubquery(true);
+            sqn.setWhereSubquery(true);
 		}
 	}
 }

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -572,8 +572,7 @@ class SubqueryNode extends ValueNode
 		 */
 		if (leftOperand != null && leftOperand.requiresTypeFromContext())
 		{
-			leftOperand.setType(
-				((ResultColumn) resultColumns.elementAt(0)).getTypeServices());
+            leftOperand.setType(resultColumns.elementAt(0).getTypeServices());
 		}
 
 		// Set the DataTypeServices
@@ -1194,8 +1193,7 @@ class SubqueryNode extends ValueNode
      * @return the right operand
      */
     private ValueNode getRightOperand() {
-        ResultColumn firstRC =
-                (ResultColumn) resultSet.getResultColumns().elementAt(0);
+        ResultColumn firstRC = resultSet.getResultColumns().elementAt(0);
         return firstRC.getExpression();
     }
 
@@ -1360,7 +1358,7 @@ class SubqueryNode extends ValueNode
                                         cm);
 		resultColumns = newRCL;
 	
-		firstRC = (ResultColumn) resultColumns.elementAt(0);
+        firstRC = resultColumns.elementAt(0);
 		rightOperand = firstRC.getExpression();
 
         BinaryComparisonOperatorNode bcoNode =
@@ -2399,7 +2397,7 @@ class SubqueryNode extends ValueNode
 		 */
 		if (subqueryType == EXPRESSION_SUBQUERY)
 		{
-			dts = ((ResultColumn) resultColumns.elementAt(0)).getTypeServices();
+            dts = resultColumns.elementAt(0).getTypeServices();
 		}
 		else
 		{

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=1497644&r1=1497643&r2=1497644&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 Fri Jun 28 04:32:08 2013
@@ -33,10 +33,10 @@ class SubstituteExpressionVisitor implem
 {
 	private ValueNode source;
 	private ValueNode target;
-	private Class     skipOverClass;
+    private Class<?>  skipOverClass;
 	
 	SubstituteExpressionVisitor(
-			ValueNode s, ValueNode t, Class skipThisClass)  
+            ValueNode s, ValueNode t, Class<?> skipThisClass)
 	{
 		source = s;
 		target = t;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java Fri Jun 28 04:32:08 2013
@@ -61,13 +61,13 @@ import org.apache.derby.impl.sql.execute
  *
  */
 
-class TableElementList extends QueryTreeNodeVector
+class TableElementList extends QueryTreeNodeVector<TableElementNode>
 {
 	private int				numColumns;
 	private TableDescriptor td;
 
     public TableElementList(ContextManager cm) {
-        super(cm);
+        super(TableElementNode.class, cm);
         setNodeType(C_NodeTypes.TABLE_ELEMENT_LIST);
     }
 
@@ -95,17 +95,12 @@ class TableElementList extends QueryTree
 	void setCollationTypesOnCharacterStringColumns(SchemaDescriptor sd)
         throws StandardException
     {
-		int			size = size();
-
-        for (int index = 0; index < size; index++)
+        for (TableElementNode te : this)
 		{
-			TableElementNode tableElement = (TableElementNode) elementAt(index);
-
-			if (tableElement instanceof ColumnDefinitionNode)
+            if (te instanceof ColumnDefinitionNode)
 			{
-				ColumnDefinitionNode cdn = (ColumnDefinitionNode) elementAt(index);
-
-                setCollationTypeOnCharacterStringColumn( sd, cdn );
+                setCollationTypeOnCharacterStringColumn(
+                        sd, (ColumnDefinitionNode)te );
 			}
 		}
 	}
@@ -192,13 +187,11 @@ class TableElementList extends QueryTree
 		if (ddlStmt instanceof CreateTableNode)
 			tableType = ((CreateTableNode)ddlStmt).tableType;
 
-		for (int index = 0; index < size; index++)
+        for (TableElementNode tableElement : this)
 		{
-			TableElementNode tableElement = (TableElementNode) elementAt(index);
-
 			if (tableElement instanceof ColumnDefinitionNode)
 			{
-				ColumnDefinitionNode cdn = (ColumnDefinitionNode) elementAt(index);
+                ColumnDefinitionNode cdn = (ColumnDefinitionNode)tableElement;
 				if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE &&
 					(cdn.getType().getTypeId().isLongConcatableTypeId() ||
 					cdn.getType().getTypeId().isUserDefinedTypeId()))
@@ -358,11 +351,8 @@ class TableElementList extends QueryTree
     public  void    validatePrimaryKeyNullability()
         throws StandardException
     {
-		int			size = size();
-		for (int index = 0; index < size; index++)
+        for (TableElementNode tableElement : this)
 		{
-			TableElementNode tableElement = (TableElementNode) elementAt(index);
-
 			if (! (tableElement.hasConstraint()))
 			{
 				continue;
@@ -396,24 +386,14 @@ class TableElementList extends QueryTree
     int countConstraints(int constraintType)
 	{
 		int	numConstraints = 0;
-		int size = size();
 
-		for (int index = 0; index < size; index++)
+        for (TableElementNode element : this)
 		{
-			ConstraintDefinitionNode cdn;
-			TableElementNode element = (TableElementNode) elementAt(index);
-
-			if (! (element instanceof ConstraintDefinitionNode))
-			{
-				continue;
-			}
-
-			cdn = (ConstraintDefinitionNode) element;
-
-			if (constraintType == cdn.getConstraintType())
-			{
-				numConstraints++;
-			}
+            if (element instanceof ConstraintDefinitionNode &&
+                ((ConstraintDefinitionNode)element).getConstraintType() ==
+                    constraintType) {
+                numConstraints++;
+            }
 		}
 
 		return numConstraints;
@@ -425,24 +405,13 @@ class TableElementList extends QueryTree
     int countGenerationClauses()
 	{
 		int	numGenerationClauses = 0;
-		int size = size();
 
-		for (int index = 0; index < size; index++)
+        for (TableElementNode element : this)
 		{
-			ColumnDefinitionNode cdn;
-			TableElementNode element = (TableElementNode) elementAt(index);
-
-			if (! (element instanceof ColumnDefinitionNode))
-			{
-				continue;
-			}
-
-			cdn = (ColumnDefinitionNode) element;
-
-			if ( cdn.hasGenerationClause() )
-			{
-				numGenerationClauses++;
-			}
+            if (element instanceof ColumnDefinitionNode &&
+                    ((ColumnDefinitionNode)element).hasGenerationClause()) {
+                numGenerationClauses++;
+            }
 		}
 
 		return numGenerationClauses;
@@ -473,9 +442,9 @@ class TableElementList extends QueryTree
 
 		for (int index = 0; index < size; index++)
 		{
-			if (((TableElementNode) elementAt(index)).getElementType() == TableElementNode.AT_DROP_COLUMN)
+            if (elementAt(index).getElementType() == TableElementNode.AT_DROP_COLUMN)
 			{
-                String columnName = ((TableElementNode) elementAt(index)).getName();
+                String columnName = elementAt(index).getName();
 
 				colInfos[index] = new ColumnInfo(
 								columnName,
@@ -590,18 +559,14 @@ class TableElementList extends QueryTree
 	void bindAndValidateCheckConstraints(FromList fromList)
 		throws StandardException
 	{
-		CompilerContext cc;
-		FromBaseTable				table = (FromBaseTable) fromList.elementAt(0);
-		int						  size = size();
-
-		cc = getCompilerContext();
+        FromBaseTable table = (FromBaseTable) fromList.elementAt(0);
+        CompilerContext cc = getCompilerContext();
 
         ArrayList<AggregateNode> aggregates = new ArrayList<AggregateNode>();
 
-		for (int index = 0; index < size; index++)
+        for (TableElementNode element : this)
 		{
 			ConstraintDefinitionNode cdn;
-			TableElementNode element = (TableElementNode) elementAt(index);
 			ValueNode	checkTree;
 
 			if (! (element instanceof ConstraintDefinitionNode))
@@ -679,9 +644,9 @@ class TableElementList extends QueryTree
 			 */
 			if (cdn.getColumnList() != null)
 			{
-				String colName = ((ResultColumn)(cdn.getColumnList().elementAt(0))).getName();
+                String colName = cdn.getColumnList().elementAt(0).getName();
 				if (numReferenced > 1 ||
-					!colName.equals(((ResultColumn)(refRCL.elementAt(0))).getName()))
+                    !colName.equals(refRCL.elementAt(0).getName()))
 					throw StandardException.newException(SQLState.LANG_DB2_INVALID_CHECK_CONSTRAINT, colName);
 				
 			}
@@ -708,25 +673,22 @@ class TableElementList extends QueryTree
 	void bindAndValidateGenerationClauses( SchemaDescriptor sd, FromList fromList, FormatableBitSet generatedColumns, TableDescriptor baseTable )
 		throws StandardException
 	{
-		CompilerContext cc;
-		FromBaseTable				table = (FromBaseTable) fromList.elementAt(0);
-        ResultColumnList            tableColumns = table.getResultColumns();
-        int                                 columnCount = table.getResultColumns().size();
-		int						  size = size();
+        FromBaseTable    table = (FromBaseTable) fromList.elementAt(0);
+        ResultColumnList tableColumns = table.getResultColumns();
+        int              columnCount = table.getResultColumns().size();
 
         // complain if a generation clause references another generated column
         findIllegalGenerationReferences( fromList, baseTable );
 
         generatedColumns.grow( columnCount + 1 );
         
-		cc = getCompilerContext();
+        CompilerContext cc = getCompilerContext();
 
         ArrayList<AggregateNode> aggregates = new ArrayList<AggregateNode>();
 
-		for (int index = 0; index < size; index++)
+        for (TableElementNode element : this)
 		{
 			ColumnDefinitionNode cdn;
-			TableElementNode element = (TableElementNode) elementAt(index);
             GenerationClauseNode    generationClauseNode;
 			ValueNode	generationTree;
 
@@ -842,7 +804,9 @@ class TableElementList extends QueryTree
 
             for ( int i = 0; i < numReferenced; i++ )
             {
-                referencedColumnNames[ i ] = ((ResultColumn)rcl.elementAt( generationClauseColumnReferences[ i ] - 1 )).getName();
+                referencedColumnNames[i] =
+                    rcl.elementAt(generationClauseColumnReferences[i] - 1).
+                        getName();
             }
 
             String              currentSchemaName = getLanguageConnectionContext().getCurrentSchemaName();
@@ -872,7 +836,6 @@ class TableElementList extends QueryTree
 	{
         ArrayList<ColumnDefinitionNode>   generatedColumns = new ArrayList<ColumnDefinitionNode>();
         HashSet<String>     names = new HashSet<String>();
-		int         size = size();
 
         // add in existing generated columns if this is an ALTER TABLE statement
         if ( baseTable != null )
@@ -886,10 +849,9 @@ class TableElementList extends QueryTree
         }
         
         // find all of the generated columns
-		for (int index = 0; index < size; index++)
+        for (TableElementNode element : this)
 		{
 			ColumnDefinitionNode cdn;
-			TableElementNode     element = (TableElementNode) elementAt(index);
 
 			if (! (element instanceof ColumnDefinitionNode)) { continue; }
 
@@ -946,14 +908,11 @@ class TableElementList extends QueryTree
         
 		FromBaseTable				table = (FromBaseTable) fromList.elementAt(0);
         ResultColumnList        tableColumns = table.getResultColumns();
-		int						  size = size();
 
         // loop through the foreign keys, looking for keys which violate the
         // rulse we're enforcing
-		for (int index = 0; index < size; index++)
+        for (TableElementNode element : this)
 		{
-			TableElementNode element = (TableElementNode) elementAt(index);
-
 			if (! (element instanceof FKConstraintDefinitionNode))
 			{
 				continue;
@@ -988,14 +947,10 @@ class TableElementList extends QueryTree
             // SET DEFAULT or whose update rule is ON UPDATE CASCADE.
             // See if any of the key columns are generated columns.
             //
-            ResultColumnList                keyCols = fk.getColumnList();
-            int                                     keyCount = keyCols.size();
-
-            for ( int i = 0; i < keyCount; i++ )
+            for (ResultColumn keyCol : fk.getColumnList())
             {
-                ResultColumn    keyCol = (ResultColumn) keyCols.elementAt( i );
-                String                  keyColName = keyCol.getName();
-                int     position = tableColumns.getPosition( keyColName, 1 );
+                String keyColName = keyCol.getName();
+                int position = tableColumns.getPosition( keyColName, 1 );
 
                 if ( generatedColumns.isSet(  position ) )
                 {
@@ -1024,20 +979,15 @@ class TableElementList extends QueryTree
 				DataDictionary dd)
 		throws StandardException
 	{
-		int size = size();
 		int conActionIndex = 0;
-		for (int index = 0; index < size; index++)
+
+        for (TableElementNode ten : this)
 		{
 			String[]	columnNames = null;
-			TableElementNode ten = (TableElementNode) elementAt(index);
 			IndexConstantAction indexAction = null;
 
-			if (! ten.hasConstraint())
-			{
-				continue;
-			}
-
-			if (ten instanceof ColumnDefinitionNode)
+            if (! ten.hasConstraint() ||
+                ten instanceof ColumnDefinitionNode)
 			{
 				continue;
 			}
@@ -1314,11 +1264,12 @@ class TableElementList extends QueryTree
             // is set for the whole database or just set on this statement.
             return result;
         }
-        ResultColumnList rcl = cdn.getColumnList();
+
         int approxLength = 0;
-        for (int index = 0; index < rcl.size(); index++)
+
+        for (ResultColumn rc : cdn.getColumnList())
         {
-            String colName = ((ResultColumn) rcl.elementAt(index)).getName();
+            String colName = rc.getName();
             DataTypeDescriptor dtd;
             if (td == null)
                 dtd = getColumnDataTypeDescriptor(colName);
@@ -1447,13 +1398,9 @@ class TableElementList extends QueryTree
 	 */
 	private void setColumnListToNotNull(ConstraintDefinitionNode cdn)
 	{
-		ResultColumnList rcl = cdn.getColumnList();
-		int rclSize = rcl.size();
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : cdn.getColumnList())
 		{
-			String colName = ((ResultColumn) rcl.elementAt(index)).getName();
-            
-            findColumnDefinition(colName).setNullability(false);
+            findColumnDefinition(rc.getName()).setNullability(false);
         }
 	}
 
@@ -1469,20 +1416,14 @@ class TableElementList extends QueryTree
     ConstraintDefinitionNode    cdn, 
     TableDescriptor             td) 
     {
-        ResultColumnList rcl = cdn.getColumnList();
-        int rclSize = rcl.size();
-        for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : cdn.getColumnList())
         {
-            String colName = ((ResultColumn) rcl.elementAt(index)).getName();
-            DataTypeDescriptor dtd;
-            if (td == null)
-            {
-                dtd = getColumnDataTypeDescriptor(colName);
-            }
-            else
-            {
-                dtd = getColumnDataTypeDescriptor(colName, td);
-            }
+            String colName = rc.getName();
+
+            DataTypeDescriptor dtd = (td == null) ?
+                getColumnDataTypeDescriptor(colName) :
+                getColumnDataTypeDescriptor(colName, td);
+
             // todo dtd may be null if the column does not exist, we should check that first
             if (dtd != null && dtd.isNullable())
             {
@@ -1494,20 +1435,12 @@ class TableElementList extends QueryTree
 
     private void checkForNullColumns(ConstraintDefinitionNode cdn, TableDescriptor td) throws StandardException
     {
-        ResultColumnList rcl = cdn.getColumnList();
-        int rclSize = rcl.size();
-        for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : cdn.getColumnList())
         {
-            String colName = ((ResultColumn) rcl.elementAt(index)).getName();
-            DataTypeDescriptor dtd;
-            if (td == null)
-            {
-                dtd = getColumnDataTypeDescriptor(colName);
-            }
-            else
-            {
-                dtd = getColumnDataTypeDescriptor(colName, td);
-            }
+            DataTypeDescriptor dtd = (td == null) ?
+                    getColumnDataTypeDescriptor(rc.getName()) :
+                    getColumnDataTypeDescriptor(rc.getName(), td);
+
             // todo dtd may be null if the column does not exist, we should check that first
             if (dtd != null && dtd.isNullable())
             {
@@ -1517,7 +1450,7 @@ class TableElementList extends QueryTree
                     ? SQLState.LANG_ADD_PRIMARY_KEY_ON_NULL_COLS
                     : SQLState.LANG_DB2_ADD_UNIQUE_OR_PRIMARY_KEY_ON_NULL_COLS;
 
-                throw StandardException.newException(errorState, colName);
+                throw StandardException.newException(errorState, rc.getName());
             }
         }
     }
@@ -1551,12 +1484,9 @@ class TableElementList extends QueryTree
      * not in the list.
      */
     private ColumnDefinitionNode findColumnDefinition(String colName) {
-        int size = size();
-        for (int index = 0; index < size; index++) {
-            TableElementNode tableElement = (TableElementNode) elementAt(index);
-
-            if (tableElement instanceof ColumnDefinitionNode) {
-                ColumnDefinitionNode cdn = (ColumnDefinitionNode) tableElement;
+        for (TableElementNode te : this) {
+            if (te instanceof ColumnDefinitionNode) {
+                ColumnDefinitionNode cdn = (ColumnDefinitionNode) te;
                 if (colName.equals(cdn.getName())) {
                     return cdn;
                 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java Fri Jun 28 04:32:08 2013
@@ -242,7 +242,7 @@ public class TypeCompilerFactoryImpl imp
                 if (anInstance == null)
                 {
                         Exception exc = null;
-                        Class typeCompilerClass = null;
+                        Class<?> typeCompilerClass = null;
 
                         try
                         {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java Fri Jun 28 04:32:08 2013
@@ -855,7 +855,7 @@ public final class UpdateNode extends DM
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public	FormatableBitSet	getReadMap
+    FormatableBitSet getReadMap
 	(
 		DataDictionary		dd,
 		TableDescriptor		baseTable,
@@ -1070,7 +1070,8 @@ public final class UpdateNode extends DM
 			// go back to the older release if that's what the user chooses
 			// after the soft-upgrade.
 			boolean in10_9_orHigherVersion = dd.checkVersion(DataDictionary.DD_VERSION_DERBY_10_9,null);
-            for (Iterator descIter = relevantTriggers.iterator();
+
+            for (Iterator<?> descIter = relevantTriggers.iterator();
                     descIter.hasNext(); ) {
                 TriggerDescriptor trd = (TriggerDescriptor) descIter.next();
 				if (in10_9_orHigherVersion) {
@@ -1201,26 +1202,22 @@ public final class UpdateNode extends DM
 	)
 		throws StandardException
 	{
-        ResultColumnList        updateColumnList = updateSet.getResultColumns();
-        int                             count = updateColumnList.size();
-        ColumnDescriptorList    generatedColumns = baseTable.getGeneratedColumns();
-        int                                 generatedColumnCount = generatedColumns.size();
-        HashSet<String>           updatedColumns = new HashSet<String>();
-        UUID                            tableID = baseTable.getObjectID();
+        ResultColumnList     updateColumnList = updateSet.getResultColumns();
+        ColumnDescriptorList generatedColumns = baseTable.getGeneratedColumns();
+        HashSet<String>      updatedColumns = new HashSet<String>();
+        UUID                 tableID = baseTable.getObjectID();
         
-		for (int ix = 0; ix < count; ix++)
+        for (ResultColumn rc : updateColumnList)
 		{
-			String      name = ((ResultColumn)updateColumnList.elementAt( ix )).getName();
-
-            updatedColumns.add( name );
+            updatedColumns.add( rc.getName() );
 		}
 
-        for ( int gcIdx = 0; gcIdx < generatedColumnCount; gcIdx++ )
+        for (ColumnDescriptor gc : generatedColumns)
         {
-            ColumnDescriptor    gc = generatedColumns.elementAt( gcIdx );
-            DefaultInfo             defaultInfo = gc.getDefaultInfo();
-            String[]                       mentionedColumnNames = defaultInfo.getReferencedColumnNames();
-            int                         mentionedColumnCount = mentionedColumnNames.length;
+            DefaultInfo defaultInfo = gc.getDefaultInfo();
+            String[] mentionedColumnNames =
+                    defaultInfo.getReferencedColumnNames();
+            int mentionedColumnCount = mentionedColumnNames.length;
 
             // handle the case of setting a generated column to the DEFAULT
             // literal
@@ -1228,11 +1225,9 @@ public final class UpdateNode extends DM
 
             // figure out if this generated column is affected by the
             // update
-            for ( int mcIdx = 0; mcIdx < mentionedColumnCount; mcIdx++ )
+            for (String mcn : mentionedColumnNames)
             {
-                String                      mentionedColumnName = mentionedColumnNames[ mcIdx ];
-
-                if ( updatedColumns.contains( mentionedColumnName ) )
+                if ( updatedColumns.contains( mcn ) )
                 {
                     // Yes, we are updating one of the columns mentioned in
                     // this generation clause.
@@ -1281,11 +1276,8 @@ public final class UpdateNode extends DM
 		{ tableNameNode = ((CurrentOfNode) fromTable).getBaseCursorTargetTableName(); }
 		else { tableNameNode = makeTableName( null, fromTable.getBaseTableName() ); }
 		
-		int			count = rcl.size();
-
-		for ( int i = 0; i < count; i++ )
+        for (ResultColumn column : rcl)
 		{
-			ResultColumn	column = (ResultColumn) rcl.elementAt( i );
 			ColumnReference	reference = column.getReference();
 
 			if ( (reference != null) && correlationName.equals( reference.getTableName() ) )
@@ -1304,18 +1296,14 @@ public final class UpdateNode extends DM
 	private void checkTableNameAndScrubResultColumns(ResultColumnList rcl) 
 			throws StandardException
 	{
-		int columnCount = rcl.size();
-		int tableCount = ((SelectNode)resultSet).fromList.size();
-
-		for ( int i = 0; i < columnCount; i++ )
+        for (ResultColumn column : rcl)
 		{
 			boolean foundMatchingTable = false;			
-			ResultColumn	column = (ResultColumn) rcl.elementAt( i );
 
 			if (column.getTableName() != null) {
-				for (int j = 0; j < tableCount; j++) {
-					FromTable fromTable = (FromTable) ((SelectNode)resultSet).
-							fromList.elementAt(j);
+                for (ResultSetNode rsn : ((SelectNode)resultSet).fromList) {
+                    FromTable fromTable = (FromTable)rsn;
+
 					final String tableName;
 					if ( fromTable instanceof CurrentOfNode ) { 
 						tableName = ((CurrentOfNode)fromTable).
@@ -1405,12 +1393,12 @@ public final class UpdateNode extends DM
 
         for ( int i = 0; i < count; i++ )
         {
-            ResultColumn    rc = (ResultColumn) targetRCL.elementAt( i );
+            ResultColumn rc = targetRCL.elementAt( i );
 
             if ( rc.hasGenerationClause() )
             {
                 ValueNode   resultExpression =
-                    ((ResultColumn) resultRCL.elementAt( i )).getExpression();
+                    resultRCL.elementAt( i ).getExpression();
 
                 if ( !( resultExpression instanceof DefaultNode) )
                 {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java Fri Jun 28 04:32:08 2013
@@ -126,9 +126,13 @@ class UserAggregateDefinition implements
                      );
             }
 
-            Class[]   genericParameterTypes = classFactory.getClassInspector().getGenericParameterTypes
-                ( derbyAggregatorInterface, userAggregatorClass );
-            if ( genericParameterTypes == null ) { genericParameterTypes = new Class[ AGGREGATOR_PARAM_COUNT ]; }
+            Class<?>[] genericParameterTypes =
+                classFactory.getClassInspector().getGenericParameterTypes(
+                    derbyAggregatorInterface, userAggregatorClass);
+
+            if ( genericParameterTypes == null ) {
+                genericParameterTypes = new Class<?>[ AGGREGATOR_PARAM_COUNT ];
+            }
 
             AggregateAliasInfo  aai = (AggregateAliasInfo) _alias.getAliasInfo();
             DataTypeDescriptor  expectedInputType = DataTypeDescriptor.getType( aai.getForType() );
@@ -222,7 +226,7 @@ class UserAggregateDefinition implements
     /**
      * Get the Java class corresponding to a Derby datatype.
      */
-    private Class   getJavaClass( ClassFactory classFactory, DataTypeDescriptor dtd )
+    private Class<?> getJavaClass( ClassFactory classFactory, DataTypeDescriptor dtd )
         throws StandardException, ClassNotFoundException
     {
         JSQLType    jsqlType = new JSQLType( dtd );