portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r957809 - /portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/src/main/java/org/apache/jetspeed/tools/migration/SQLScriptReader.java
Date Fri, 25 Jun 2010 05:44:42 GMT
Author: rwatler
Date: Fri Jun 25 05:44:41 2010
New Revision: 957809

URL: http://svn.apache.org/viewvc?rev=957809&view=rev
Log:
DB Tools: remove dangling ';' from sourced SQL statements

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/src/main/java/org/apache/jetspeed/tools/migration/SQLScriptReader.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/src/main/java/org/apache/jetspeed/tools/migration/SQLScriptReader.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/src/main/java/org/apache/jetspeed/tools/migration/SQLScriptReader.java?rev=957809&r1=957808&r2=957809&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/src/main/java/org/apache/jetspeed/tools/migration/SQLScriptReader.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-db-tools/src/main/java/org/apache/jetspeed/tools/migration/SQLScriptReader.java
Fri Jun 25 05:44:41 2010
@@ -21,6 +21,8 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 
 /**
  * SQL Script Reader
@@ -30,13 +32,38 @@ import java.io.IOException;
  */
 public class SQLScriptReader
 {
+    private static final String EOL = System.getProperty("line.separator");
+    
     private BufferedReader reader;
     
+    /**
+     * Construct reader for SQL script stream.
+     * 
+     * @param scriptStream script stream
+     * @throws FileNotFoundException
+     */
+    public SQLScriptReader(InputStream scriptStream) throws FileNotFoundException
+    {
+        this.reader = new BufferedReader(new InputStreamReader(scriptStream));
+    }
+    
+    /**
+     * Construct reader for SQL script file.
+     * 
+     * @param scriptFile script file
+     * @throws FileNotFoundException
+     */
     public SQLScriptReader(File scriptFile) throws FileNotFoundException
     {
         this.reader = new BufferedReader(new FileReader(scriptFile));
     }
     
+    /**
+     * Read next SQL statement from script file.
+     * 
+     * @return read SQL statement
+     * @throws IOException
+     */
     public String readSQLStatement() throws IOException
     {
         StringBuilder sqlStatement = new StringBuilder();
@@ -58,13 +85,17 @@ public class SQLScriptReader
                     {
                         if (sqlStatement.length() > 0)
                         {
-                            sqlStatement.append(' ');
+                            sqlStatement.append(EOL);
                         }
-                        sqlStatement.append(line);
                         if (line.endsWith(";"))
                         {
+                            sqlStatement.append(line.substring(0, line.length()-1));
                             break;
                         }
+                        else
+                        {
+                            sqlStatement.append(line);
+                        }
                     }
                 }
             }
@@ -77,6 +108,11 @@ public class SQLScriptReader
         return ((sqlStatement.length() > 0) ? sqlStatement.toString() : null);
     }
 
+    /**
+     * Close reader.
+     * 
+     * @throws IOException
+     */
     public void close() throws IOException
     {
         reader.close();



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message