empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1057056 - in /incubator/empire-db/trunk: empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db/src/main/java/org/apache/empire/db/ empire-db/src/test/java/org/apache/empire/db/
Date Sun, 09 Jan 2011 23:30:02 GMT
Author: doebele
Date: Sun Jan  9 23:30:01 2011
New Revision: 1057056

URL: http://svn.apache.org/viewvc?rev=1057056&view=rev
Log:
EMPIREDB-95

Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
Sun Jan  9 23:30:01 2011
@@ -426,8 +426,8 @@ public class SampleAdvApp 
         // create a command
         DBCommand cmd = db.createCommand();
         // Create cmd parameters
-        DBCommandParam curDepParam = cmd.addCmdParam(); // Current Department
-        DBCommandParam genderParam = cmd.addCmdParam(); // Gender ('M' or 'F')
+        DBCommandParam curDepParam = cmd.addParam(); // Current Department
+        DBCommandParam genderParam = cmd.addParam(); // Gender ('M' or 'F')
         // Define the query
         cmd.select(T_EMP.C_FULLNAME);
         cmd.join  (T_EMP.C_EMPLOYEE_ID, db.V_EMPLOYEE_INFO.C_EMPLOYEE_ID);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
Sun Jan  9 23:30:01 2011
@@ -97,10 +97,10 @@ public class DBCombinedCmd extends DBCom
     * @return the list of parameter values for a prepared statement 
     */
    @Override
-   public Object[] getCmdParamValues()
+   public Object[] getParamValues()
    {
-       Object[] leftParams  = left.getCmdParamValues();
-       Object[] rightParams = right.getCmdParamValues();
+       Object[] leftParams  = left.getParamValues();
+       Object[] rightParams = right.getParamValues();
        // Check
        if (leftParams==null)
            return rightParams;
@@ -161,7 +161,6 @@ public class DBCombinedCmd extends DBCom
       }
    }
 
-
 }
 
 

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
Sun Jan  9 23:30:01 2011
@@ -356,7 +356,7 @@ public abstract class DBCommand extends 
         }
         // Replace with parameter 
         if (useCmdParam(expr.column) && (expr.value instanceof DBExpr)==false)
-            expr.value = addCmdParam(expr.column.getDataType(), expr.value);
+            expr.value = addParam(expr.column.getDataType(), expr.value);
         // new Value!
         set.add(expr);
     }
@@ -389,7 +389,7 @@ public abstract class DBCommand extends 
      * 
      * @return the command parameter object 
      */
