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 ADQLQueryThe object representation of the ADQL query to parse.protected ADQLQueryFactoryTool 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 ParseExceptionGenerate aParseExceptioninstance representing the givenException.final ADQLQueryFactoryGet theADQLQueryFactoryused by this Grammar Parser to create ADQL object representations (e.g.booleanTell whether the given token represents the end of an ADQL query.final booleanisRegularIdentifier(String idCandidate) Tell whether the given string is a valid ADQL regular identifier.abstract voidReInit(InputStream stream) Re-initialize the input of the ADQL grammar parser.final voidreset(InputStream inputADQLExpression) (Re-)Set the ADQL expression to parse.final voidsetQueryFactory(ADQLQueryFactory factory) Set theADQLQueryFactoryto use in order to create ADQL object representations (e.g.final voidtestRegularIdentifier(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, waitMethods 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:ADQLGrammarGet theADQLQueryFactoryused by this Grammar Parser to create ADQL object representations (e.g. SELECT, column, string, constraint) while building the ADQL query tree- Specified by:
getQueryFactoryin interfaceADQLGrammar- Returns:
- The used
ADQLQueryFactory. Never NULL
-
setQueryFactory
Description copied from interface:ADQLGrammarSet theADQLQueryFactoryto use in order to create ADQL object representations (e.g. SELECT, column, string, constraint) while building the ADQL query tree.- Specified by:
setQueryFactoryin interfaceADQLGrammar- Parameters:
factory- TheADQLQueryFactoryto 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:
resetin interfaceADQLGrammar- Parameters:
inputADQLExpression- ADQL expression to parse.- Throws:
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:ADQLGrammarTell 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:
isRegularIdentifierin interfaceADQLGrammar- Parameters:
idCandidate- The string to test.- Returns:
trueif the given string is a valid regular identifier,falseotherwise.- See Also:
-
testRegularIdentifier
Description copied from interface:ADQLGrammarTest 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, aParseExceptionis thrown.- Specified by:
testRegularIdentifierin 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:ADQLGrammarTell 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:
isEndin interfaceADQLGrammar- Parameters:
token- Token to analyze. Might be NULL.- Returns:
trueif the given token represents a query end,falseotherwise.
-
generateParseException
Description copied from interface:ADQLGrammarGenerate aParseExceptioninstance representing the givenException.Implementation note: If the given
Exceptionis already aParseExceptionthis function should do nothing else than returning it as such.- Specified by:
generateParseExceptionin interfaceADQLGrammar- Parameters:
ex- The exception to represent as aParseException.- Returns:
- The corresponding ParseException.
-