Class SqlSplitter

java.lang.Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value indicating the sql has no end-delimiter like i.e.
    static final int
    parsed sql started a comment with /_* which continues on the next line (did not end)
    static final int
    parsed sql started a double quote static text which continues on the next line (did not end)
    static final int
    parsed sql started a single quote static text which continues on the next line (did not end)
  • Method Summary

    Modifier and Type
    Method
    Description
    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 Details

    • NO_END

      public static final int NO_END
      Value indicating the sql has no end-delimiter like i.e. the semicolon.
      See Also:
    • 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:
    • 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:
    • 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:
  • Method Details

    • 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.