-    public DBCommandParam addCmdParam(DataType type, Object value)
+    public DBCommandParam addParam(DataType type, Object value)
     {
         if (cmdParams==null)
             cmdParams= new Vector<DBCommandParam>();
@@ -410,9 +410,9 @@ public abstract class DBCommand extends 
      * 
      * @return the command parameter object 
      */
-    public final DBCommandParam addCmdParam(DBColumnExpr colExpr, Object value)
+    public final DBCommandParam addParam(DBColumnExpr colExpr, Object value)
     {
-        return addCmdParam(colExpr.getDataType(), value);
+        return addParam(colExpr.getDataType(), value);
     }
 
     /**
@@ -421,9 +421,9 @@ public abstract class DBCommand extends 
      *  
      * @return the command parameter object
      */
-    public final DBCommandParam addCmdParam(Object value)
+    public final DBCommandParam addParam(Object value)
     {
-        return addCmdParam(DataType.UNKNOWN, value);
+        return addParam(DataType.UNKNOWN, value);
     }
 
     /**
@@ -432,9 +432,9 @@ public abstract class DBCommand extends 
      *  
      * @return the command parameter object
      */
-    public final DBCommandParam addCmdParam()
+    public final DBCommandParam addParam()
     {
-        return addCmdParam(DataType.UNKNOWN, null);
+        return addParam(DataType.UNKNOWN, null);
     }
 
     /**
@@ -915,11 +915,12 @@ public abstract class DBCommand extends 
     } 
     
     /**
-     * Returns the list of parameter values for a prepared statement.
-     * @return the list of parameter values for a prepared statement 
+     * Returns an array of parameter values for a prepared statement.
+     * To ensure that all values are in the order of their occurrence, getSelect() should
be called first.
+     * @return an array of parameter values for a prepared statement 
      */
     @Override
-    public Object[] getCmdParamValues()
+    public Object[] getParamValues()
     {
         if (cmdParams==null || cmdParams.size()==0)
             return null;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
Sun Jan  9 23:30:01 2011
@@ -304,9 +304,17 @@ public abstract class DBCommandExpr exte
 
     public abstract DBColumnExpr[] getSelectExprList();
     
-    public abstract Object[] getCmdParamValues();
+    /**
+     * returns an array holding all parameter values in the order of their occurrence.
+     * To ensure the correct order, getSelect() should be called first.
+     * @return an array of command parameter values 
+     */
+    public abstract Object[] getParamValues();
 
-    public DBColumnExpr getCmdColumn(DBColumnExpr col)
+    /**
+     * returns column expression that is specific for to this command and detached from its
source.
+     */
+    protected DBColumnExpr getCmdColumn(DBColumnExpr col)
     {
         // Check the Instance of col
         if ((col instanceof DBCmdColumn))
@@ -324,14 +332,6 @@ public abstract class DBCommandExpr exte
         return new DBCmdColumn(cmdQuery, col);
     }
 
-    public DBColumnExpr getCmdColumn(int i)
-    {
-        DBColumnExpr[] list = getSelectExprList();
-        if (i >= list.length)
-            return null;
-        return getCmdColumn(list[i]);
-    }
-
     /**
      * returns an SQL select command for querying records.
      * @return the SQL-Command
@@ -357,7 +357,7 @@ public abstract class DBCommandExpr exte
     protected void addListExpr(StringBuilder buf, List<? extends DBExpr> list, long
context, String separator)
     {
         for (int i = 0; i < list.size(); i++)
-        { // Selectfelder zusammenbauen
+        {   // assemble select columns
             if (i > 0)
                 buf.append(separator);
             list.get(i).addSQL(buf, context);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java Sun
Jan  9 23:30:01 2011
@@ -359,7 +359,7 @@ public class DBQuery extends DBRowSet
         {   // Set key column constraint
             Object value = key[i];
             if (db.isPreparedStatementsEnabled())
-                value = cmd.addCmdParam(keyColumns[i], value);
+                value = cmd.addParam(keyColumns[i], value);
             cmd.where(keyColumns[i].is(value));
         }    
         // Read Record
@@ -466,7 +466,7 @@ public class DBQuery extends DBRowSet
                     	{	// Create a new command param
                     		DBColumnExpr colExpr = cmpExpr.getColumnExpr();
                     		DBCommandParam param =(DBCommandParam)cmpExpr.getValue(); 
-                    		DBCommandParam value = upd.addCmdParam(colExpr, param.getValue());
+                    		DBCommandParam value = upd.addParam(colExpr, param.getValue());
                     		cmp = new DBCompareColExpr(colExpr, cmpExpr.getCmpop(), value);
                     	}
                         upd.where(cmp);
@@ -484,7 +484,7 @@ public class DBQuery extends DBRowSet
                 {   // Set key column constraint
                     Object value = keys[i];
                     if (db.isPreparedStatementsEnabled())
-                        value = upd.addCmdParam(keyColumns[i], value);
+                        value = upd.addParam(keyColumns[i], value);
                     upd.where(keyColumns[i].is(value));
                 }
             }    
@@ -503,7 +503,7 @@ public class DBQuery extends DBRowSet
                     if (ObjectUtils.isEmpty(lastTS)==false)
                     {   // set timestamp constraint
                         if (db.isPreparedStatementsEnabled())
-                            lastTS = upd.addCmdParam(tsColumn, lastTS);
+                            lastTS = upd.addParam(tsColumn, lastTS);
                         upd.where(tsColumn.is(lastTS));
                     }    
                     // Set new Timestamp
@@ -516,7 +516,7 @@ public class DBQuery extends DBRowSet
             }
             
             // Execute SQL
-            int affected = db.executeSQL(upd.getUpdate(), upd.getCmdParamValues(), conn);
+            int affected = db.executeSQL(upd.getUpdate(), upd.getParamValues(), conn);
             if (affected <= 0)
             {   // Error
                 if (affected == 0)

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBReader.java Sun
Jan  9 23:30:01 2011
@@ -410,7 +410,7 @@ public class DBReader extends DBRecordDa
         String sqlCmd = cmd.getSelect();
         // Create Statement
         db = cmd.getDatabase();
-        rset = db.executeQuery(sqlCmd, cmd.getCmdParamValues(), scrollable, conn);
+        rset = db.executeQuery(sqlCmd, cmd.getParamValues(), scrollable, conn);
         if (rset==null)
             return error(db);
         // successfully opened

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java Sun
Jan  9 23:30:01 2011
@@ -512,7 +512,7 @@ public abstract class DBRowSet extends D
         {   // Set key column constraint
             Object value = key[i];
             if (db.isPreparedStatementsEnabled())
-                value = cmd.addCmdParam(keyColumns[i], value);
+                value = cmd.addParam(keyColumns[i], value);
             cmd.where(keyColumns[i].is(value));
         }    
         return true;
@@ -634,7 +634,7 @@ public abstract class DBRowSet extends D
                         }
                         // set pk constraint
                         if (db.isPreparedStatementsEnabled())
-                            value = cmd.addCmdParam(col, value);
+                            value = cmd.addParam(col, value);
                         cmd.where(col.is(value));
                     } 
                     else if (timestampColumn == col)
@@ -642,7 +642,7 @@ public abstract class DBRowSet extends D
                     	if (empty==false) 
                     	{   // set timestamp constraint
                             if (db.isPreparedStatementsEnabled())
-                                value = cmd.addCmdParam(col, value);
+                                value = cmd.addParam(col, value);
 	                        cmd.where(col.is(value));
                     	}    
                     	else if (log.isDebugEnabled()) {
@@ -720,7 +720,7 @@ public abstract class DBRowSet extends D
             return success();
         }
         // Perform action
-        int affected = db.executeSQL(sql, cmd.getCmdParamValues(), conn, setGenKey);
+        int affected = db.executeSQL(sql, cmd.getParamValues(), conn, setGenKey);
         if (affected < 0)
         { // Update Failed
             return error(db);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java Sun
Jan  9 23:30:01 2011
@@ -178,7 +178,7 @@ public class DBTable extends DBRowSet im
     }
 
     /**
-     * Creates a new DBTableColumn object and add it to this object.
+     * Creates a new DBTableColumn object and adds it to the column collection.
      * 
      * @param columnName the column name
      * @param type the type of the column e.g. integer, text, date
@@ -193,7 +193,7 @@ public class DBTable extends DBRowSet im
     }
 
     /**
-     * Creates a new DBTableColumn object and add it to this object.
+     * Creates a new DBTableColumn object and adds it to the column collection.
      * 
      * @param columnName the column name
      * @param type the type of the column e.g. integer, text, date
@@ -207,7 +207,8 @@ public class DBTable extends DBRowSet im
     }
 
     /**
-     * deprecated use DBTableColumn addColumn(String columnName, DataType type, double size,
DataMode dataMode, Object defValue) instead
+     * Creates a new DBTableColumn object and adds it to the column collection.
+     * Instead of the data mode enum, a boolean flag is used to indicate whether the column
is required or optional.
      * 
      * @param columnName the column name
      * @param type the type of the column e.g. integer, text, date
@@ -216,15 +217,15 @@ public class DBTable extends DBRowSet im
      * @param defValue a Object object
      * @return the created DBTableColumn object
      */
-    // @Deprecated
-    @SuppressWarnings("deprecation")
     public final DBTableColumn addColumn(String columnName, DataType type, double size, boolean
required, Object defValue)
     { 
-        return new DBTableColumn(this, type, columnName, size, required, defValue);
+        DataMode dm = (required ? DataMode.NotNull : DataMode.Nullable);
+        return new DBTableColumn(this, type, columnName, size, dm, defValue);
     }
 
     /**
-     * deprecated use DBTableColumn addColumn(String columnName, DataType type, double size,
DataMode dataMode) instead
+     * Creates a new DBTableColumn object and adds it to the column collection.
+     * Instead of the data mode enum, a boolean flag is used to indicate whether the column
is required or optional. 
      * 
      * @param columnName the column name
      * @param type the type of the column e.g. integer, text, date
@@ -232,11 +233,10 @@ public class DBTable extends DBRowSet im
      * @param required true if not null column
      * @return the created DBTableColumn object
      */
-    // @Deprecated
-    @SuppressWarnings("deprecation")
     public final DBTableColumn addColumn(String columnName, DataType type, double size, boolean
required)
     { 
-        return new DBTableColumn(this, type, columnName, size, required, null);
+        DataMode dm = (required ? DataMode.NotNull : DataMode.Nullable);
+        return new DBTableColumn(this, type, columnName, size, dm, null);
     }
 
     /**
@@ -451,7 +451,7 @@ public class DBTable extends DBRowSet im
 
         // Perform delete
         String sqlCmd = cmd.getDelete(this);
-        int affected  = db.executeSQL(sqlCmd, cmd.getCmdParamValues(), conn);
+        int affected  = db.executeSQL(sqlCmd, cmd.getParamValues(), conn);
         if (affected < 0)
         { // Delete Failed
             return error(db);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
Sun Jan  9 23:30:01 2011
@@ -80,22 +80,6 @@ public class DBTableColumn extends DBCol
     }
 
     /**
-     * @deprecated use DBTableColumn(DBTable table, DataType type, String name, double size,
DataMode dataMode, Object defValue) instead 
-     * 
-     * @param table the table object to add the column to, set to null if you don't want
it added to a table
-     * @param type the type of the column e.g. integer, text, date
-     * @param name the column name
-     * @param size the column width
-     * @param required true if not null column
-     * @param defValue the object value
-     */
-    @Deprecated
-    public DBTableColumn(DBTable table, DataType type, String name, double size, boolean
required, Object defValue)
-    {
-        this(table, type, name, size, (required ? DataMode.NotNull : DataMode.Nullable),
defValue);
-    }
-
-    /**
      * Clone Constructor - use clone()
      */
     protected DBTableColumn(DBTable newTable, DBTableColumn other)

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java?rev=1057056&r1=1057055&r2=1057056&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/PreparedStatementTest.java
Sun Jan  9 23:30:01 2011
@@ -63,7 +63,7 @@ public class PreparedStatementTest{
         // Define the query
         DBCommand cmd = db.createCommand();
         // Create parameters
-        DBCommandParam empIdParam  = cmd.addCmdParam(null);
+        DBCommandParam empIdParam  = cmd.addParam(null);
         // the previous line could be shorter
         // DBCommandParam empIdParam  = cmd.addCmdParam(id);
         // create statement
@@ -72,7 +72,7 @@ public class PreparedStatementTest{
         // set param value
         empIdParam.setValue(id);
         // check command
-        assertNotNull(cmd.getCmdParamValues());
+        assertNotNull(cmd.getParamValues());
         assertTrue(cmd.getSelect().indexOf('?') > 0);
 
         DBReader r = new DBReader();



Mime
View raw message