org.codehaus.mojo.sql
Class SqlSplitter

java.lang.Object
  extended by org.codehaus.mojo.sql.SqlSplitter

public final class SqlSplitter
extends Object

Utility class to split a long sql batch script into single SQL commands.


Field Summary
static int NO_END
          Value indicating the sql has no end-delimiter like i.e. the semicolon.
static int OVERFLOW_COMMENT
          parsed sql started a comment with /_* which continues on the next line (did not end)
static int OVERFLOW_DOUBLE_QUOTE
          parsed sql started a double quote static text which continues on the next line (did not end)
static int OVERFLOW_SINGLE_QUOTE
          parsed sql started a single quote static text which continues on the next line (did not end)
 
Method Summary
static int containsSqlEnd(String line, String delimiter, int overflowValue)
          Check if the given sql line contains a delimiter representing the end of the command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_END

public static final int NO_END
Value indicating the sql has no end-delimiter like i.e. the semicolon.

See Also:
Constant Field Values

OVERFLOW_SINGLE_QUOTE

public static final int OVERFLOW_SINGLE_QUOTE
parsed sql started a single quote static text which continues on the next line (did not end)

See Also:
Constant Field Values

OVERFLOW_DOUBLE_QUOTE

public static final int OVERFLOW_DOUBLE_QUOTE
parsed sql started a double quote static text which continues on the next line (did not end)

See Also:
Constant Field Values

OVERFLOW_COMMENT

public static final int OVERFLOW_COMMENT
parsed sql started a comment with /_* which continues on the next line (did not end)

See Also:
Constant Field Values
Method Detail

containsSqlEnd

public static int containsSqlEnd(String line,
                                 String delimiter,
                                 int overflowValue)
Check if the given sql line contains a delimiter representing the end of the command. Please note that we do not fully parse the SQL, so if we get a malformed statement, we cannot detect it.

Parameters:
line - to parse
delimiter - which should be used to split SQL commands
overflowValue - 0=none, OVERFLOW_COMMENT, OVERFLOW_SINGLE_QUOTE or OVERFLOW_DOUBLE_QUOTE
Returns:
position after the end character if the given line contains the end of a SQL script, NO_END if it doesn't contain an end char. OVERFLOW_SINGLE_QUOTE will be returned if a single quote didn't get closed, OVERFLOW_DOUBLE_QUOTE likewise for not closed double quotes.


Copyright © 2006-2011 Codehaus. All Rights Reserved.