db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1497644 [1/4] - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/loader/ iapi/sql/compile/ impl/sql/compile/
Date Fri, 28 Jun 2013 04:32:09 GMT
Author: dag
Date: Fri Jun 28 04:32:08 2013
New Revision: 1497644

URL: http://svn.apache.org/r1497644
Log:
DERBY-673: Get rid of the NodeFactory

Patch derby-673-typesafe-lists-2, which introduces generics to the
lists based on QueryTreeNodeVector. I also let the latter implement
the Iterable interface, which opens up for using Java 6 "foreach"
syntax in many cases. The patch makes use of this. Together, these
changes enables many casts to be eliminated and code clarification in
the compiler implementation.

It also removes most -Xlint warnings from impl/sql/compile classes, so
it should be ready to run with full lint.

Diffstat summary:
63 files changed, 854 insertions(+), 1236 deletions(-)

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IndexToBaseRowNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderedColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNodeVector.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceAggregatesWithCRVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ReplaceWindowFuncCallsWithCRVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RevokeRoleNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowOrderingImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubstituteExpressionVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableElementList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TypeCompilerFactoryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserAggregateDefinition.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VTIDeferModPolicy.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/loader/ClassInspector.java Fri Jun 28 04:32:08 2013
@@ -554,7 +554,8 @@ public class ClassInspector
      * the actual types of the interface type variables.
      * May return null or an array of nulls if type resolution fails.
 	 */
-    public Class[] getGenericParameterTypes( Class parameterizedType, Class implementation )
+    public Class<?>[] getGenericParameterTypes(
+            Class parameterizedType, Class implementation )
         throws StandardException
 	{
         // construct the inheritance chain stretching from the parameterized
@@ -577,7 +578,7 @@ public class ClassInspector
             return null;
         }
 
-        return parameterTypes.toArray(new Class[parameterTypes.size()]);
+        return parameterTypes.toArray(new Class<?>[parameterTypes.size()]);
     }
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/CompilerContext.java Fri Jun 28 04:32:08 2013
@@ -310,7 +310,7 @@ public interface CompilerContext extends
 	 * @exception StandardException thrown on failure.
 	 *
 	 */
-	public	void createDependency(Dependent d, Provider p) throws StandardException;
+    void createDependency(Dependent d, Provider p) throws StandardException;
 
 	/**
 	 * Add an object to the pool that is created at compile time
@@ -346,25 +346,25 @@ public interface CompilerContext extends
 	 *
 	 * @param inUse	 The new inUse state for the compiler context.
 	 */
-	public void setInUse(boolean inUse);
+    void setInUse(boolean inUse);
 
 	/**
 	 * Return the in use state for the compiler context.
 	 *
 	 * @return boolean	The in use state for the compiler context.
 	 */
-	public boolean getInUse();
+    boolean getInUse();
 
 	/**
 	 * Mark this CompilerContext as the first on the stack, so we can avoid
 	 * continually popping and pushing a CompilerContext.
 	 */
-	public void firstOnStack();
+    void firstOnStack();
 
 	/**
 	 * Is this the first CompilerContext on the stack?
 	 */
-	public boolean isFirstOnStack();
+    boolean isFirstOnStack();
 
 	/**
 	 * Sets which kind of query fragments are NOT allowed. Basically,
@@ -375,7 +375,7 @@ public interface CompilerContext extends
 	 *						see the reliability bitmasks above
 	 *
 	 */
-	public void	setReliability(int reliability);
+    void    setReliability(int reliability);
 
 	/**
 	 * Return the reliability requirements of this clause. See setReliability()
@@ -383,7 +383,7 @@ public interface CompilerContext extends
 	 *
 	 * @return a bitmask of which types of query fragments are to be forbidden
 	 */
-	public int getReliability();
+    int getReliability();
 
 	/**
 	 * Get the compilation schema descriptor for this compilation context.
@@ -392,7 +392,7 @@ public interface CompilerContext extends
 	 * 
 	 * @return the compilation schema descirptor
 	 */
-	public SchemaDescriptor getCompilationSchema();
+    SchemaDescriptor getCompilationSchema();
 
 	/**
 	 * Set the compilation schema descriptor for this compilation context.
@@ -401,7 +401,7 @@ public interface CompilerContext extends
 	 * 
 	 * @return the previous compilation schema descirptor
 	 */
-	public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault);
+    SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault);
 
 	/**
 	 * Push a default schema to use when compiling.
@@ -414,13 +414,13 @@ public interface CompilerContext extends
 	 * </p>
 	 * @param sd schema to use
 	 */
-	public void pushCompilationSchema(SchemaDescriptor sd);
+    void pushCompilationSchema(SchemaDescriptor sd);
 
 
 	/**
 	 * Pop the default schema to use when compiling.
 	 */
-	public void popCompilationSchema();
+    void popCompilationSchema();
 
 	/**
 	 * Get a StoreCostController for the given conglomerate.
@@ -432,7 +432,7 @@ public interface CompilerContext extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public StoreCostController getStoreCostController(long conglomerateNumber)
+    StoreCostController getStoreCostController(long conglomerateNumber)
 			throws StandardException;
 
 	/**
@@ -440,78 +440,78 @@ public interface CompilerContext extends
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public SortCostController getSortCostController() throws StandardException;
+    SortCostController getSortCostController() throws StandardException;
 
 	/**
 	 * Set the parameter list.
 	 *
 	 * @param parameterList	The parameter list.
 	 */
-    public void setParameterList(List<ParameterNode> parameterList);
+    void setParameterList(List<ParameterNode> parameterList);
 
 	/**
 	 * Get the parameter list.
 	 *
 	 * @return	The parameter list.
 	 */
-    public List<ParameterNode> getParameterList();
+    List<ParameterNode> getParameterList();
 
 	/**
 	 * If callable statement uses ? = form
 	 */
-	public void setReturnParameterFlag();
+    void setReturnParameterFlag();
 
 	/**
 	 * Is the callable statement uses ? for return parameter.
 	 *
 	 * @return	true if ? = call else false
 	 */
-	public boolean getReturnParameterFlag();
+    boolean getReturnParameterFlag();
 
 	/**
 	 * Get the cursor info stored in the context.
 	 *
 	 * @return the cursor info
 	 */
-	public Object getCursorInfo();
+    Object getCursorInfo();
 	
 	/**
 	 * Set params
 	 *
 	 * @param cursorInfo the cursor info
 	 */
-	public void setCursorInfo(Object cursorInfo);
+    void setCursorInfo(Object cursorInfo);
 
 	/**
 	 * Set the isolation level for the scans in this query.
 	 *
 	 * @param isolationLevel	The isolation level to use.
 	 */
-	public void setScanIsolationLevel(int isolationLevel);
+    void setScanIsolationLevel(int isolationLevel);
 
 	/**
 	 * Get the isolation level for the scans in this query.
 	 *
 	 * @return	The isolation level for the scans in this query.
 	 */
-	public int getScanIsolationLevel();
+    int getScanIsolationLevel();
 
 	/**
 	 * Get the next equivalence class for equijoin clauses.
 	 *
 	 * @return The next equivalence class for equijoin clauses.
 	 */
-	public int getNextEquivalenceClass();
+    int getNextEquivalenceClass();
 
 	/**
 		Add a compile time warning.
 	*/
-	public void addWarning(SQLWarning warning);
+    void addWarning(SQLWarning warning);
 
 	/**
 		Get the chain of compile time warnings.
 	*/
-	public SQLWarning getWarnings();
+    SQLWarning getWarnings();
 
 	/**
 	 * Sets the current privilege type context and pushes the previous on onto a stack.
@@ -522,23 +522,23 @@ public interface CompilerContext extends
 	 * @param privType One of the privilege types in 
 	 *						org.apache.derby.iapi.sql.conn.Authorizer.
 	 */
-	public void pushCurrentPrivType( int privType);
+    void pushCurrentPrivType( int privType);
 	
-	public void popCurrentPrivType();
+    void popCurrentPrivType();
     
 	/**
 	 * Add a column privilege to the list of used column privileges.
 	 *
 	 * @param column
 	 */
-	public void addRequiredColumnPriv( ColumnDescriptor column);
+    void addRequiredColumnPriv( ColumnDescriptor column);
 
 	/**
 	 * Add a table or view privilege to the list of used table privileges.
 	 *
 	 * @param table
 	 */
-	public void addRequiredTablePriv( TableDescriptor table);
+    void addRequiredTablePriv( TableDescriptor table);
 
 	/**
 	 * Add a schema privilege to the list of used privileges.
@@ -547,42 +547,42 @@ public interface CompilerContext extends
 	 * @param aid		Requested authorizationId for new schema
 	 * @param privType	CREATE_SCHEMA_PRIV, MODIFY_SCHEMA_PRIV or DROP_SCHEMA_PRIV
 	 */
