@ -259,7 +259,7 @@ public abstract class ScriptUtils {
* @throws IOException in case of I / O errors
* @throws IOException in case of I / O errors
* /
* /
static String readScript ( EncodedResource resource ) throws IOException {
static String readScript ( EncodedResource resource ) throws IOException {
return readScript ( resource , DEFAULT_COMMENT_PREFIX , DEFAULT_STATEMENT_SEPARATOR ) ;
return readScript ( resource , DEFAULT_COMMENT_PREFIX , DEFAULT_STATEMENT_SEPARATOR , DEFAULT_BLOCK_COMMENT_END_DELIMITER ) ;
}
}
/ * *
/ * *
@ -273,15 +273,16 @@ public abstract class ScriptUtils {
* @param commentPrefix the prefix that identifies comments in the SQL script & mdash ;
* @param commentPrefix the prefix that identifies comments in the SQL script & mdash ;
* typically "--"
* typically "--"
* @param separator the statement separator in the SQL script & mdash ; typically ";"
* @param separator the statement separator in the SQL script & mdash ; typically ";"
* @param blockCommentEndDelimiter the < em > end < / em > block comment delimiter
* @return a { @code String } containing the script lines
* @return a { @code String } containing the script lines
* @throws IOException in case of I / O errors
* @throws IOException in case of I / O errors
* /
* /
private static String readScript ( EncodedResource resource , @Nullable String commentPrefix ,
private static String readScript ( EncodedResource resource , @Nullable String commentPrefix ,
@Nullable String separator ) throws IOException {
@Nullable String separator , @Nullable String blockCommentEndDelimite r ) throws IOException {
LineNumberReader lnr = new LineNumberReader ( resource . getReader ( ) ) ;
LineNumberReader lnr = new LineNumberReader ( resource . getReader ( ) ) ;
try {
try {
return readScript ( lnr , commentPrefix , separator ) ;
return readScript ( lnr , commentPrefix , separator , blockCommentEndDelimiter ) ;
}
}
finally {
finally {
lnr . close ( ) ;
lnr . close ( ) ;
@ -297,19 +298,21 @@ public abstract class ScriptUtils {
* a statement & mdash ; will be included in the results .
* a statement & mdash ; will be included in the results .
* @param lineNumberReader the { @code LineNumberReader } containing the script
* @param lineNumberReader the { @code LineNumberReader } containing the script
* to be processed
* to be processed
* @param c ommentPrefix the prefix that identifies comments in the SQL script & mdash ;
* @param lineC ommentPrefix the prefix that identifies comments in the SQL script & mdash ;
* typically "--"
* typically "--"
* @param separator the statement separator in the SQL script & mdash ; typically ";"
* @param separator the statement separator in the SQL script & mdash ; typically ";"
* @param blockCommentEndDelimiter the < em > end < / em > block comment delimiter
* @return a { @code String } containing the script lines
* @return a { @code String } containing the script lines
* @throws IOException in case of I / O errors
* @throws IOException in case of I / O errors
* /
* /
public static String readScript ( LineNumberReader lineNumberReader , @Nullable String c ommentPrefix,
public static String readScript ( LineNumberReader lineNumberReader , @Nullable String lineC ommentPrefix,
@Nullable String separator ) throws IOException {
@Nullable String separator , @Nullable String blockCommentEndDelimite r ) throws IOException {
String currentStatement = lineNumberReader . readLine ( ) ;
String currentStatement = lineNumberReader . readLine ( ) ;
StringBuilder scriptBuilder = new StringBuilder ( ) ;
StringBuilder scriptBuilder = new StringBuilder ( ) ;
while ( currentStatement ! = null ) {
while ( currentStatement ! = null ) {
if ( commentPrefix ! = null & & ! currentStatement . startsWith ( commentPrefix ) ) {
if ( ( blockCommentEndDelimiter ! = null & & currentStatement . contains ( blockCommentEndDelimiter ) ) | |
( lineCommentPrefix ! = null & & ! currentStatement . startsWith ( lineCommentPrefix ) ) ) {
if ( scriptBuilder . length ( ) > 0 ) {
if ( scriptBuilder . length ( ) > 0 ) {
scriptBuilder . append ( '\n' ) ;
scriptBuilder . append ( '\n' ) ;
}
}
@ -460,7 +463,7 @@ public abstract class ScriptUtils {
String script ;
String script ;
try {
try {
script = readScript ( resource , commentPrefix , separator ) ;
script = readScript ( resource , commentPrefix , separator , blockCommentEndDelimiter ) ;
}
}
catch ( IOException ex ) {
catch ( IOException ex ) {
throw new CannotReadScriptException ( resource , ex ) ;
throw new CannotReadScriptException ( resource , ex ) ;