Class ADQLGrammarBase
- All Implemented Interfaces:
ADQLGrammar
ADQLGrammar
.- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface adql.parser.grammar.ADQLGrammar
ADQLGrammar.Tokenizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ADQLQuery
The object representation of the ADQL query to parse.protected ADQLQueryFactory
Tool to build the object representation of the ADQL query.The stack of queries (in order to deal with sub-queries). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ParseException
Generate aParseException
instance representing the givenException
.final ADQLQueryFactory
Get theADQLQueryFactory
used by this Grammar Parser to create ADQL object representations (e.g.boolean
Tell whether the given token represents the end of an ADQL query.final boolean
isRegularIdentifier
(String idCandidate) Tell whether the given string is a valid ADQL regular identifier.abstract void
ReInit
(InputStream stream) Re-initialize the input of the ADQL grammar parser.final void
reset
(InputStream inputADQLExpression) (Re-)Set the ADQL expression to parse.final void
setQueryFactory
(ADQLQueryFactory factory) Set theADQLQueryFactory
to use in order to create ADQL object representations (e.g.final void
testRegularIdentifier
(Token token) Test the given token as an ADQL's regular identifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface adql.parser.grammar.ADQLGrammar
disable_tracing, enable_tracing, From, getTokenizer, getVersion, GroupBy, isEOF, isEOQ, isLeftPar, isRegularIdentifierCandidate, isSQLReservedWord, OrderBy, Query, Select, StringExpression, Where
-
Field Details
-
queryFactory
Tool to build the object representation of the ADQL query. -
query
The object representation of the ADQL query to parse. (ONLY USED DURING THE PARSING, otherwise it is always NULL). -
stackQuery
The stack of queries (in order to deal with sub-queries).
-
-
Constructor Details
-
ADQLGrammarBase
public ADQLGrammarBase()
-
-
Method Details
-
getQueryFactory
Description copied from interface:ADQLGrammar
Get theADQLQueryFactory
used by this Grammar Parser to create ADQL object representations (e.g. SELECT, column, string, constraint) while building the ADQL query tree- Specified by:
getQueryFactory
in interfaceADQLGrammar
- Returns:
- The used
ADQLQueryFactory
. Never NULL
-
setQueryFactory
Description copied from interface:ADQLGrammar
Set theADQLQueryFactory
to use in order to create ADQL object representations (e.g. SELECT, column, string, constraint) while building the ADQL query tree.- Specified by:
setQueryFactory
in interfaceADQLGrammar
- Parameters:
factory
- TheADQLQueryFactory
to use.- Throws:
NullPointerException
- If the given factory is NULL.
-
reset
Description copied from interface:ADQLGrammar
(Re-)Set the ADQL expression to parse.Important note: This function MUST always be called BEFORE calling any parsing function.
- Specified by:
reset
in interfaceADQLGrammar
- Parameters:
inputADQLExpression
- ADQL expression to parse.- Throws:
NullPointerException
- If the given stream is NULL.Exception
- If any error occurs while initializing the parser.
-
ReInit
Re-initialize the input of the ADQL grammar parser.- Parameters:
stream
- The new input stream to parse.
-
isRegularIdentifier
Description copied from interface:ADQLGrammar
Tell whether the given string is a valid ADQL regular identifier.According to the ADQL-2.0's BNF, a regular identifier (i.e. not delimited ; not between double quotes) must be a letter followed by a letter, digit or underscore. So, the following regular expression:
[a-zA-Z]+[a-zA-Z0-9_]*
This is what this function tests on the given string.
Warning: This function may return a different result for different versions of the ADQL grammar.
- Specified by:
isRegularIdentifier
in interfaceADQLGrammar
- Parameters:
idCandidate
- The string to test.- Returns:
true
if the given string is a valid regular identifier,false
otherwise.- See Also:
-
testRegularIdentifier
Description copied from interface:ADQLGrammar
Test the given token as an ADQL's regular identifier.Implementation note: This function uses
ADQLGrammar.isRegularIdentifier(String)
to test the given token's image. If the test fails, aParseException
is thrown.- Specified by:
testRegularIdentifier
in interfaceADQLGrammar
- Parameters:
token
- The token to test.- Throws:
ParseException
- If the given token is not a valid ADQL regular identifier.- See Also:
-
isEnd
Description copied from interface:ADQLGrammar
Tell whether the given token represents the end of an ADQL query.Implementation note: NULL is considered as a last token of a set. So, by extension it should also be considered as the end of an ADQL query. But this method should rely on the ADQL grammar. Consequently, at least the token for the semi-colon (;) and the token for the End-Of-File (EOF) should be considered as the correct one to use to indicate the end of an ADQL query.
- Specified by:
isEnd
in interfaceADQLGrammar
- Parameters:
token
- Token to analyze. Might be NULL.- Returns:
true
if the given token represents a query end,false
otherwise.
-
generateParseException
Description copied from interface:ADQLGrammar
Generate aParseException
instance representing the givenException
.Implementation note: If the given
Exception
is already aParseException
this function should do nothing else than returning it as such.- Specified by:
generateParseException
in interfaceADQLGrammar
- Parameters:
ex
- The exception to represent as aParseException
.- Returns:
- The corresponding ParseException.
-