empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1508390 - /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
Date Tue, 30 Jul 2013 11:05:30 GMT
Author: doebele
Date: Tue Jul 30 11:05:30 2013
New Revision: 1508390

URL: http://svn.apache.org/r1508390
Log:
EMPIREDB-188
added a setStmt method to allow changing of existing statements

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java?rev=1508390&r1=1508389&r2=1508390&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java Tue Jul
30 11:05:30 2013
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 
 import org.apache.empire.db.exceptions.EmpireSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,10 +93,29 @@ public class DBSQLScript implements Iter
      */
     public String getStmt(int i)
     {
+        if (i<0 || i>=sqlCmdList.size())
+            throw new InvalidArgumentException("index", i);
+        // return statement
         return sqlCmdList.get(i);
     }
     
     /**
+     * Replaces an entry in the list
+     * @param i index of the statement to replace
+     * @param stmt the new statement for this index, or NULL to remove the statement
+     */
+    public void setStmt(int i, String stmt)
+    {
+        if (i<0 || i>=sqlCmdList.size())
+            throw new InvalidArgumentException("index", i);
+        // replace or remove statement
+        if (stmt==null)
+            sqlCmdList.remove(i);
+        else
+            sqlCmdList.set(i, stmt);
+    }
+    
+    /**
      * Clears the script by removing all statements
      */
     public void clear()



Mime
View raw message