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

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

public class NormalParsingState
extends BaseParsingState

The default initial parsing state that is able to recognize the beginning of line comments, block comments, single and double quote literals and the ending of a statment.

Author:
Tim Ducheyne, Filip Neven

Field Summary
protected  boolean backSlashEscapingEnabled
          Determines whether backslashes can be used to escape characters, e.g. \" for a double quote (= "")
protected  boolean escaping
          True if the next character should be escaped
protected  ParsingState inBlockCommentParsingState
          The in a block comment (/ * comment * /) state.
protected  ParsingState inDoubleQuotesParsingState
          The in double quotes ("text") state.
protected  ParsingState inLineCommentParsingState
          The in an in-line comment (-- comment) state.
protected  ParsingState inSingleQuotesParsingState
          The in single quotes ('text') state.
 
Constructor Summary
NormalParsingState()
           
 
Method Summary
protected  ParsingState getNextParsingState(char previousChar, char currentChar, char nextChar, StatementBuilder statementBuilder)
          Determines the next state.
 void init(ParsingState inLineCommentParsingState, ParsingState inBlockCommentParsingState, ParsingState inSingleQuotesParsingState, ParsingState inDoubleQuotesParsingState, boolean backSlashEscapingEnabled)
          Initializes the state with the given parsing states.
 
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

inLineCommentParsingState

protected ParsingState inLineCommentParsingState
The in an in-line comment (-- comment) state.


inBlockCommentParsingState

protected ParsingState inBlockCommentParsingState
The in a block comment (/ * comment * /) state.


inSingleQuotesParsingState

protected ParsingState inSingleQuotesParsingState
The in single quotes ('text') state.


inDoubleQuotesParsingState

protected ParsingState inDoubleQuotesParsingState
The in double quotes ("text") state.


backSlashEscapingEnabled

protected boolean backSlashEscapingEnabled
Determines whether backslashes can be used to escape characters, e.g. \" for a double quote (= "")


escaping

protected boolean escaping
True if the next character should be escaped

Constructor Detail

NormalParsingState

public NormalParsingState()
Method Detail

init

public void init(ParsingState inLineCommentParsingState,
                 ParsingState inBlockCommentParsingState,
                 ParsingState inSingleQuotesParsingState,
                 ParsingState inDoubleQuotesParsingState,
                 boolean backSlashEscapingEnabled)
Initializes the state with the given parsing states.

Parameters:
inLineCommentParsingState - The inline comment state, not null
inBlockCommentParsingState - The block comment state, not null
inSingleQuotesParsingState - The single quote literal state, not null
inDoubleQuotesParsingState - The double quote literal state, not null
backSlashEscapingEnabled - True if backslashes can be used for escaping

getNextParsingState

protected ParsingState getNextParsingState(char previousChar,
                                           char currentChar,
                                           char nextChar,
                                           StatementBuilder statementBuilder)
Determines the next state. This will look for the beginning of a line comment, a block comment, a single qoute literal and a double quote literal. A semi-colon indicates the end of the statement.

Specified by:
getNextParsingState in class BaseParsingState
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


Copyright © 2011. All Rights Reserved.