You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2013/07/30 13:05:30 UTC
svn commit: r1508390 -
/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
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()