-	public void addRequiredSchemaPriv(String schema, String aid, int privType);
+    void addRequiredSchemaPriv(String schema, String aid, int privType);
 
 	/**
 	 * Add a routine execute privilege to the list of used routine privileges.
 	 *
 	 * @param routine
 	 */
-	public void addRequiredRoutinePriv( AliasDescriptor routine);
+    void addRequiredRoutinePriv( AliasDescriptor routine);
 
 	/**
 	 * Add a usage privilege to the list of required privileges.
 	 *
 	 * @param usableObject
 	 */
-	public void addRequiredUsagePriv( PrivilegedSQLObject usableObject );
+    void addRequiredUsagePriv( PrivilegedSQLObject usableObject );
 
 	/**
 	 * Add a required role privilege to the list of privileges.
 	 *
 	 * @see CompilerContext#addRequiredRolePriv
 	 */
-	public void addRequiredRolePriv(String roleName, int privType);
+    void addRequiredRolePriv(String roleName, int privType);
 
 	/**
 	 * @return The list of required privileges.
 	 */
-	public List<StatementPermission>getRequiredPermissionsList();
+    List<StatementPermission>getRequiredPermissionsList();
     
 	/**
 	 * Add a sequence descriptor to the list of referenced sequences.
 	 */
-	public void addReferencedSequence( SequenceDescriptor sd );
+    void addReferencedSequence( SequenceDescriptor sd );
 
 	/**
 	 * Report whether the given sequence has been referenced already.
 	 */
-    public boolean isReferenced( SequenceDescriptor sd );
+    boolean isReferenced( SequenceDescriptor sd );
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Fri Jun 28 04:32:08 2013
@@ -50,7 +50,7 @@ class AggregateNode extends UnaryOperato
     private TableName           userAggregateName;
 	private StringBuffer			aggregatorClassName;
 	private String					aggregateDefinitionClassName;
-	private Class					aggregateDefinitionClass;
+    private Class<?>                aggregateDefinitionClass;
 	private ClassInspector			classInspector;
 	private String					aggregateName;
 
