db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1485984 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: compile/CursorNode.java compile/sqlgrammar.jj execute/TriggerEventActivator.java
Date Fri, 24 May 2013 09:28:29 GMT
Author: kahatlen
Date: Fri May 24 09:28:29 2013
New Revision: 1485984

URL: http://svn.apache.org/r1485984
Log:
DERBY-5840: Clean up compiler warnings introduced by using Java 5 language features

Fix compiler warning in CursorNode.init() by changing parameter from
List<String> to String[] so that the cast from Object can be checked.

Fix compiler warning in TriggerEventActivator by using a List instead
of an array to store generic types.

Modified:
    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/sqlgrammar.jj
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEventActivator.java

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=1485984&r1=1485983&r2=1485984&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
May 24 09:28:29 2013
@@ -22,6 +22,7 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.derby.iapi.error.StandardException;
@@ -91,13 +92,12 @@ public class CursorNode extends DMLState
 	 * @param hasJDBClimitClause True if the offset/fetchFirst clauses come from JDBC limit/offset
escape syntax
 	 * @param updateMode	The user-specified update mode for the cursor,
 	 *			for example, CursorNode.READ_ONLY
-	 * @param updatableColumns The list of updatable columns specified by
+     * @param updatableColumns The array of updatable columns specified by
 	 *			the user in the FOR UPDATE clause, null if no
 	 *			updatable columns specified.  May only be
 	 *			provided if the updateMode parameter is
 	 *			CursorNode.UPDATE.
 	 */
-    @SuppressWarnings("unchecked")
 	public	void init(
 		Object statementType,
 		Object resultSet,
@@ -118,7 +118,9 @@ public class CursorNode extends DMLState
         this.hasJDBClimitClause = (hasJDBClimitClause == null) ? false : ((Boolean) hasJDBClimitClause).booleanValue();
 
 		this.updateMode = ((Integer) updateMode).intValue();
-		this.updatableColumns = (List<String>) updatableColumns;
+        this.updatableColumns =
+                updatableColumns == null ?
+                null : Arrays.asList((String[]) updatableColumns);
 
 		/*
 		** This is a sanity check and not an error since the parser

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1485984&r1=1485983&r2=1485984&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri May
24 09:28:29 2013
@@ -3347,7 +3347,9 @@ preparableSelectStatement(boolean checkP
 				offsetClauses[ FETCH_FIRST_CLAUSE ],
                 Boolean.valueOf( hasJDBClimitClause ),
 				ReuseFactory.getInteger(forUpdateState),
-				(forUpdateState == CursorNode.READ_ONLY ? null : updateColumns ),
+                forUpdateState == CursorNode.READ_ONLY ?
+                    null :
+                    updateColumns.toArray(new String[updateColumns.size()]),
 				getContextManager());
 
 		if (checkParams)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEventActivator.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEventActivator.java?rev=1485984&r1=1485983&r2=1485984&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEventActivator.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TriggerEventActivator.java
Fri May 24 09:28:29 2013
@@ -21,6 +21,8 @@
 
 package org.apache.derby.impl.sql.execute;
 
+import java.util.ArrayList;
+import java.util.List;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.error.StandardException;
 
@@ -128,21 +130,15 @@ public class TriggerEventActivator
 								);
 		setupExecutors(triggerInfo);
 	}
-
-    /** Perform the cast needed to a list of triggers from the executorLists */
-    @SuppressWarnings("unchecked")
-    private Vector<TriggerDescriptor>   getTriggers( int idx, Vector[] executorLists
)
-    {
-        return (Vector<TriggerDescriptor>) executorLists[ idx ];
-    }
     
 	private void setupExecutors(TriggerInfo triggerInfo) throws StandardException
 	{
 		executors = new GenericTriggerExecutor[TriggerEvent.MAX_EVENTS][];
-		Vector[] executorLists = new Vector[TriggerEvent.MAX_EVENTS];
+        List<List<TriggerDescriptor>> executorLists =
+            new ArrayList<List<TriggerDescriptor>>(TriggerEvent.MAX_EVENTS);
 		for (int i = 0; i < TriggerEvent.MAX_EVENTS; i++)
 		{
-			executorLists[i] = new Vector<TriggerDescriptor>();
+            executorLists.add(new ArrayList<TriggerDescriptor>());
 		}
 
 		for (int i = 0; i < triggerInfo.triggerArray.length; i++)
@@ -153,11 +149,11 @@ public class TriggerEventActivator
 				case TriggerDescriptor.TRIGGER_EVENT_INSERT:
 					if (td.isBeforeTrigger())
 					{
-						getTriggers( TriggerEvent.BEFORE_INSERT, executorLists ).addElement( td );
+                        executorLists.get(TriggerEvent.BEFORE_INSERT).add(td);
 					}
 					else
 					{
-						getTriggers( TriggerEvent.AFTER_INSERT, executorLists ).addElement( td );
+                        executorLists.get(TriggerEvent.AFTER_INSERT).add(td);
 					}
 					break;
 
@@ -165,22 +161,22 @@ public class TriggerEventActivator
 				case TriggerDescriptor.TRIGGER_EVENT_DELETE:
 					if (td.isBeforeTrigger())
 					{
-						getTriggers( TriggerEvent.BEFORE_DELETE, executorLists ).addElement( td );
+                        executorLists.get(TriggerEvent.BEFORE_DELETE).add(td);
 					}
 					else
 					{
-						getTriggers( TriggerEvent.AFTER_DELETE, executorLists ).addElement( td );
+                        executorLists.get(TriggerEvent.AFTER_DELETE).add(td);
 					}
 					break;
 
 				case TriggerDescriptor.TRIGGER_EVENT_UPDATE:
 					if (td.isBeforeTrigger())
 					{
-						getTriggers( TriggerEvent.BEFORE_UPDATE, executorLists ).addElement( td );
+                        executorLists.get(TriggerEvent.BEFORE_UPDATE).add(td);
 					}
 					else
 					{
-						getTriggers( TriggerEvent.AFTER_UPDATE, executorLists ).addElement( td );
+                        executorLists.get(TriggerEvent.AFTER_UPDATE).add(td);
 					}
 					break;
 				default:
@@ -191,15 +187,16 @@ public class TriggerEventActivator
 			}
 		}
 
-		for (int i = 0; i < executorLists.length; i++)
+        for (int i = 0; i < executorLists.size(); i++)
 		{
-			int size = executorLists[i].size();
+            List<TriggerDescriptor> descriptors = executorLists.get(i);
+            int size = descriptors.size();
 			if (size > 0)
 			{
 				executors[i] = new GenericTriggerExecutor[size];
 				for (int j = 0; j < size; j++)
 				{
-					TriggerDescriptor td = (TriggerDescriptor)executorLists[i].elementAt(j);
+                    TriggerDescriptor td = descriptors.get(j);
 					executors[i][j] =  (td.isRowTrigger()) ? 
 								(GenericTriggerExecutor)new RowTriggerExecutor(tec, td, activation, lcc) :
 								(GenericTriggerExecutor)new StatementTriggerExecutor(tec, td, activation, lcc);



Mime
View raw message