psdi.configure

Class ScriptReader

  • java.lang.Object
    • java.io.Reader
      • java.io.BufferedReader
        • java.io.LineNumberReader
          • psdi.configure.ScriptReader
  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Readable, UpgConstants


    public class ScriptReader
    extends java.io.LineNumberReader
    implements UpgConstants
    Script Reader utility. Reads sql from an input file and returns sql statements.
    • Constructor Detail

      • ScriptReader

        public ScriptReader(java.io.Reader in)
        For example

        ScriptReader reader = new ScriptReader(new FileReader("foo.sql"));

      • ScriptReader

        public ScriptReader(java.io.Reader in,
                            int sz)
    • Method Detail

      • setTriggerScript

        public void setTriggerScript(boolean value)
        Sets the value of triggerScript. Since this defaults to False, this method would be called only if we are reading a trigger script that uses the delimiter [END TRIGGER].
      • getNextSql

        public java.lang.String getNextSql()
                                    throws java.lang.Exception
        Get the next sql statement from the input file. This will bypass any remarks.

        Remarks are identified as follows.

        • A line that starts with REM , or
        • A line that starts with -- , or
        • A block that starts with /* and ends with */. This class presumes that the begin-block indicator is at the beginning of a line, and the end-block indicator is at the end of a line.

        Sql statements are identified as follows.

        • It is not a remark (described above), and
        • The line after the end of the statement equals ; or go (upper or lower case).
        • However, if triggerScript was set to True via setTriggerScript, this will look for [END TRIGGER] as the separator between statements, instead of ; or go. (When triggerScript is True, [BEGIN TRIGGER] markers are not needed.) This is to support multiline triggers.
        • Even if this was not marked as a "trigger script" via setTriggerScript, it can still contain triggers, as long as each trigger is preceded by [BEGIN TRIGGER] and followed by [END TRIGGER]. This is to support multiline triggers.
        • If the trigger is written on a single line, then the [BEGIN TRIGGER] and [END TRIGGER] markers are not needed. If the line begins with CREATE OR REPLACE TRIGGER then the terminator will be a slash (/).
        • Similarly, after CREATE OR REPLACE PROCEDURE, the terminator will be a slash (/).
        Returns:
        The next sql statement from the input file, excluding terminators such as ; and go, and excluding remarks. If end of file, this will return null.
        Throws:
        java.lang.Exception
        See Also:
        ScriptReader.lastWasCommit