org.unitils.dbmaintainer.script.parsingstate.impl
Class OracleNormalParsingState

java.lang.Object
  extended by org.unitils.dbmaintainer.script.parsingstate.impl.BaseParsingState
      extended by org.unitils.dbmaintainer.script.parsingstate.impl.NormalParsingState
          extended by org.unitils.dbmaintainer.script.parsingstate.impl.OracleNormalParsingState
All Implemented Interfaces:
ParsingState

public class OracleNormalParsingState
extends NormalParsingState

The initial state for Oracle. This parser adds PL/SQL statement recognition to the parser. In order for the parser to recognize the ending of a code block, the SQLPlus standard must be followed, namely every code block should end with line containing a single forward slash (/).

Author:
Tim Ducheyne, Filip Neven

Field Summary
protected  StringBuilder lineBuffer
          Contains the current line
protected  boolean parsingCodeBlock
          True if a code block is being parsed
protected  StringBuilder statementBuffer
          Contains the current statement letters (no signs..) with all double whitespace and newlines converted to single whitespace
 
Fields inherited from class org.unitils.dbmaintainer.script.parsingstate.impl.NormalParsingState
backSlashEscapingEnabled, escaping, inBlockCommentParsingState, inDoubleQuotesParsingState, inLineCommentParsingState, inSingleQuotesParsingState
 
Constructor Summary
OracleNormalParsingState()
           
 
Method Summary
protected  ParsingState getNextParsingState(char previousChar, char currentChar, char nextChar, StatementBuilder statementBuilder)
          Overridden to also correctly identify the starting of PL/SQL code blocks and to handle slashes / to end a statement.
protected  boolean isStartOfCodeStatement(StringBuilder statement)
          Checks whether the statment contains the starting letters of a code statement (eg CREATE PACKAGE).
protected  boolean matches(String text, StringBuilder statement)
          Utility method to check whether the given statement starts with the letters of the given text.
 
Methods inherited from class org.unitils.dbmaintainer.script.parsingstate.impl.NormalParsingState
init
 
Methods inherited from class org.unitils.dbmaintainer.script.parsingstate.impl.BaseParsingState
handleNextChar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parsingCodeBlock

protected boolean parsingCodeBlock
True if a code block is being parsed


lineBuffer

protected StringBuilder lineBuffer
Contains the current line


statementBuffer

protected StringBuilder statementBuffer
Contains the current statement letters (no signs..) with all double whitespace and newlines converted to single whitespace

Constructor Detail

OracleNormalParsingState

public OracleNormalParsingState()
Method Detail

getNextParsingState

protected ParsingState getNextParsingState(char previousChar,
                                           char currentChar,
                                           char nextChar,
                                           StatementBuilder statementBuilder)
Overridden to also correctly identify the starting of PL/SQL code blocks and to handle slashes / to end a statement.

Overrides:
getNextParsingState in class NormalParsingState
Parameters:
previousChar - The previous char, 0 if none
currentChar - The current char
nextChar - The next char, 0 if none
statementBuilder - The statement builder, not null
Returns:
The next parsing state, null if the end of the statement is reached

isStartOfCodeStatement

protected boolean isStartOfCodeStatement(StringBuilder statement)
Checks whether the statment contains the starting letters of a code statement (eg CREATE PACKAGE). The statementBuffer should contain all letters (no signs) and every double space or newline converted to a single space.

Parameters:
statement - The buffer, not null
Returns:
True if a code statment is recognized

matches

protected boolean matches(String text,
                          StringBuilder statement)
Utility method to check whether the given statement starts with the letters of the given text.

Parameters:
text - The starting letters, not null
statement - The statement to check
Returns:
True if the statement starts with the text


Copyright © 2011. All Rights Reserved.