Top Description Fields Constructors Methods
org.h2.command

public Class ParserBase

extends Object
Class Inheritance
Known Direct Subclasses
org.h2.command.Parser
Static Imports
org.h2.command.Token.CLOSE_PAREN, .Token.COMMA, .Token.LITERAL, .Token.MINUS_SIGN, .Token.OPEN_PAREN, .Token.PLUS_SIGN, .Token.TOKENS, org.h2.util.ParserUtil.FALSE, .ParserUtil.FIRST_KEYWORD, .ParserUtil.IDENTIFIER, .ParserUtil.LAST_KEYWORD, .ParserUtil.ON, .ParserUtil.TRUE

The base class for the parser.

Field Summary

Modifier and TypeField and Description
pack-priv String
currentToken

String representation of the current token.

pack-priv int
currentTokenType

Type of the current token.

pack-priv final Database
database

The database or null.

pack-priv ArrayList<String>
expectedList

List of expected tokens or null.

private final boolean
private final boolean
private boolean
literalsChecked

If true, checks for literals are disabled.

pack-priv final BitSet
nonKeywords

Value of NON_KEYWORDS setting.

pack-priv ArrayList<Parameter>
parameters

JDBC parameters.

pack-priv final SessionLocal
session

The session or null.

pack-priv String
sqlCommand

Original SQL.

pack-priv Token
token

The current token.

pack-priv int
tokenIndex

Index of the current token.

pack-priv ArrayList<Token>
tokens

Tokens.

pack-priv BitSet
usedParameters

Indexes of used parameters.

pack-priv final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
public
ParserBase()

Creates a new instance of parser for special use cases.

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
pack-priv final void
addExpected(int tokenType)

private void
addExpected(int tokenType1, int tokenType2)

private void
addExpected(String tokenType1, String tokenType2)

private void
addExpected(Object... tokens)

pack-priv final void
addMultipleExpected(int... tokenTypes)

private void
pack-priv final ArrayList<Parameter>
closeParametersScope(BitSet outerUsedParameters)

pack-priv final boolean
public static String

Returns:

comma-separated list of non-keywords
formatNonKeywords
(BitSet
bit set of non-keywords, or null
nonKeywords
)

Formats a comma-separated list of keywords.

public final int

Returns:

the last parse index
getLastParseIndex
()

Returns the last parse index.

pack-priv final ArrayList<Token>
getRemainingTokens(int offset)

pack-priv final DbException
pack-priv final void
initialize(String sql, ArrayList<Token> tokens, boolean stopOnCloseParen)

pack-priv final boolean
pack-priv static boolean
isKeyword(int tokenType)

pack-priv final boolean
pack-priv final boolean
isToken(String tokenName)

pack-priv final boolean
isToken(int tokenType)

pack-priv final boolean
isTokenCompat(String tokenName)

pack-priv final BitSet
public Object

Returns:

the array of column names (String[]) or numbers (int[])
parseColumnList
(String
the source SQL
sql
,
int
the initial offset
offset
)

Parses a list of column names or numbers in parentheses.

public static BitSet

Returns:

bit set of non-keywords, or null
parseNonKeywords
(String[]
array of non-keywords in upper case
nonKeywords
)

Parses the specified collection of non-keywords.

public static String

Returns:

the quoted identifier
quoteIdentifier
(String
the identifier
s
,
int
formatting flags
sqlFlags
)

Add double quotes around an identifier if required.

pack-priv final void
read(String expected)

pack-priv final void
read(int tokenType)

pack-priv final void
read()

pack-priv final boolean
pack-priv final void
readCompat(int tokenType)

pack-priv final boolean
readIf(String tokenName)

pack-priv final boolean
readIf(String tokenName1, String tokenName2)

pack-priv final boolean
readIf(String tokenName1, int tokenType2)

pack-priv final boolean
readIf(int tokenType)

pack-priv final boolean
readIf(int tokenType1, int tokenType2)

