org.dbmaintain.script.parser.parsingstate.impl
Class BaseNormalParsingState

java.lang.Object
  extended by org.dbmaintain.script.parser.parsingstate.impl.BaseNormalParsingState
All Implemented Interfaces:
ParsingState
Direct Known Subclasses:
PlSqlBlockNormalParsingState, SqlStatementNormalParsingState

public abstract class BaseNormalParsingState
extends Object
implements ParsingState

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

Author:
Tim Ducheyne, Filip Neven

Field Summary
protected static Character ASTERIX
           
protected static Character BACKSLASH
           
protected  boolean backSlashEscapingEnabled
           
protected  boolean curlyBraceBlockCommentSupported
           
protected static Character DASH
           
protected static Character DOUBLE_QUOTE
           
protected  HandleNextCharacterResult endOfStatementResult
           
protected static Character OPEN_CURLY_BRACE
           
protected  PlSqlBlockMatcher plSqlBlockMatcher
           
protected static Character SEMICOLON
           
protected static Character SINGLE_QUOTE
           
protected static Character SLASH
           
protected  HandleNextCharacterResult stayInNormalExecutableResult
           
protected  HandleNextCharacterResult stayInNormalNotExecutableResult
           
protected  HandleNextCharacterResult toCurlyBraceBlockCommentResult
           
protected  HandleNextCharacterResult toEscapingParsingStateResult
           
protected  HandleNextCharacterResult toInBlockCommentResult
           
protected  HandleNextCharacterResult toInDoubleQuotesStateResult
           
protected  HandleNextCharacterResult toInLineCommentResult
           
protected  HandleNextCharacterResult toInPlSqlBlockStateResult
           
protected  HandleNextCharacterResult toInSingleQuotesStateResult
           
 
Constructor Summary
protected BaseNormalParsingState(boolean backSlashEscapingEnabled, boolean curlyBraceBlockCommentSupported, PlSqlBlockMatcher plSqlBlockMatcher)
           
 
Method Summary
 HandleNextCharacterResult getNextParsingState(Character previousChar, Character currentChar, Character nextChar, StatementBuilder statementBuilder)
          Determines the next state.
protected abstract  boolean isEndOfStatement(Character previousChar, Character currentChar, StatementBuilder statementBuilder)
           
protected abstract  boolean isStatementSeparator(Character currentChar)
           
protected  boolean isWhitespace(Character character)
           
 void linkParsingStates(ParsingState inLineCommentParsingState, ParsingState inBlockCommentParsingState, ParsingState inCurlyBraceBlockCommentParsingState, ParsingState inSingleQuotesParsingState, ParsingState inDoubleQuotesParsingState, ParsingState escapingParsingState, ParsingState plSqlBlockNormalParsingState)
          Initializes the state with the given parsing states.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BACKSLASH

protected static final Character BACKSLASH

DASH

protected static final Character DASH

SLASH

protected static final Character SLASH

ASTERIX

protected static final Character ASTERIX

SINGLE_QUOTE

protected static final Character SINGLE_QUOTE

DOUBLE_QUOTE

protected static final Character DOUBLE_QUOTE

SEMICOLON

protected static final Character SEMICOLON

OPEN_CURLY_BRACE

protected static final Character OPEN_CURLY_BRACE

backSlashEscapingEnabled

protected boolean backSlashEscapingEnabled

curlyBraceBlockCommentSupported

protected boolean curlyBraceBlockCommentSupported

plSqlBlockMatcher

protected PlSqlBlockMatcher plSqlBlockMatcher

endOfStatementResult

protected HandleNextCharacterResult endOfStatementResult

stayInNormalNotExecutableResult

protected HandleNextCharacterResult stayInNormalNotExecutableResult

stayInNormalExecutableResult

protected HandleNextCharacterResult stayInNormalExecutableResult

toEscapingParsingStateResult

protected HandleNextCharacterResult toEscapingParsingStateResult

toInLineCommentResult

protected HandleNextCharacterResult toInLineCommentResult

toInBlockCommentResult

protected HandleNextCharacterResult toInBlockCommentResult

toCurlyBraceBlockCommentResult

protected HandleNextCharacterResult toCurlyBraceBlockCommentResult

toInSingleQuotesStateResult

protected HandleNextCharacterResult toInSingleQuotesStateResult

toInDoubleQuotesStateResult

protected HandleNextCharacterResult toInDoubleQuotesStateResult

toInPlSqlBlockStateResult

protected HandleNextCharacterResult toInPlSqlBlockStateResult
Constructor Detail

BaseNormalParsingState

protected BaseNormalParsingState(boolean backSlashEscapingEnabled,
                                 boolean curlyBraceBlockCommentSupported,
                                 PlSqlBlockMatcher plSqlBlockMatcher)
Method Detail

linkParsingStates

public void linkParsingStates(ParsingState inLineCommentParsingState,
                              ParsingState inBlockCommentParsingState,
                              ParsingState inCurlyBraceBlockCommentParsingState,
                              ParsingState inSingleQuotesParsingState,
                              ParsingState inDoubleQuotesParsingState,
                              ParsingState escapingParsingState,
                              ParsingState plSqlBlockNormalParsingState)
Initializes the state with the given parsing states.

Parameters:
inLineCommentParsingState - the inline comment state, not null
inBlockCommentParsingState - the block comment state, not null
inCurlyBraceBlockCommentParsingState - the curly brace block comment state, not null
inSingleQuotesParsingState - the single quote literal state, not null
inDoubleQuotesParsingState - the double quote literal state, not null
escapingParsingState - the escaping parsing state, not null
plSqlBlockNormalParsingState - the pl-sql block parsing state, not null

getNextParsingState

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

Specified by:
getNextParsingState in interface ParsingState
Parameters:
previousChar - The previous char, null if none
currentChar - The current char
nextChar - The next char, null if none
statementBuilder - The statement builder, not null
Returns:
The next parsing state, null if the end of the statement is reached

isStatementSeparator

protected abstract boolean isStatementSeparator(Character currentChar)

isEndOfStatement

protected abstract boolean isEndOfStatement(Character previousChar,
                                            Character currentChar,
                                            StatementBuilder statementBuilder)

isWhitespace

protected boolean isWhitespace(Character character)


Copyright © 2011. All Rights Reserved.