cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r599905 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: access/ access/jdbc/ dba/ dba/oracle/
Date Fri, 30 Nov 2007 18:54:48 GMT
Author: aadamchik
Date: Fri Nov 30 10:54:46 2007
New Revision: 599905

URL: http://svn.apache.org/viewvc?rev=599905&view=rev
Log:
cleanup: generics

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OperationObserver.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleProcedureAction.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OperationObserver.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OperationObserver.java?rev=599905&r1=599904&r2=599905&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OperationObserver.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/OperationObserver.java
Fri Nov 30 10:54:46 2007
@@ -22,6 +22,7 @@
 
 import java.util.List;
 
+import org.apache.cayenne.DataRow;
 import org.apache.cayenne.query.Query;
 
 /**
@@ -48,7 +49,7 @@
     /**
      * Callback method invoked for each processed ResultSet.
      */
-    public void nextDataRows(Query query, List dataRows);
+    public void nextDataRows(Query query, List<DataRow> dataRows);
 
     /**
      * Callback method invoked for each opened ResultIterator. If this observer requested

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java?rev=599905&r1=599904&r2=599905&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
Fri Nov 30 10:54:46 2007
@@ -24,11 +24,10 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.QueryLogger;
 import org.apache.cayenne.access.trans.ProcedureTranslator;
@@ -184,7 +183,7 @@
         long t1 = System.currentTimeMillis();
 
         // build result row...
-        Map result = null;
+        DataRow result = null;
         List parameters = getProcedure().getCallParameters();
         for (int i = 0; i < parameters.size(); i++) {
             ProcedureParameter parameter = (ProcedureParameter) parameters.get(i);
@@ -194,7 +193,7 @@
             }
 
             if (result == null) {
-                result = new HashMap();
+                result = new DataRow(2);
             }
 
             ColumnDescriptor descriptor = new ColumnDescriptor(parameter);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java?rev=599905&r1=599904&r2=599905&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
Fri Nov 30 10:54:46 2007
@@ -212,7 +212,7 @@
         return getAdapter().createTable(entity);
     }
 
-    public String createUniqueConstraint(DbEntity source, Collection columns) {
+    public String createUniqueConstraint(DbEntity source, Collection<DbAttribute> columns)
{
         return getAdapter().createUniqueConstraint(source, columns);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java?rev=599905&r1=599904&r2=599905&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcPkGenerator.java
Fri Nov 30 10:54:46 2007
@@ -29,11 +29,11 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.QueryLogger;
@@ -55,10 +55,10 @@
 
     public static final int DEFAULT_PK_CACHE_SIZE = 20;
 
-    protected Map pkCache = new HashMap();
+    protected Map<String, PkRange> pkCache = new HashMap<String, PkRange>();
     protected int pkCacheSize = DEFAULT_PK_CACHE_SIZE;
 
-    public void createAutoPk(DataNode node, List dbEntities) throws Exception {
+    public void createAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
{
         // check if a table exists
 
         // create AUTO_PK_SUPPORT table
@@ -70,22 +70,18 @@
         runUpdate(node, pkDeleteString(dbEntities));
 
         // insert all needed entries
-        Iterator it = dbEntities.iterator();
-        while (it.hasNext()) {
-            DbEntity ent = (DbEntity) it.next();
+        for (DbEntity ent : dbEntities) {
             runUpdate(node, pkCreateString(ent.getName()));
         }
     }
 
-    public List createAutoPkStatements(List dbEntities) {
-        List list = new ArrayList();
+    public List<String> createAutoPkStatements(List<DbEntity> dbEntities) {
+        List<String> list = new ArrayList<String>(dbEntities.size() + 2);
 
         list.add(pkTableCreateString());
         list.add(pkDeleteString(dbEntities));
 
-        Iterator it = dbEntities.iterator();
-        while (it.hasNext()) {
-            DbEntity ent = (DbEntity) it.next();
+        for (DbEntity ent : dbEntities) {
             list.add(pkCreateString(ent.getName()));
         }
 
@@ -95,14 +91,14 @@
     /**
      * Drops table named "AUTO_PK_SUPPORT" if it exists in the database.
      */