pack-priv final boolean
readIf(int tokenType1, String tokenName2)

pack-priv final boolean
readIf(Object... tokensTypesOrNames)

pack-priv final boolean
readIfCompat(String tokenName)

pack-priv final boolean
readIfCompat(int tokenType)

pack-priv final boolean
readIfCompat(int tokenType1, int tokenType2)

pack-priv final boolean
readIfCompat(int tokenType1, String tokenName2)

pack-priv final boolean
readIfCompat(Object... tokensTypesOrNames)

pack-priv final boolean

Returns:

true if comma is read, false if brace is read
readIfMore
()

Read comma or closing brace.

pack-priv final int
pack-priv final long
pack-priv final int
pack-priv final Parameter
pack-priv final long
pack-priv final void
public final void
setLiteralsChecked(boolean literalsChecked)

public final void
pack-priv final void
setTokenIndex(int index)

private boolean
testToken(Object expected, Token token)

private boolean
testToken(String tokenName, Token token)

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv final String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

currentTokenback to summary
pack-priv String currentToken

String representation of the current token.

currentTokenTypeback to summary
pack-priv int currentTokenType

Type of the current token.

databaseback to summary
pack-priv final Database database

The database or null.

expectedListback to summary
pack-priv ArrayList<String> expectedList

List of expected tokens or null.

identifiersToLowerback to summary
private final boolean identifiersToLower
See Also
org.h2.engine.DbSettings#databaseToLower
identifiersToUpperback to summary
private final boolean identifiersToUpper
See Also
org.h2.engine.DbSettings#databaseToUpper
literalsCheckedback to summary
private boolean literalsChecked

If true, checks for literals are disabled.

nonKeywordsback to summary
pack-priv final BitSet nonKeywords

Value of NON_KEYWORDS setting.

parametersback to summary
pack-priv ArrayList<Parameter> parameters

JDBC parameters.

sessionback to summary
pack-priv final SessionLocal session

The session or null.

sqlCommandback to summary
pack-priv String sqlCommand

Original SQL.

tokenback to summary
pack-priv Token token

The current token.

tokenIndexback to summary
pack-priv int tokenIndex

Index of the current token.

tokensback to summary
pack-priv ArrayList<Token> tokens

Tokens.

usedParametersback to summary
pack-priv BitSet usedParameters

Indexes of used parameters.

variableBinaryback to summary
pack-priv final boolean variableBinary
See Also
org.h2.engine.SessionLocal#isVariableBinary()

Constructor Detail

ParserBaseback to summary
pack-priv ParserBase(SessionLocal session)
ParserBaseback to summary
public ParserBase()

Creates a new instance of parser for special use cases.

Method Detail

addExpectedback to summary
pack-priv final void addExpected(String token)
addExpectedback to summary
pack-priv final void addExpected(int tokenType)
addExpectedback to summary
private void addExpected(int tokenType1, int tokenType2)
addExpectedback to summary
private void addExpected(String tokenType1, String tokenType2)
addExpectedback to summary
private void addExpected(Object... tokens)
addMultipleExpectedback to summary
pack-priv final void addMultipleExpected(int... tokenTypes)
checkLiteralsback to summary
private void checkLiterals()
closeParametersScopeback to summary
pack-priv final ArrayList<Parameter> closeParametersScope(BitSet outerUsedParameters)
equalsTokenback to summary
pack-priv final boolean equalsToken(String a, String b)
formatNonKeywordsback to summary
public static String formatNonKeywords(BitSet nonKeywords)

Formats a comma-separated list of keywords.

Parameters
nonKeywords:BitSet

bit set of non-keywords, or null

Returns:String

comma-separated list of non-keywords

getLastParseIndexback to summary
public final int getLastParseIndex()

Returns the last parse index.

Returns:int

the last parse index