@@ -126,7 +126,7 @@ class AggregateNode extends UnaryOperato
      */
     AggregateNode(
             ValueNode operand,
-            Class uadClass,
+            Class<?> uadClass,
             boolean distinct,
             String aggregateName,
             ContextManager cm) throws StandardException {
@@ -492,7 +492,7 @@ class AggregateNode extends UnaryOperato
 	{
         if ( uad == null )
         {
-            Class theClass = aggregateDefinitionClass;
+            Class<?> theClass = aggregateDefinitionClass;
 
             // get the class
             if (theClass == null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BetweenOperatorNode.java Fri Jun 28 04:32:08 2013
@@ -114,7 +114,7 @@ class BetweenOperatorNode extends Binary
         leftBCO = new BinaryRelationalOperatorNode(
 									C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE,
 									leftOperand, 
-                                    (ValueNode)rightOperandList.elementAt(0),
+                                    rightOperandList.elementAt(0),
                                     false,
 									cm);
 		/* Set type info for the operator node */
@@ -130,7 +130,7 @@ class BetweenOperatorNode extends Binary
         rightBCO = new BinaryRelationalOperatorNode(
 								C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE,
 								leftClone,
-                                (ValueNode)rightOperandList.elementAt(1),
+                                rightOperandList.elementAt(1),
                                 false,
 								cm);
 		/* Set type info for the operator node */
@@ -209,7 +209,7 @@ class BetweenOperatorNode extends Binary
             new BinaryRelationalOperatorNode(
 						C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
 						leftClone1, 
-                        (ValueNode)rightOperandList.elementAt(1),
+                        rightOperandList.elementAt(1),
                         false,
 						cm);
 
@@ -225,7 +225,7 @@ class BetweenOperatorNode extends Binary
             new BinaryRelationalOperatorNode(
 					C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
 					leftOperand, 
-                    (ValueNode)rightOperandList.elementAt(0),
+                    rightOperandList.elementAt(0),
                     false,
 					cm);
 
@@ -278,7 +278,7 @@ class BetweenOperatorNode extends Binary
         leftBCO = new BinaryRelationalOperatorNode(
 							C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE,
 							leftOperand, 
-                            (ValueNode)rightOperandList.elementAt(0),
+                            rightOperandList.elementAt(0),
                             false,
 							cm);
 		/* Set type info for the operator node */
@@ -288,7 +288,7 @@ class BetweenOperatorNode extends Binary
         rightBCO = new BinaryRelationalOperatorNode(
 						C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE,
 						leftOperand, 
-                        (ValueNode)rightOperandList.elementAt(1),
+                        rightOperandList.elementAt(1),
                         false,
 						cm);
 		/* Set type info for the operator node */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java Fri Jun 28 04:32:08 2013
@@ -1379,7 +1379,7 @@ class BinaryRelationalOperatorNode
 
 	/** return the selectivity of this predicate.
 	 */
-    @Override
+    @Override @SuppressWarnings("fallthrough")
 	public double selectivity(Optimizable optTable)
 	throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Fri Jun 28 04:32:08 2013
@@ -187,7 +187,7 @@ class CastNode extends ValueNode
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-    @Override
+    @Override @SuppressWarnings("fallthrough")
     ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 				throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java Fri Jun 28 04:32:08 2013
@@ -155,37 +155,41 @@ class CoalesceFunctionNode extends Value
 		//find the first non-param argument. The generated method will generate code to call coalesce on this argument
 		for (int index = 0; index < argumentsListSize; index++)
 		{
-			if (!(((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext()))
+            if (!argumentsList.elementAt(index).requiresTypeFromContext())
 			{
 				firstNonParameterNodeIdx = index;
 				break;
 			}
 		}
 
-		//make sure these arguments are compatible to each other before coalesce can be allowed
-		for (int index = 0; index < argumentsListSize; index++)
-		{
-			if (((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext()) //since we don't know the type of param, can't check for compatibility
+        // Make sure these arguments are compatible to each other before
+        // coalesce can be allowed.
+        for (ValueNode vn : argumentsList) {
+            if (vn.requiresTypeFromContext()) {
+                // Since we don't know the type of param, can't check for
+                // compatibility.
 				continue;
-				argumentsList.compatible((ValueNode) argumentsList.elementAt(index));
+            }
+            argumentsList.compatible(vn);
 		}
 
-		//set the result type to the most dominant datatype in the arguments list and based on the table listed above
+        // Set the result type to the most dominant datatype in the arguments
+        // list and based on the table listed above.
 		setType(argumentsList.getDominantTypeServices());
 
-		//set all the parameter types to the type of the result type
-		for (int index = 0; index < argumentsListSize; index++)
+        // Set all the parameter types to the type of the result type.
+        for (ValueNode vn : argumentsList)
 		{
-			if (((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext())
+            if (vn.requiresTypeFromContext())
 			{
-				((ValueNode)argumentsList.elementAt(index)).setType(getTypeServices());
+                vn.setType(getTypeServices());
 			}
 		}
 		return this;
 	}
 
 	/**
-	 * Do code generation for coalese/value
+     * Do code generation for coalesce/value
 	 *
 	 * @param acb	The ExpressionClassBuilder for the class we're generating
 	 * @param mb	The method the expression will go into
@@ -257,7 +261,7 @@ class CoalesceFunctionNode extends Value
 			}
 
 			setArrayMethod.getField(arrayField); 
-			((ValueNode) argumentsList.elementAt(index)).generateExpression(acb, setArrayMethod);
+            argumentsList.elementAt(index).generateExpression(acb, setArrayMethod);
 			setArrayMethod.upCast(receiverType);
 			setArrayMethod.setArrayElement(index);
 		}
@@ -283,7 +287,7 @@ class CoalesceFunctionNode extends Value
 		*/
 
 		// coalesce will be called on this non-parameter argument
-		((ValueNode) argumentsList.elementAt(firstNonParameterNodeIdx)).
+        argumentsList.elementAt(firstNonParameterNodeIdx).
 			generateExpression(acb, mb);
 
 		mb.upCast(ClassName.DataValueDescriptor);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CompilerContextImpl.java Fri Jun 28 04:32:08 2013
@@ -634,16 +634,16 @@ public class CompilerContextImpl extends
 		return warnings;
 	}
 
-	/////////////////////////////////////////////////////////////////////////////////////
-	//
-	// class interface
-	//
-	// this constructor is called with the parser
-	// to be saved when the context
-	// is created (when the first statement comes in, likely).
-	//
-	/////////////////////////////////////////////////////////////////////////////////////
+    /*
+     * class interface
+     */
 
+    /**
+     * This constructor creates and saves the parser using the language
+     * connection factory when the context is created (when the first statement
+     * comes in, likely).
+     */
+    @SuppressWarnings("LeakingThisInConstructor")
 	public CompilerContextImpl(ContextManager cm,
 			LanguageConnectionContext lcc,
 		TypeCompilerFactory typeCompilerFactory )
@@ -671,9 +671,8 @@ public class CompilerContextImpl extends
 		requiredRoutinePrivileges = null;
 		requiredUsagePrivileges = null;
 		requiredRolePrivileges = null;
-		LanguageConnectionContext lcc = (LanguageConnectionContext)
-		getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
-		if( lcc.usesSqlAuthorization())
+
+        if( lcc.usesSqlAuthorization())
 		{
 			requiredColumnPrivileges = new HashMap<StatementTablePermission,StatementColumnPermission>();
 			requiredTablePrivileges = new HashMap<StatementTablePermission,StatementTablePermission>();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java Fri Jun 28 04:32:08 2013
@@ -77,7 +77,7 @@ class ConditionalNode extends ValueNode
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
+    @Override
     void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
@@ -192,13 +192,11 @@ class ConditionalNode extends ValueNode
 		 * dummy SubqueryList and AggreateList (we don't care)
 		 */
 
-		ValueNode thenNode =
-			((ValueNode)thenElseList.elementAt(0)).bindExpression(
+        ValueNode thenNode = thenElseList.elementAt(0).bindExpression(
                 fromList, subqueryList, aggregates);
         thenElseList.setElementAt( thenNode, 0 );
 
-		ValueNode elseNode =
-			((ValueNode)thenElseList.elementAt(1)).bindExpression(
+        ValueNode elseNode = thenElseList.elementAt(1).bindExpression(
                 fromList, subqueryList, aggregates);
         thenElseList.setElementAt( elseNode, 1 );
 
@@ -279,8 +277,8 @@ class ConditionalNode extends ValueNode
 		
 		// need to have nullNodes nullable
 		castType = castType.getNullabilityType(true);
-		ValueNode thenNode = (ValueNode)thenElseList.elementAt(0);
-		ValueNode elseNode = (ValueNode)thenElseList.elementAt(1);
+        ValueNode thenNode = thenElseList.elementAt(0);
+        ValueNode elseNode = thenElseList.elementAt(1);
 
 		// first check if the "then" node is NULL
 		if (isNullNode(thenNode) &&
@@ -289,7 +287,8 @@ class ConditionalNode extends ValueNode
 			// recast and rebind. findTypes would have bound as SQL CHAR.
 			// need to rebind here. (DERBY-3032)
 			thenElseList.setElementAt(recastNullNode(thenNode, castType), 0);
-            ((ValueNode) thenElseList.elementAt(0)).bindExpression(fromList, subqueryList, aggregates);
+            thenElseList.elementAt(0).bindExpression(
+                    fromList, subqueryList, aggregates);
 			
 		// otherwise recurse on thenNode, but only if it's a conditional
 		} else if (isConditionalNode(thenNode)) {
@@ -304,7 +303,8 @@ class ConditionalNode extends ValueNode
 			// recast and rebind. findTypes would have bound as SQL CHAR.
 			// need to rebind here. (DERBY-3032)
 			thenElseList.setElementAt(recastNullNode(elseNode, castType), 1);
-            ((ValueNode) thenElseList.elementAt(1)).bindExpression(fromList, subqueryList, aggregates);
+            thenElseList.elementAt(1).bindExpression(
+                    fromList, subqueryList, aggregates);
 		// otherwise recurse on elseNode, but only if it's a conditional
 		} else if (isConditionalNode(elseNode)) {
 			recastNullNodes(((ConditionalNode)elseNode).thenElseList,
@@ -331,7 +331,7 @@ class ConditionalNode extends ValueNode
 	 *
 	 * @exception StandardException Thrown on error.
 	 */
-	private QueryTreeNode recastNullNode(ValueNode nodeToCast,
+    private CastNode recastNullNode(ValueNode nodeToCast,
 		DataTypeDescriptor typeToUse) throws StandardException
 	{
         return new CastNode(
@@ -379,8 +379,8 @@ class ConditionalNode extends ValueNode
 			 * The untyped NULL should have a data type descriptor
 			 * that allows its value to be nullable.
 			 */
-            QueryTreeNode cast = new CastNode(
-                        (ValueNode)thenElseList.elementAt(0),
+            CastNode cast = new CastNode(
+                        thenElseList.elementAt(0),
 						bcon.getLeftOperand().getTypeServices().getNullabilityType(true),
 						getContextManager());
 
@@ -405,8 +405,8 @@ class ConditionalNode extends ValueNode
 		
 		// Can't get the then and else expressions until after they've been bound
 		// expressions have been bound by findType and rebound by recastNullNodes if needed.
-		ValueNode thenExpression = (ValueNode) thenElseList.elementAt(0);
-		ValueNode elseExpression = (ValueNode) thenElseList.elementAt(1);
+        ValueNode thenExpression = thenElseList.elementAt(0);
+        ValueNode elseExpression = thenElseList.elementAt(1);
 
 		/* testCondition must be a boolean expression.
 		 * If it is a ? parameter on the left, then set type to boolean,
@@ -492,8 +492,8 @@ class ConditionalNode extends ValueNode
 		** stick it over the original expression
 		*/
 		TypeId condTypeId = getTypeId();
-		TypeId thenTypeId = ((ValueNode) thenElseList.elementAt(0)).getTypeId();
-		TypeId elseTypeId = ((ValueNode) thenElseList.elementAt(1)).getTypeId();
+        TypeId thenTypeId = thenElseList.elementAt(0).getTypeId();
+        TypeId elseTypeId = thenElseList.elementAt(1).getTypeId();
 
 		/* Need to generate conversion if thenExpr or elseExpr is not of 
 		 * dominant type.  (At least 1 of them must be of the dominant type.)
@@ -501,7 +501,7 @@ class ConditionalNode extends ValueNode
 		if (thenTypeId.typePrecedence() != condTypeId.typePrecedence())
 		{
             ValueNode cast = new CastNode(
-                                (ValueNode)thenElseList.elementAt(0),
+                                thenElseList.elementAt(0),
                                 getTypeServices(),	// cast to dominant type
 								getContextManager());
 			cast = cast.bindExpression(fromList, 
@@ -514,7 +514,7 @@ class ConditionalNode extends ValueNode
 		else if (elseTypeId.typePrecedence() != condTypeId.typePrecedence())
 		{
             ValueNode cast = new CastNode(
-                                (ValueNode)thenElseList.elementAt(1),
+                                thenElseList.elementAt(1),
                                 getTypeServices(),	// cast to dominant type
 								getContextManager());
 			cast = cast.bindExpression(fromList, 
@@ -671,8 +671,8 @@ class ConditionalNode extends ValueNode
 		}
 
 		/* Simply swap the then and else expressions */
-		thenExpression = (ValueNode) thenElseList.elementAt(0);
-		elseExpression = (ValueNode) thenElseList.elementAt(1);
+        thenExpression = thenElseList.elementAt(0);
+        elseExpression = thenElseList.elementAt(1);
 		thenElseList.setElementAt(elseExpression, 0);
 		thenElseList.setElementAt(thenExpression, 1);
 
@@ -697,9 +697,9 @@ class ConditionalNode extends ValueNode
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "equals", "boolean", 1);
 
 		mb.conditionalIf();
-		  ((ValueNode) thenElseList.elementAt(0)).generateExpression(acb, mb);
+         thenElseList.elementAt(0).generateExpression(acb, mb);
 		mb.startElseCode();
-		  ((ValueNode) thenElseList.elementAt(1)).generateExpression(acb, mb);
+         thenElseList.elementAt(1).generateExpression(acb, mb);
 		mb.completeConditional();
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java Fri Jun 28 04:32:08 2013
@@ -323,9 +323,8 @@ class CreateTableNode extends DDLStateme
 			/* Create table element list from columns in query expression */
             tableElementList = new TableElementList(getContextManager());
 			
-			for (int index = 0; index < qeRCL.size(); index++)
+            for (ResultColumn rc : qeRCL)
 			{
-				ResultColumn rc = (ResultColumn) qeRCL.elementAt(index);
 				if (rc.isGenerated()) 
 				{
 					continue;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java Fri Jun 28 04:32:08 2013
@@ -412,10 +412,9 @@ class CreateTriggerNode extends DDLState
 		if (triggerCols != null && triggerCols.size() != 0)
 		{
             HashSet<String> columnNames = new HashSet<String>();
-			int tcSize = triggerCols.size();
-			for (int i = 0; i < tcSize; i++)
+
+            for (ResultColumn rc : triggerCols)
 			{
-				ResultColumn rc  = (ResultColumn) triggerCols.elementAt(i);
 				if (!columnNames.add(rc.getName()))
 				{
 					throw StandardException.newException(SQLState.LANG_DUPLICATE_COLUMN_IN_TRIGGER_UPDATE, 
@@ -526,8 +525,7 @@ class CreateTriggerNode extends DDLState
 			//their column positions and ensure that those columns do
 			//indeed exist in the trigger table.
 			referencedColInts = new int[triggerCols.size()];
-			ResultColumn rc;
-			ColumnDescriptor cd;
+
 			//This is the most interesting case for us. If we are here, 
 			//then it means that the trigger is defined at the row level
 			//and a set of trigger columns are specified in the CREATE
@@ -539,8 +537,9 @@ class CreateTriggerNode extends DDLState
 			//    FOR EACH ROW UPDATE table2 SET c24=oldt.c14;
 			
 			for (int i=0; i < triggerCols.size(); i++){
-				rc = (ResultColumn)triggerCols.elementAt(i);
-				cd = triggerTableDescriptor.getColumnDescriptor(rc.getName());
+                ResultColumn rc = triggerCols.elementAt(i);
+                ColumnDescriptor cd =
+                    triggerTableDescriptor.getColumnDescriptor(rc.getName());
 				//Following will catch the case where an invalid trigger column
 				//has been specified in CREATE TRIGGER statement.
 				//CREATE TRIGGER tr1 AFTER UPDATE OF c1678 ON table1 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateViewNode.java Fri Jun 28 04:32:08 2013
@@ -278,7 +278,7 @@ class CreateViewNode extends DDLStatemen
 		}
 
 		DependencyManager 		dm = dataDictionary.getDependencyManager();
-		ProviderInfo[]			providerInfos = dm.getPersistentProviderInfos(apl);
+        ProviderInfo[]          provInfo = dm.getPersistentProviderInfos(apl);
 		// need to clear the column info in case the same table descriptor
 		// is reused, eg., in multiple target only view definition
 		dm.clearColumnInfoInProviders(apl);
@@ -291,7 +291,7 @@ class CreateViewNode extends DDLStatemen
 				" on return from RS.bindExpressions()");
 		}
 
-		return providerInfos;
+        return provInfo;
 	}
 
 	/**
@@ -343,7 +343,7 @@ class CreateViewNode extends DDLStatemen
 
 		for (int index = 0; index < colInfos.length; index++)
 		{
-			ResultColumn rc = (ResultColumn) rcl.elementAt(index);
+            ResultColumn rc = rcl.elementAt(index);
 			// The colInfo array has been initialized to be of length 
 			// visibleSize() (DERBY-4230).  This code assumes that all the visible
 			// columns are at the beginning of the rcl. Throw an assertion 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java Fri Jun 28 04:32:08 2013
@@ -738,7 +738,7 @@ public class CursorNode extends DMLState
 		int size = updatableColumns.size();
 		TableDescriptor tableDescriptor;
 		String columnName;
-		ResultColumnList rcls = resultSet.getResultColumns();
+        ResultColumnList rcl = resultSet.getResultColumns();
 
 		for (int index = 0; index < size; index++)
 		{
@@ -749,18 +749,29 @@ public class CursorNode extends DMLState
 					throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND, columnName);
 		    }
 
-		    ResultColumn rc;
-		    //make sure that we are not using correlation names for updatable columns. 
-		    //eg select c11 as col1, 2, c13 as col3 from t1 for update of c11, c12
-		    //In the eg above, correlation name for c11 will cause exception because Derby does not support correlation name for updatable columns
-		    //But correlation name for c13 is ok because it is a read only column
-		    for (int rclsIndex = 0; rclsIndex < rcls.size(); rclsIndex++) {//look through each column in the resultset for cursor
-					rc = ((ResultColumn) rcls.elementAt(rclsIndex));
-					if (rc.getSourceTableName() == null) //continue to look at the next column because this is derived column in the select list
-					continue;
-					if (rc.getExpression() != null && rc.getExpression().getColumnName().equals(columnName) &&  !rc.getName().equals(columnName)) {
-					throw StandardException.newException(SQLState.LANG_CORRELATION_NAME_FOR_UPDATABLE_COLUMN_DISALLOWED_IN_CURSOR, columnName);
-					}
+            // Make sure that we are not using correlation names for updatable
+            // columns.
+            //
+            // Example:
+            //     select c11 as col1, 2, c13 as col3 from t1
+            //         for update of c11, c12
+            //
+            // The correlation name for c11 will cause an exception because
+            // Derby does not support correlation name for updatable
+            // columns. However, a correlation name for c13 is ok because it is
+            // a read only column.
+
+            for (ResultColumn rc : rcl) {
+                // Look through each column in the resultset for cursor.
+                if (rc.getSourceTableName() == null) {
+                    // Continue to look at the next column because this is
+                    // a derived column in the select list.
+                    continue;
+                }
+
+                if (rc.getExpression() != null && rc.getExpression().getColumnName().equals(columnName) &&  !rc.getName().equals(columnName)) {
+                    throw StandardException.newException(SQLState.LANG_CORRELATION_NAME_FOR_UPDATABLE_COLUMN_DISALLOWED_IN_CURSOR, columnName);
+                }
 		    }
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java Fri Jun 28 04:32:08 2013
@@ -413,7 +413,7 @@ abstract class DMLModStatementNode exten
 		TableDescriptor		targetTableDescriptor,
 		ResultColumnList	sourceRCL,
 		ResultColumnList	targetRCL,
-        boolean                 forUpdate,
+        boolean             forUpdate,
         ResultSetNode       updateResultSet
     )
 		throws StandardException
@@ -423,7 +423,7 @@ abstract class DMLModStatementNode exten
 
         for ( int i = 0; i < count; i++ )
         {
-            ResultColumn    rc = (ResultColumn) targetRCL.elementAt( i );
+            ResultColumn rc = targetRCL.elementAt( i );
 
             //
             // For updates, there are two copies of the column in the row: a
@@ -562,9 +562,8 @@ abstract class DMLModStatementNode exten
 			}
 		}
 
-		clauseTree = ((ResultColumn) 
-							((CursorNode) qt).getResultSetNode().getResultColumns().elementAt(0)).
-									getExpression();
+        clauseTree = ((CursorNode) qt).getResultSetNode().getResultColumns().
+                elementAt(0).getExpression();
 
 		lcc.popCompilerContext(newCC);
 
@@ -1125,7 +1124,7 @@ abstract class DMLModStatementNode exten
 	{
 		CompilerContext 			compilerContext = getCompilerContext();
 
-        for (Iterator descIter = tdl.iterator(); descIter.hasNext() ; ) {
+        for (Iterator<?> descIter = tdl.iterator(); descIter.hasNext() ; ) {
             TriggerDescriptor td = (TriggerDescriptor)descIter.next();
             /*
             ** The dependent now depends on this trigger.
@@ -1487,23 +1486,18 @@ abstract class DMLModStatementNode exten
 	  */
 	public	void	generateGenerationClauses
 	(
-        ResultColumnList            rcl,
-        int                                 resultSetNumber,
-        boolean                         isUpdate,
+        ResultColumnList        rcl,
+        int                     resultSetNumber,
+        boolean                 isUpdate,
 		ExpressionClassBuilder	ecb,
 		MethodBuilder			mb
     )
-							throws StandardException
+        throws StandardException
 	{
-		ResultColumn rc; 
-		int size = rcl.size();
         boolean hasGenerationClauses = false;
 
-		for (int index = 0; index < size; index++)
+        for (ResultColumn rc : rcl)
 		{
-			rc = (ResultColumn) rcl.elementAt(index);
-
-            //
             // Generated columns should be populated after the base row because
             // the generation clauses may refer to base columns that have to be filled
             // in first.
@@ -1589,7 +1583,7 @@ abstract class DMLModStatementNode exten
         }
         for ( int i = startColumn; i < size; i++ )
         {
-            ResultColumn    rc = (ResultColumn) rcl.elementAt( i );
+            ResultColumn rc = rcl.elementAt( i );
 
             if ( !rc.hasGenerationClause() ) { continue; }
 
@@ -1867,11 +1861,9 @@ abstract class DMLModStatementNode exten
 		
 		String synTableName = synonymTableName.getTableName();
 		
-		int	count = rcl.size();
-		for (int i = 0; i < count; i++)
+        for (ResultColumn rc : rcl)
 		{
-			ResultColumn    column    = (ResultColumn) rcl.elementAt(i);
-			ColumnReference	reference = column.getReference();
+            ColumnReference reference = rc.getReference();
 
 			if ( reference != null )
 			{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DefaultNode.java Fri Jun 28 04:32:08 2013
@@ -275,9 +275,8 @@ public  class DefaultNode extends ValueN
 			}
 		}
 
-		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/DeleteNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DeleteNode.java Fri Jun 28 04:32:08 2013
@@ -402,7 +402,7 @@ class DeleteNode extends DMLModStatement
 		if (targetTableDescriptor != null)
 		{
 			// Base table
-			int lockMode = resultSet.updateTargetLockMode();
+            int lckMode = resultSet.updateTargetLockMode();
 			long heapConglomId = targetTableDescriptor.getHeapConglomerateId();
 			TransactionController tc = getLanguageConnectionContext().getTransactionCompile();
 			StaticCompiledOpenConglomInfo[] indexSCOCIs = 
@@ -419,7 +419,7 @@ class DeleteNode extends DMLModStatement
 			*/
 			if (targetTableDescriptor.getLockGranularity() == TableDescriptor.TABLE_LOCK_GRANULARITY)
 			{
-				lockMode = TransactionController.MODE_TABLE;
+                lckMode = TransactionController.MODE_TABLE;
 			}
 
 			ResultDescription resultDescription = null;
@@ -442,7 +442,7 @@ class DeleteNode extends DMLModStatement
 				  deferred,
 				  false,
 				  targetTableDescriptor.getUUID(),
-				  lockMode,
+                  lckMode,
 				  null, null, null, 0, null, null, 
 				  resultDescription,
 				  getFKInfo(), 
@@ -795,7 +795,7 @@ class DeleteNode extends DMLModStatement
 
         fromList.addFromTable(fromTable);
 
-        SelectNode resultSet = new SelectNode(getSetClause(cdl),
+        SelectNode sn = new SelectNode(getSetClause(cdl),
                                               fromList, /* FROM list */
                                               whereClause, /* WHERE clause */
                                               null, /* GROUP BY list */
@@ -803,7 +803,7 @@ class DeleteNode extends DMLModStatement
                                               null, /* windows */
                                               getContextManager());
 
-        return new UpdateNode(tableName, resultSet, getContextManager());
+        return new UpdateNode(tableName, sn, getContextManager());
 
     }
 
@@ -927,7 +927,7 @@ class DeleteNode extends DMLModStatement
 			needsDeferredProcessing[0] = true;
 			
 			boolean needToIncludeAllColumns = false;
-            for (Iterator descIter = relevantTriggers.iterator();
+            for (Iterator<?> descIter = relevantTriggers.iterator();
                     descIter.hasNext(); ) {
                 TriggerDescriptor trd = (TriggerDescriptor)descIter.next();
 				//Does this trigger have REFERENCING clause defined on it.
@@ -964,12 +964,9 @@ class DeleteNode extends DMLModStatement
 		if ( correlationName == null ) { return; }
 
 		TableName	correlationNameNode = makeTableName( null, correlationName );
-		int			count = rcl.size();
 
-		for ( int i = 0; i < count; i++ )
+        for (ResultColumn column : rcl)
 		{
-			ResultColumn	column = (ResultColumn) rcl.elementAt( i );
-
 			ValueNode		expression = column.getExpression();
 
 			if ( (expression != null) && (expression instanceof ColumnReference) )

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java Fri Jun 28 04:32:08 2013
@@ -567,7 +567,7 @@ abstract	class ExpressionClassBuilder im
 	}	
 
 
-	FormatableArrayHolder getColumnOrdering(OrderedColumnList  oclist) {
+    FormatableArrayHolder getColumnOrdering(OrderedColumnList<?>  oclist) {
 		int numCols = (oclist == null) ? 0 : oclist.size();
 
 		if (numCols == 0)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FKConstraintDefinitionNode.java Fri Jun 28 04:32:08 2013
@@ -129,9 +129,8 @@ public final class FKConstraintDefinitio
 		}
 		else
 		{
-			for (int i=0; i<refRcl.size(); i++)
+            for (ResultColumn rc : refRcl)
 			{
-				ResultColumn rc = (ResultColumn) refRcl.elementAt(i);
 				ColumnDescriptor cd = td.getColumnDescriptor(rc.getName());
 				if (cd != null)
 				{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Fri Jun 28 04:32:08 2013
@@ -613,11 +613,8 @@ class FromBaseTable extends FromTable
 		baseCols = irg.baseColumnPositions();
 
 		/* First we check to see if this is a covering index */
-		int rclSize = resultColumns.size();
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : resultColumns)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
-
 			/* Ignore unreferenced columns */
 			if (! rc.isReferenced())
 			{
@@ -680,7 +677,7 @@ class FromBaseTable extends FromTable
 		boolean indexSpecified = false;
 		boolean constraintSpecified = false;
 		ConstraintDescriptor consDesc = null;
-		Enumeration e = tableProperties.keys();
+        Enumeration<?> e = tableProperties.keys();
 
         StringUtil.SQLEqualsIgnoreCase(tableDescriptor.getSchemaName(), "SYS");
 		while (e.hasMoreElements())
@@ -1354,10 +1351,9 @@ class FromBaseTable extends FromTable
                     // when the index is being considered by the optimizer.
                     IndexRowGenerator irg = cd.getIndexDescriptor();
                     if (irg.isUnique() 
-                        && irg.numberOfOrderedColumns() == 1 
-                        && startStopPredCount == 1) {
-                            statStartStopSelectivity = 
-                                (double)(1/(double)baseRowCount());
+                            && irg.numberOfOrderedColumns() == 1
+                            && startStopPredCount == 1) {
+                        statStartStopSelectivity = (1/(double)baseRowCount());
                     }
                 }
             }
@@ -2384,10 +2380,10 @@ class FromBaseTable extends FromTable
 				//sql accessing a view, we only need to look for select privilege
 				//on the actual view and that is what the following code is
 				//checking.
-				for (int i = 0; i < resultColumns.size(); i++) {
-					ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
-					if (rc.isPrivilegeCollectionRequired())
+                for (ResultColumn rc : resultColumns) {
+                    if (rc.isPrivilegeCollectionRequired()) {
 						compilerContext.addRequiredColumnPriv( rc.getTableColumnDescriptor());
+                    }
 				}
 
                 fsq = new FromSubquery(
@@ -3020,9 +3016,8 @@ class FromBaseTable extends FromTable
 		 * really need to completely disable bulk fetching here,
 		 * or can we do something else?
 		 */
-		for (int i = 0; i < restrictionList.size(); i++)
+        for (Predicate pred : restrictionList)
 		{
-			Predicate pred = (Predicate)restrictionList.elementAt(i);
 			if (pred.isInListProbePredicate() && pred.isStartKey())
 			{
 				disableBulkFetch();
@@ -4400,8 +4395,8 @@ class FromBaseTable extends FromTable
 		}
 
 		HashSet<ValueNode> columns = new HashSet<ValueNode>();
-		for (int i = 0; i < resultColumns.size(); i++) {
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
+
+        for (ResultColumn rc : resultColumns) {
 			columns.add(rc.getExpression());
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromList.java Fri Jun 28 04:32:08 2013
@@ -44,7 +44,8 @@ import org.apache.derby.iapi.util.String
  *
  */
 
-class FromList extends QueryTreeNodeVector implements OptimizableList
+class FromList extends    QueryTreeNodeVector<ResultSetNode>
+               implements OptimizableList
 {
 	Properties	properties;
 	// RESOLVE: The default should be false
@@ -79,7 +80,7 @@ class FromList extends QueryTreeNodeVect
      * @param cm context manager
      */
     FromList(ContextManager cm) {
-        super(cm);
+        super(ResultSetNode.class, cm);
         this.isTransparent = false;
         setNodeType(C_NodeTypes.FROM_LIST);
     }
@@ -94,7 +95,7 @@ class FromList extends QueryTreeNodeVect
 
     FromList(boolean optimizeJoinOrder, ContextManager cm)
 	{
-        super(cm);
+        super(ResultSetNode.class, cm);
         constructorMinion(optimizeJoinOrder);
 	}
 
@@ -111,7 +112,7 @@ class FromList extends QueryTreeNodeVect
              FromTable fromTable,
              ContextManager cm) throws StandardException
 	{
-        super(cm);
+        super(ResultSetNode.class, cm);
         constructorMinion(optimizeJoinOrder);
         addFromTable(fromTable);
 	}
@@ -199,7 +200,7 @@ class FromList extends QueryTreeNodeVect
 			}
 		}
 
-		addElement(fromTable);
+        addElement(fromTable);
 	}
 
 	/**
@@ -931,7 +932,7 @@ class FromList extends QueryTreeNodeVect
 		** there is nothing in this properties list that relies on binding
 		** or optimization to validate.
 		*/
-		Enumeration e = properties.keys();
+        Enumeration<?> e = properties.keys();
 		while (e.hasMoreElements())
 		{
 			String key = (String) e.nextElement();
@@ -1012,15 +1013,17 @@ class FromList extends QueryTreeNodeVect
 			*/
 			if (sum != ( ( joinOrder.length * (joinOrder.length - 1) ) / 2) )
 			{
-				String arrayVals = "";
-				for (int i = 0; i < joinOrder.length; i++)
-					arrayVals = arrayVals + joinOrder[i] + " ";
+                StringBuilder arrayVals = new StringBuilder();
+                for (int i : joinOrder) {
+                    arrayVals.append(i);
+                    arrayVals.append(' ');
+                }
 				SanityManager.THROWASSERT("joinOrder array has some duplicate value: " + arrayVals);
 			}
 		}
 
 		/* Form a list that's in the order we want */
-		QueryTreeNode[] orderedFL = new FromTable[joinOrder.length];
+        ResultSetNode[] orderedFL = new FromTable[joinOrder.length];
 		for (posn = 0; posn < joinOrder.length; posn++)
 		{
 			/*
@@ -1217,9 +1220,10 @@ class FromList extends QueryTreeNodeVect
 
 		PredicateList predicatesTemp;
         predicatesTemp = new PredicateList(getContextManager());
-		int wherePredicatesSize = wherePredicates.size();
-		for (int index = 0; index < wherePredicatesSize; index++)
-			predicatesTemp.addPredicate((Predicate)wherePredicates.elementAt(index));
+
+        for (Predicate p : wherePredicates) {
+            predicatesTemp.addPredicate(p);
+        }
 
 		/* When considering subquery flattening, we are interested
 		 * in the 1st (and only) entry in the RCL.  (The RCL will be
@@ -1229,7 +1233,7 @@ class FromList extends QueryTreeNodeVect
 		 */
 		if (rcl != null)
 		{
-			ResultColumn rc = (ResultColumn) rcl.elementAt(0);
+            ResultColumn rc = rcl.elementAt(0);
 			if (rc.getExpression() instanceof ColumnReference)
 			{
 				additionalCR = (ColumnReference) rc.getExpression();
@@ -1294,12 +1298,11 @@ class FromList extends QueryTreeNodeVect
 			if (fbt.getExistsBaseTable())
 			{
 				int existsTableNumber = fbt.getTableNumber();
-				int predicatesTempSize = predicatesTemp.size();
-				for (int predicatesTempIndex = predicatesTempSize-1;
-					predicatesTempIndex >= 0; predicatesTempIndex--)
+
+                for (int i = predicatesTemp.size() - 1; i >= 0; i--)
 				{
                     AndNode topAndNode =
-						((Predicate) predicatesTemp.elementAt(predicatesTempIndex)).getAndNode();
+                            predicatesTemp.elementAt(i).getAndNode();
 
 					for (ValueNode whereWalker = topAndNode; whereWalker instanceof AndNode;
 						whereWalker = ((AndNode) whereWalker).getRightOperand())
@@ -1319,7 +1322,7 @@ class FromList extends QueryTreeNodeVect
 						JBitSet referencedTables = and.getLeftOperand().getTablesReferenced();
 						if (referencedTables.get(existsTableNumber))
 						{
-							predicatesTemp.removeElementAt(predicatesTempIndex);
+                            predicatesTemp.removeElementAt(i);
 							break;
 						}
 					}
@@ -1593,7 +1596,7 @@ class FromList extends QueryTreeNodeVect
 					"size() expected to be 1");
 			}
 		}
-		return ((ResultSetNode) elementAt(0)).updateTargetLockMode();
+        return elementAt(0).updateTargetLockMode();
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromSubquery.java Fri Jun 28 04:32:08 2013
@@ -631,11 +631,8 @@ class FromSubquery extends FromTable
 
 		// Use visibleSize, because we don't want to propagate any order by
 		// columns not selected.
-		int rclSize = resultColumns.visibleSize();
-
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn resultColumn : resultColumns)
 		{
-			ResultColumn resultColumn = (ResultColumn) resultColumns.elementAt(index);
 			ValueNode		 valueNode;
 			String			 columnName;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromTable.java Fri Jun 28 04:32:08 2013
@@ -434,7 +434,8 @@ abstract class FromTable extends ResultS
 		 *		invalid value for hashLoadFactor
 		 *		invalid value for hashMaxCapacity
 		 */
-		Enumeration e = tableProperties.keys();
+        Enumeration<?> e = tableProperties.keys();
+
 		while (e.hasMoreElements())
 		{
 			String key = (String) e.nextElement();
@@ -748,8 +749,7 @@ abstract class FromTable extends ResultS
      * {@code false} otherwise
      */
     public boolean hasLargeObjectColumns() {
-        for (int i = 0; i < resultColumns.size(); i++) {
-            ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
+        for (ResultColumn rc : resultColumns) {
             if (rc.isReferenced()) {
                 DataTypeDescriptor type = rc.getType();
                 if (type != null && type.getTypeId().isLOBTypeId()) {
@@ -841,7 +841,7 @@ abstract class FromTable extends ResultS
             {
                 if (refCols.isSet(i))
                 {
-                    ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
+                    ResultColumn rc = resultColumns.elementAt(i);
                     DataTypeDescriptor expressionType = rc.getExpression().getTypeServices();
                     if( expressionType != null)
                         perRowUsage += expressionType.estimatedMemoryUsage();
@@ -1110,12 +1110,8 @@ abstract class FromTable extends ResultS
 												TableName tableName)
 			throws StandardException
 	{
-		ResultColumn	 resultColumn;
-		ValueNode		 valueNode;
-		String			 columnName;
 		TableName		 exposedName;
         TableName        toCompare;
-
 		/* If allTableName is non-null, then we must check to see if it matches
 		 * our exposed name.
 		 */
@@ -1148,24 +1144,21 @@ abstract class FromTable extends ResultS
 			exposedName = makeTableName(null, correlationName);
 		}
 
-        ResultColumnList rcList = new ResultColumnList((getContextManager()));
+        final ContextManager cm = getContextManager();
+        ResultColumnList rcList = new ResultColumnList(cm);
 
 		/* Build a new result column list based off of resultColumns.
 		 * NOTE: This method will capture any column renaming due to 
 		 * a derived column list.
 		 */
-		int inputSize = inputRcl.size();
-		for (int index = 0; index < inputSize; index++)
+        for (ResultColumn rc : inputRcl)
 		{
-			// Build a ResultColumn/ColumnReference pair for the column //
-			columnName = ((ResultColumn) inputRcl.elementAt(index)).getName();
-            valueNode = new ColumnReference(columnName,
-											exposedName,
-											getContextManager());
-            resultColumn =
-                new ResultColumn(columnName, valueNode, getContextManager());
-			// Build the ResultColumnList to return //
-			rcList.addResultColumn(resultColumn);
+            ResultColumn newRc = new ResultColumn(
+                    rc.getName(),
+                    new ColumnReference(rc.getName(), exposedName, cm),
+                    cm);
+
+            rcList.addResultColumn(newRc);
 		}
 		return rcList;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java Fri Jun 28 04:32:08 2013
@@ -765,7 +765,7 @@ class FromVTI extends FromTable implemen
         throws StandardException
     {
 		NewInvocationNode   constructor = (NewInvocationNode) methodCall;
-		Class[]  paramTypeClasses = constructor.getMethodParameterClasses();
+        Class<?>[]  paramTypeClasses = constructor.getMethodParameterClasses();
         Object[] paramObjects;
 
 		if (paramTypeClasses != null)
@@ -774,7 +774,7 @@ class FromVTI extends FromTable implemen
 
 			for (int index = 0; index < paramTypeClasses.length; index++)
 			{
-				Class paramClass = paramTypeClasses[index];
+                Class<?> paramClass = paramTypeClasses[index];
 
 				paramObjects[index] = methodParms[index].getConstantValueAsObject();
 
@@ -801,15 +801,15 @@ class FromVTI extends FromTable implemen
 				{
 					if (paramClass.equals(Integer.TYPE))
 					{
-						paramObjects[index] = new Integer(0);
+                        paramObjects[index] = Integer.valueOf(0);
 					}
 					else if (paramClass.equals(Short.TYPE))
 					{
-						paramObjects[index] = new Short((short) 0);
+                        paramObjects[index] = Short.valueOf((short) 0);
 					}
 					else if (paramClass.equals(Byte.TYPE))
 					{
-						paramObjects[index] = new Byte((byte) 0);
+                        paramObjects[index] = Byte.valueOf((byte)0);
 					}
 					else if (paramClass.equals(Long.TYPE))
 					{
@@ -837,7 +837,7 @@ class FromVTI extends FromTable implemen
 		}
 		else
 		{
-			paramTypeClasses = new Class[0];
+            paramTypeClasses = new Class<?>[0];
 			paramObjects = new Object[0];
 		}
 
@@ -845,7 +845,7 @@ class FromVTI extends FromTable implemen
         {
             ClassInspector classInspector = getClassFactory().getClassInspector();
             String javaClassName = methodCall.getJavaClassName();
-            Constructor constr = classInspector.getClass(javaClassName).getConstructor(paramTypeClasses);
+            Constructor<?> constr = classInspector.getClass(javaClassName).getConstructor(paramTypeClasses);
 
             return constr.newInstance(paramObjects);
         }
@@ -1037,9 +1037,6 @@ class FromVTI extends FromTable implemen
     ResultColumnList getAllResultColumns(TableName allTableName)
 			throws StandardException
 	{
-		ResultColumn	 resultColumn;
-		ValueNode		 valueNode;
-		String			 columnName;
         TableName        toCompare;
 
 		if(allTableName != null)
@@ -1053,32 +1050,25 @@ class FromVTI extends FromTable implemen
             return null;
         }
 
-        ResultColumnList rcList = new ResultColumnList((getContextManager()));
+        final ContextManager cm = getContextManager();
+        final ResultColumnList rcList = new ResultColumnList(cm);
 
 		/* Build a new result column list based off of resultColumns.
 		 * NOTE: This method will capture any column renaming due to 
 		 * a derived column list.
 		 */
-		int rclSize = resultColumns.size();
-		for (int index = 0; index < rclSize; index++)
+        for (ResultColumn rc : resultColumns)
 		{
-			resultColumn = (ResultColumn) resultColumns.elementAt(index);
-
-			if (resultColumn.isGenerated())
-			{
-				continue;
-			}
-
-			// Build a ResultColumn/ColumnReference pair for the column //
-			columnName = resultColumn.getName();
-            valueNode = new ColumnReference(columnName,
-											exposedName,
-											getContextManager());
-            resultColumn =
-                new ResultColumn(columnName, valueNode, getContextManager());
+            if (!rc.isGenerated()) {
+                // Build a ResultColumn/ColumnReference pair for the column //
+                ResultColumn newRc = new ResultColumn(
+                        rc.getName(),
+                        new ColumnReference(rc.getName(), exposedName, cm),
+                        cm);
 
-			// Build the ResultColumnList to return //
-			rcList.addResultColumn(resultColumn);
+                // Build the ResultColumnList to return //
+                rcList.addResultColumn(newRc);
+            }
 		}
 		return rcList;
 	}
@@ -1345,18 +1335,15 @@ class FromVTI extends FromTable implemen
     {
         if ( parentPredicates == null )  { return; }
 
-        int predicateCount = parentPredicates.size();
-
         // walk the list, looking for qualifiers, that is, WHERE clause
         // fragments (conjuncts)  which can be pushed into the table function
-        for ( int i = 0; i < predicateCount; i++ )
+        for (Predicate pp : parentPredicates)
         {
-            Predicate predicate = (Predicate) parentPredicates.elementAt( i );
-
-            if ( canBePushedDown( predicate ) )
+            if ( canBePushedDown( pp ) )
             {
                 // A Predicate has a top level AND node
-                Restriction newRestriction = makeRestriction( predicate.getAndNode(), columnNameMap );
+                Restriction newRestriction =
+                        makeRestriction( pp.getAndNode(), columnNameMap );
 
                 // If newRestriction is null, then we are confused. Don't push
                 // the restriction into the table function
@@ -1395,7 +1382,9 @@ class FromVTI extends FromTable implemen
      * @param clause The clause which should be turned into a Restriction.
      * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
      */
-    private Restriction makeRestriction( ValueNode clause, HashMap columnNameMap )
+    private Restriction makeRestriction(
+            ValueNode clause,
+            HashMap<String, String> columnNameMap )
         throws StandardException
     {
         if ( clause instanceof AndNode )
@@ -1441,8 +1430,9 @@ class FromVTI extends FromTable implemen
      * @param clause The clause which should be turned into a Restriction.
      * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
      */
-    private Restriction makeLeafRestriction( BinaryRelationalOperatorNode clause, HashMap columnNameMap )
-        throws StandardException
+    private Restriction makeLeafRestriction(
+            BinaryRelationalOperatorNode clause,
+            HashMap<String, String> columnNameMap) throws StandardException
     {
         int rawOperator = clause.getOperator();
         ColumnReference rawColumn;
@@ -1464,7 +1454,7 @@ class FromVTI extends FromTable implemen
         int comparisonOperator = mapOperator( rawOperator );
         if ( comparisonOperator < 0 ) { return iAmConfused( clause ); }
 
-        String columnName = (String) columnNameMap.get( rawColumn.getColumnName() );
+        String columnName = columnNameMap.get( rawColumn.getColumnName() );
         Object constantOperand = squeezeConstantValue( rawValue );
         if ( (columnName == null) || (constantOperand == null) ) { return iAmConfused( clause ); }
 
@@ -1477,8 +1467,9 @@ class FromVTI extends FromTable implemen
      * @param clause The IS NULL (or IS NOT NULL) node
      * @param columnNameMap Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
      */
-    private Restriction makeIsNullRestriction( IsNullNode clause, HashMap columnNameMap )
-        throws StandardException
+    private Restriction makeIsNullRestriction(
+            IsNullNode clause,
+            HashMap<String, String> columnNameMap) throws StandardException
     {
         ColumnReference rawColumn = (ColumnReference) clause.getOperand();
 
@@ -1489,7 +1480,7 @@ class FromVTI extends FromTable implemen
             (comparisonOperator != Restriction.ColumnQualifier.ORDER_OP_ISNOTNULL)
             ) { return iAmConfused( clause ); }
 
-        String columnName = (String) columnNameMap.get( rawColumn.getColumnName() );
+        String columnName = columnNameMap.get( rawColumn.getColumnName() );
         if ( columnName == null ) { return iAmConfused( clause ); }
 
         return new Restriction.ColumnQualifier( columnName, comparisonOperator, null );
@@ -1646,7 +1637,7 @@ class FromVTI extends FromTable implemen
 
 		for (int index = 0; index < rclSize; index++)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(index);
+            ResultColumn rc = resultColumns.elementAt(index);
 			if (rc.isReferenced())
 			{
 				referencedCols.set(index);
@@ -2014,7 +2005,7 @@ class FromVTI extends FromTable implemen
     private boolean implementsDerbyStyleVTICosting( String className )
         throws StandardException
     {
-        Constructor     constructor = null;
+        Constructor<?>     constructor = null;
         Class<?>           vtiClass = lookupClass( className );
         Class<?>           vtiCostingClass = lookupClass( VTICosting.class.getName() );
 
@@ -2027,7 +2018,7 @@ class FromVTI extends FromTable implemen
         }
 
         try {
-            constructor = vtiClass.getConstructor( new Class[] {} );
+            constructor = vtiClass.getConstructor( new Class<?>[] {} );
         }
         catch (Throwable t)
         {
@@ -2055,7 +2046,8 @@ class FromVTI extends FromTable implemen
         Class<?>               vtiClass = lookupClass( className );
         
         try {
-            Constructor         constructor = vtiClass.getConstructor( new Class[] {} );
+            Constructor<?> constructor =
+                    vtiClass.getConstructor( new Class<?>[] {} );
             VTICosting          result =
                     (VTICosting) constructor.newInstance( (Object[])null );
 
@@ -2070,7 +2062,7 @@ class FromVTI extends FromTable implemen
     /**
      * Lookup the class that holds the VTI.
      */
-    private Class lookupClass( String className )
+    private Class<?> lookupClass( String className )
         throws StandardException
     {
         try {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByList.java Fri Jun 28 04:32:08 2013
@@ -35,13 +35,13 @@ import org.apache.derby.iapi.sql.compile
  *
  */
 
-class GroupByList extends OrderedColumnList
+class GroupByList extends OrderedColumnList<GroupByColumn>
 {
 	int		numGroupingColsAdded = 0;
 	boolean         rollup = false;
 
     public GroupByList(ContextManager cm) {
-        super(cm);
+        super(GroupByColumn.class, cm);
         setNodeType(C_NodeTypes.GROUP_BY_LIST);
     }
 
@@ -69,7 +69,7 @@ class GroupByList extends OrderedColumnL
 					"position (" + position +
 					") expected to be between 0 and " + size());
 		}
-		return (GroupByColumn) elementAt(position);
+        return elementAt(position);
 	}
 
 
@@ -114,35 +114,32 @@ class GroupByList extends OrderedColumnL
 		ResultColumnList selectRCL = select.getResultColumns();
         SubqueryList dummySubqueryList = new SubqueryList(getContextManager());
 		int				 numColsAddedHere = 0;
-		int				 size = size();
 
 		/* Only 32677 columns allowed in GROUP BY clause */
-		if (size > Limits.DB2_MAX_ELEMENTS_IN_GROUP_BY)
+        if (size() > Limits.DB2_MAX_ELEMENTS_IN_GROUP_BY)
 		{
 			throw StandardException.newException(SQLState.LANG_TOO_MANY_ELEMENTS);
 		}
 
 		/* Bind the grouping column */
-		for (int index = 0; index < size; index++)
+        for (GroupByColumn groupByCol : this)
 		{
-			GroupByColumn groupByCol = (GroupByColumn) elementAt(index);
 			groupByCol.bindExpression(fromList,
                                       dummySubqueryList, aggregates);
 		}
 
 		
 		int				rclSize = selectRCL.size();
-		for (int index = 0; index < size; index++)
+        for (GroupByColumn groupingCol : this)
 		{
 			boolean				matchFound = false;
-			GroupByColumn		groupingCol = (GroupByColumn) elementAt(index);
 
 			/* Verify that this entry in the GROUP BY list matches a
 			 * grouping column in the select list.
 			 */
 			for (int inner = 0; inner < rclSize; inner++)
 			{
-				ResultColumn selectListRC = (ResultColumn) selectRCL.elementAt(inner);
+                ResultColumn selectListRC = selectRCL.elementAt(inner);
 				if (!(selectListRC.getExpression() instanceof ColumnReference)) {
 					continue;
 				}
@@ -242,10 +239,8 @@ class GroupByList extends OrderedColumnL
     GroupByColumn findGroupingColumn(ValueNode node)
 	        throws StandardException
 	{
-		int sz = size();
-		for (int i = 0; i < sz; i++) 
+        for (GroupByColumn gbc : this)
 		{
-			GroupByColumn gbc = (GroupByColumn)elementAt(i);
 			if (gbc.getColumnExpression().isEquivalent(node))
 			{
 				return gbc;
@@ -262,20 +257,15 @@ class GroupByList extends OrderedColumnL
 	 */
     void remapColumnReferencesToExpressions() throws StandardException
 	{
-		GroupByColumn	gbc;
-		int				size = size();
-
 		/* This method is called when flattening a FromTable.  We should
 		 * not be flattening a FromTable if the underlying expression that
 		 * will get returned out, after chopping out the redundant ResultColumns,
 		 * is not a ColumnReference.  (See ASSERT below.)
 		 */
-		for (int index = 0; index < size; index++)
+        for (GroupByColumn gbc : this)
 		{
-			ValueNode	retVN;
-			gbc = (GroupByColumn) elementAt(index);
-
-			retVN = gbc.getColumnExpression().remapColumnReferencesToExpressions();
+            ValueNode retVN =
+                gbc.getColumnExpression().remapColumnReferencesToExpressions();
 
 			if (SanityManager.DEBUG)
 			{
@@ -307,15 +297,15 @@ class GroupByList extends OrderedColumnL
 	}
 
 
-    void preprocess(
-			int numTables, FromList fromList, SubqueryList whereSubquerys, 
-			PredicateList wherePredicates) throws StandardException 
+    void preprocess(int numTables,
+                    FromList fromList,
+                    SubqueryList whereSubquerys,
+                    PredicateList wherePredicates) throws StandardException
 	{
-		for (int index = 0; index < size(); index++)
+        for (GroupByColumn gbc : this)
 		{
-			GroupByColumn	groupingCol = (GroupByColumn) elementAt(index);
-			groupingCol.setColumnExpression(
-					groupingCol.getColumnExpression().preprocess(
+            gbc.setColumnExpression(
+                    gbc.getColumnExpression().preprocess(
 							numTables, fromList, whereSubquerys, wherePredicates));
 		}		
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/GroupByNode.java Fri Jun 28 04:32:08 2013
@@ -103,7 +103,7 @@ class GroupByNode extends SingleChildRes
 	private int		addDistinctAggregateColumnNum;
 
 	// Is the source in sorted order
-	private boolean isInSortedOrder;
+    final private boolean isInSortedOrder;
 
 	private ValueNode havingClause;
 	
@@ -201,23 +201,23 @@ class GroupByNode extends SingleChildRes
 			int index;
 			for (index = 0; index < glSize; index++)
 			{
-				GroupByColumn gc =
-						(GroupByColumn) this.groupingList.elementAt(index);
+                GroupByColumn gc = this.groupingList.elementAt(index);
 				if (gc.getColumnExpression() instanceof ColumnReference) 
 				{
 					crs[index] = (ColumnReference)gc.getColumnExpression();
 				} 
 				else 
 				{
-					isInSortedOrder = false;
 					break;
 				}
 				
 			}
-			if (index == glSize) {
-				isInSortedOrder = childResult.isOrderedOn(crs, true, (List<FromBaseTable>)null);
-			}
-		}
+
+            isInSortedOrder = (index == glSize) &&
+                childResult.isOrderedOn(crs, true, (List<FromBaseTable>)null);
+        } else {
+            isInSortedOrder = false;
+        }
 	}
 
 	/**
@@ -293,10 +293,9 @@ class GroupByNode extends SingleChildRes
 		** Get the new PR, put above the GroupBy.  
 		*/
         ResultColumnList rclNew = new ResultColumnList((getContextManager()));
-		int sz = resultColumns.size();
-		for (int i = 0; i < sz; i++) 
+
+        for (ResultColumn rc : resultColumns)
 		{
-			ResultColumn rc = (ResultColumn) resultColumns.elementAt(i);
 			if (!rc.isGenerated()) {
 				rclNew.addElement(rc);
 			}
@@ -350,10 +349,9 @@ class GroupByNode extends SingleChildRes
 		ArrayList<SubstituteExpressionVisitor> havingRefsToSubstitute = null;
 		if (havingClause != null)
 			havingRefsToSubstitute = new ArrayList<SubstituteExpressionVisitor>();
-		int sz = groupingList.size();
-		for (int i = 0; i < sz; i++) 
+
+        for (GroupByColumn gbc : groupingList)
 		{
-			GroupByColumn gbc = (GroupByColumn) groupingList.elementAt(i);
             ResultColumn newRC = new ResultColumn(
                     "##UnaggColumn",
 					gbc.getColumnExpression(),
@@ -780,14 +778,12 @@ class GroupByNode extends SingleChildRes
 			throws StandardException
 	{
 		// RESOLVE: NEED TO FACTOR IN THE COST OF GROUPING (SORTING) HERE
-		CostEstimate childCost = ((Optimizable) childResult).optimizeIt(
-													optimizer,
-													predList,
-													outerCost,
-													rowOrdering);
+        ((Optimizable) childResult).optimizeIt( optimizer,
+                                                predList,
+                                                outerCost,
+                                                rowOrdering);
 
-		CostEstimate retval = super.optimizeIt(
-												optimizer,
+        CostEstimate retval = super.optimizeIt( optimizer,
 												predList,
 												outerCost,
 												rowOrdering

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HalfOuterJoinNode.java Fri Jun 28 04:32:08 2013
@@ -222,7 +222,7 @@ class HalfOuterJoinNode extends JoinNode
 		{
 			Predicate predicate;
 
-			predicate = (Predicate) joinPredicates.elementAt(index);
+            predicate = joinPredicates.elementAt(index);
 			if (! predicate.getPushable())
 			{
 				continue;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java?rev=1497644&r1=1497643&r2=1497644&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasNodeVisitor.java Fri Jun 28 04:32:08 2013
@@ -36,15 +36,15 @@ import org.apache.derby.iapi.sql.compile
 class HasNodeVisitor implements Visitor
 {
 	protected boolean hasNode;
-	private Class 	nodeClass;
-	private Class	skipOverClass;
+    private Class<?> nodeClass;
+    private Class<?> skipOverClass;
 	/**
 	 * Construct a visitor
 	 *
 	 * @param nodeClass the class of the node that 
 	 * 	we are looking for.
 	 */
-    HasNodeVisitor(Class nodeClass)
+    HasNodeVisitor(Class<?> nodeClass)
 	{
 		this.nodeClass = nodeClass;
 	}
@@ -57,7 +57,7 @@ class HasNodeVisitor implements Visitor
 	 * @param skipOverClass do not go below this
 	 * node when searching for nodeClass.
 	 */
-    HasNodeVisitor(Class nodeClass, Class skipOverClass)
+    HasNodeVisitor(Class<?> nodeClass, Class<?> skipOverClass)
 	{
 		this.nodeClass = nodeClass;
 		this.skipOverClass = skipOverClass;



Mime
View raw message