-    public void dropAutoPk(DataNode node, List dbEntities) throws Exception {
+    public void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception
{
         if (autoPkTableExists(node)) {
             runUpdate(node, dropAutoPkString());
         }
     }
 
-    public List dropAutoPkStatements(List dbEntities) {
-        List list = new ArrayList();
+    public List<String> dropAutoPkStatements(List<DbEntity> dbEntities) {
+        List<String> list = new ArrayList<String>(1);
         list.add(dropAutoPkString());
         return list;
     }
@@ -119,7 +115,7 @@
         return buf.toString();
     }
 
-    protected String pkDeleteString(List dbEntities) {
+    protected String pkDeleteString(List<DbEntity> dbEntities) {
         StringBuffer buf = new StringBuffer();
         buf.append("DELETE FROM AUTO_PK_SUPPORT WHERE TABLE_NAME IN (");
         int len = dbEntities.size();
@@ -127,7 +123,7 @@
             if (i > 0) {
                 buf.append(", ");
             }
-            DbEntity ent = (DbEntity) dbEntities.get(i);
+            DbEntity ent = dbEntities.get(i);
             buf.append('\'').append(ent.getName()).append('\'');
         }
         buf.append(')');
@@ -243,10 +239,10 @@
         }
 
         synchronized (pkCache) {
-            PkRange r = (PkRange) pkCache.get(ent.getName());
+            PkRange r = pkCache.get(ent.getName());
 
             if (r == null) {
-                // created exhaused PkRange
+                // created exhausted PkRange
                 r = new PkRange(1, 0);
                 pkCache.put(ent.getName(), r);
             }
@@ -263,7 +259,7 @@
     /**
      * @return a binary PK if DbEntity has a BINARY or VARBINARY pk, null otherwise. This
      *         method will likely be deprecated in 1.1 in favor of a more generic
-     *         soultion.
+     *         solution.
      * @since 1.0.2
      */
     protected byte[] binaryPK(DbEntity entity) {
@@ -297,7 +293,7 @@
                 + '\'';
 
         // run queries via DataNode to utilize its transactional behavior
-        List queries = new ArrayList(2);
+        List<Query> queries = new ArrayList<Query>(2);
         queries.add(new SQLTemplate(ent, select));
         queries.add(new SQLTemplate(ent, pkUpdateString(ent.getName())));
 
@@ -358,7 +354,7 @@
             return id.intValue();
         }
 
-        public void nextDataRows(Query query, List dataRows) {
+        public void nextDataRows(Query query, List<DataRow> dataRows) {
 
             // process selected object, issue an update query
             if (dataRows == null || dataRows.size() == 0) {
@@ -371,7 +367,7 @@
                         "Error generating PK : too many rows for entity: " + entityName);
             }
 
-            Map lastPk = (Map) dataRows.get(0);
+            DataRow lastPk = dataRows.get(0);
             id = (Number) lastPk.get("NEXT_ID");
         }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java?rev=599905&r1=599904&r2=599905&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/PkGenerator.java
Fri Nov 30 10:54:46 2007
@@ -36,33 +36,33 @@
      * Generates necessary database objects to provide automatic primary key support.
      * 
      * @param node node that provides access to a DataSource.
-     * @param dbEntities a list of entities that require primary key autogeneration
+     * @param dbEntities a list of entities that require primary key auto-generation
      *            support
      */
-    void createAutoPk(DataNode node, List dbEntities) throws Exception;
+    void createAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception;
 
     /**
      * Returns a list of SQL strings needed to generates database objects to provide
      * automatic primary support for the list of entities. No actual database operations
      * are performed.
      */
-    List createAutoPkStatements(List dbEntities);
+    List<String> createAutoPkStatements(List<DbEntity> dbEntities);
 
     /**
      * Drops any common database objects associated with automatic primary key generation
      * process. This may be lookup tables, special stored procedures or sequences.
      * 
      * @param node node that provides access to a DataSource.
-     * @param dbEntities a list of entities whose primary key autogeneration support
+     * @param dbEntities a list of entities whose primary key auto-generation support
      *            should be dropped.
      */
-    void dropAutoPk(DataNode node, List dbEntities) throws Exception;
+    void dropAutoPk(DataNode node, List<DbEntity> dbEntities) throws Exception;
 
     /**
      * Returns SQL string needed to drop database objects associated with automatic
      * primary key generation. No actual database operations are performed.
      */
-    List dropAutoPkStatements(List dbEntities);
+    List<String> dropAutoPkStatements(List<DbEntity> dbEntities);
 
     /**
      * Generates new (unique and non-repeating) primary key for specified DbEntity.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleProcedureAction.java?rev=599905&r1=599904&r2=599905&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleProcedureAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleProcedureAction.java
Fri Nov 30 10:54:46 2007
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.QueryLogger;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
@@ -61,7 +62,7 @@
         long t1 = System.currentTimeMillis();
 
         // build result row...
-        Map result = null;
+        DataRow result = null;
         List parameters = getProcedure().getCallParameters();
         for (int i = 0; i < parameters.size(); i++) {
             ProcedureParameter parameter = (ProcedureParameter) parameters.get(i);
@@ -91,7 +92,7 @@
             // ==== end Oracle-specific part
             else {
                 if (result == null) {
-                    result = new HashMap();
+                    result = new DataRow(2);
                 }
 
                 ColumnDescriptor descriptor = new ColumnDescriptor(parameter);



Mime
View raw message