getRemainingTokensback to summary
pack-priv final ArrayList<Token> getRemainingTokens(int offset)
getSyntaxErrorback to summary
pack-priv final DbException getSyntaxError()
initializeback to summary
pack-priv final void initialize(String sql, ArrayList<Token> tokens, boolean stopOnCloseParen)
isIdentifierback to summary
pack-priv final boolean isIdentifier()
isKeywordback to summary
pack-priv static boolean isKeyword(int tokenType)
isKeywordback to summary
pack-priv final boolean isKeyword(String s)
isTokenback to summary
pack-priv final boolean isToken(String tokenName)
isTokenback to summary
pack-priv final boolean isToken(int tokenType)
isTokenCompatback to summary
pack-priv final boolean isTokenCompat(String tokenName)
openParametersScopeback to summary
pack-priv final BitSet openParametersScope()
parseColumnListback to summary
public Object parseColumnList(String sql, int offset)

Parses a list of column names or numbers in parentheses.

Parameters
sql:String

the source SQL

offset:int

the initial offset

Returns:Object

the array of column names (String[]) or numbers (int[])

Exceptions
DbException:
on syntax error
parseNonKeywordsback to summary
public static BitSet parseNonKeywords(String[] nonKeywords)

Parses the specified collection of non-keywords.

Parameters
nonKeywords:String[]

array of non-keywords in upper case

Returns:BitSet

bit set of non-keywords, or null

quoteIdentifierback to summary
public static String quoteIdentifier(String s, int sqlFlags)

Add double quotes around an identifier if required.

Parameters
s:String

the identifier

sqlFlags:int

formatting flags

Returns:String

the quoted identifier

readback to summary
pack-priv final void read(String expected)
readback to summary
pack-priv final void read(int tokenType)
readback to summary
pack-priv final void read()
readBooleanSettingback to summary
pack-priv final boolean readBooleanSetting()
readCompatback to summary
pack-priv final void readCompat(int tokenType)
readIfback to summary
pack-priv final boolean readIf(String tokenName)
readIfback to summary
pack-priv final boolean readIf(String tokenName1, String tokenName2)
readIfback to summary
pack-priv final boolean readIf(String tokenName1, int tokenType2)
readIfback to summary
pack-priv final boolean readIf(int tokenType)
readIfback to summary
pack-priv final boolean readIf(int tokenType1, int tokenType2)
readIfback to summary
pack-priv final boolean readIf(int tokenType1, String tokenName2)
readIfback to summary
pack-priv final boolean readIf(Object... tokensTypesOrNames)
readIfCompatback to summary
pack-priv final boolean readIfCompat(String tokenName)
readIfCompatback to summary
pack-priv final boolean readIfCompat(int tokenType)
readIfCompatback to summary
pack-priv final boolean readIfCompat(int tokenType1, int tokenType2)
readIfCompatback to summary
pack-priv final boolean readIfCompat(int tokenType1, String tokenName2)
readIfCompatback to summary
pack-priv final boolean readIfCompat(Object... tokensTypesOrNames)
readIfMoreback to summary
pack-priv final boolean readIfMore()

Read comma or closing brace.

Returns:boolean

true if comma is read, false if brace is read

readIntback to summary
pack-priv final int readInt()
readLongback to summary
pack-priv final long readLong()
readNonNegativeIntback to summary
pack-priv final int readNonNegativeInt()
readParameterback to summary
pack-priv final Parameter readParameter()
readPositiveLongback to summary
pack-priv final long readPositiveLong()
resetTokenIndexback to summary
pack-priv final void resetTokenIndex()
setLiteralsCheckedback to summary
public final void setLiteralsChecked(boolean literalsChecked)
setSuppliedParametersback to summary
public final void setSuppliedParameters(ArrayList<Parameter> suppliedParameters)
setTokenIndexback to summary
pack-priv final void setTokenIndex(int index)
testTokenback to summary
private boolean testToken(Object expected, Token token)
testTokenback to summary
private boolean testToken(String tokenName, Token token)
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
upperNameback to summary
pack-priv final String upperName(String name)