Class ADQLParser
- java.lang.Object
-
- adql.parser.ADQLParser
-
- All Implemented Interfaces:
ADQLParserConstants
public class ADQLParser extends java.lang.Object implements ADQLParserConstants
Parses an ADQL query thanks to theQuery()
function.This parser is able, thanks to a
QueryChecker
object, to check eachADQLQuery
just after its generation. It could be used to check the consistency between the ADQL query to parse and the "database" on which the query must be executed. By default, there is noQueryChecker
. Thus you must extendQueryChecker
to check semantically all generated ADQLQuery objects.To create an object representation of the given ADQL query, this parser uses a
ADQLQueryFactory
object. So if you want customize some object (ie. CONTAINS) of this representation you just have to extend the corresponding default object (ie. ContainsFunction) and to extend the corresponding function ofADQLQueryFactory
(ie. createContains(...)).WARNING: To modify this class it's strongly encouraged to modify the .jj file in the section between PARSER_BEGIN and PARSER_END and to re-compile it with JavaCC.
- Version:
- 1.4 (01/2018)
- Author:
- Grégory Mantelet (CDS;ARI) - gmantele@ari.uni-heidelberg.de
- See Also:
QueryChecker
,ADQLQueryFactory
-
-
Field Summary
Fields Modifier and Type Field Description Token
jj_nt
Next token.Token
token
Current token.ADQLParserTokenManager
token_source
Generated Token Manager.-
Fields inherited from interface adql.parser.ADQLParserConstants
ABS, ACOS, AND, AREA, AS, ASC, ASIN, ASTERISK, ATAN, ATAN2, AVG, BETWEEN, BOX, BY, CEILING, CENTROID, CIRCLE, COMMA, CONCAT, CONTAINS, COORD1, COORD2, COORDSYS, COS, COT, COUNT, DEFAULT, DEGREES, DELIMITED_IDENTIFIER, DESC, DIGIT, DISTANCE, DIVIDE, DOT, EOF, EOQ, EQUAL, EXISTS, EXP, FLOOR, FROM, FULL, GREATER_EQUAL_THAN, GREATER_THAN, GROUP, HAVING, IN, INNER, INTERSECTS, IS, JOIN, LEFT, LEFT_PAR, LESS_EQUAL_THAN, LESS_THAN, Letter, LIKE, LOG, LOG10, MAX, MIN, MINUS, MOD, NATURAL, NOT, NOT_EQUAL, NULL, ON, OR, ORDER, OUTER, PI, PLUS, POINT, POLYGON, POWER, QUANTIFIER, RADIANS, RAND, REGION, REGULAR_IDENTIFIER, RIGHT, RIGHT_PAR, ROUND, SCIENTIFIC_NUMBER, SELECT, SIN, SQL_RESERVED_WORD, SQRT, STRING_LITERAL, SUM, TAN, tokenImage, TOP, TRUNCATE, UNSIGNED_FLOAT, UNSIGNED_INTEGER, USING, WHERE, WithinDelimitedId, WithinString
-
-
Constructor Summary
Constructors Constructor Description ADQLParser()
Builds an ADQL parser without a query to parse.ADQLParser(ADQLParserTokenManager tm)
Constructor with generated Token Manager.ADQLParser(ADQLParserTokenManager tm, ADQLQueryFactory factory)
Builds a parser with another token manager.ADQLParser(ADQLParserTokenManager tm, QueryChecker checker)
Builds a parser with another token manager.ADQLParser(ADQLParserTokenManager tm, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with another token manager.ADQLParser(ADQLQueryFactory factory)
Builds an ADQL parser without a query to parse but with aADQLQueryFactory
.ADQLParser(QueryChecker checker)
Builds an ADQL parser without a query to parse but with aQueryChecker
.ADQLParser(QueryChecker checker, ADQLQueryFactory factory)
Builds an ADQL parser without a query to parse but with aQueryChecker
and aADQLQueryFactory
.ADQLParser(java.io.InputStream stream)
Constructor with InputStream.ADQLParser(java.io.InputStream stream, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.ADQLParser(java.io.InputStream stream, QueryChecker checker)
Builds a parser with a stream containing the query to parse.ADQLParser(java.io.InputStream stream, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.ADQLParser(java.io.InputStream stream, java.lang.String encoding)
Constructor with InputStream and supplied encodingADQLParser(java.io.InputStream stream, java.lang.String encoding, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.ADQLParser(java.io.InputStream stream, java.lang.String encoding, QueryChecker checker)
Builds a parser with a stream containing the query to parse.ADQLParser(java.io.InputStream stream, java.lang.String encoding, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.ADQLParser(java.io.Reader stream)
Constructor.ADQLParser(java.io.Reader reader, ADQLQueryFactory factory)
Builds a parser with a reader containing the query to parse.ADQLParser(java.io.Reader reader, QueryChecker checker)
Builds a parser with a reader containing the query to parse.ADQLParser(java.io.Reader reader, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with a reader containing the query to parse.
-
Method Summary
-
-
-
Field Detail
-
token_source
public ADQLParserTokenManager token_source
Generated Token Manager.
-
token
public Token token
Current token.
-
jj_nt
public Token jj_nt
Next token.
-
-
Constructor Detail
-
ADQLParser
public ADQLParser()
Builds an ADQL parser without a query to parse.
-
ADQLParser
public ADQLParser(QueryChecker checker, ADQLQueryFactory factory)
Builds an ADQL parser without a query to parse but with aQueryChecker
and aADQLQueryFactory
.- Parameters:
checker
- The object to use to check eachADQLQuery
.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(QueryChecker checker)
Builds an ADQL parser without a query to parse but with aQueryChecker
.- Parameters:
checker
- The object to use to check eachADQLQuery
.
-
ADQLParser
public ADQLParser(ADQLQueryFactory factory)
Builds an ADQL parser without a query to parse but with aADQLQueryFactory
.- Parameters:
factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.- Parameters:
stream
- The stream in which the ADQL query to parse is given.checker
- The object to use to check eachADQLQuery
.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, QueryChecker checker)
Builds a parser with a stream containing the query to parse.- Parameters:
stream
- The stream in which the ADQL query to parse is given.checker
- The object to use to check eachADQLQuery
.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.- Parameters:
stream
- The stream in which the ADQL query to parse is given.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, java.lang.String encoding, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.- Parameters:
stream
- The stream in which the ADQL query to parse is given.encoding
- The supplied encoding.checker
- The object to use to check eachADQLQuery
.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, java.lang.String encoding, QueryChecker checker)
Builds a parser with a stream containing the query to parse.- Parameters:
stream
- The stream in which the ADQL query to parse is given.encoding
- The supplied encoding.checker
- The object to use to check eachADQLQuery
.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, java.lang.String encoding, ADQLQueryFactory factory)
Builds a parser with a stream containing the query to parse.- Parameters:
stream
- The stream in which the ADQL query to parse is given.encoding
- The supplied encoding.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.Reader reader, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with a reader containing the query to parse.- Parameters:
reader
- The reader in which the ADQL query to parse is given.checker
- The object to use to check eachADQLQuery
.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.Reader reader, QueryChecker checker)
Builds a parser with a reader containing the query to parse.- Parameters:
reader
- The reader in which the ADQL query to parse is given.checker
- The object to use to check eachADQLQuery
.
-
ADQLParser
public ADQLParser(java.io.Reader reader, ADQLQueryFactory factory)
Builds a parser with a reader containing the query to parse.- Parameters:
reader
- The reader in which the ADQL query to parse is given.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(ADQLParserTokenManager tm, QueryChecker checker, ADQLQueryFactory factory)
Builds a parser with another token manager.- Parameters:
tm
- The manager which associates a token to a numeric code.checker
- The object to use to check eachADQLQuery
.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(ADQLParserTokenManager tm, QueryChecker checker)
Builds a parser with another token manager.- Parameters:
tm
- The manager which associates a token to a numeric code.checker
- The object to use to check eachADQLQuery
.
-
ADQLParser
public ADQLParser(ADQLParserTokenManager tm, ADQLQueryFactory factory)
Builds a parser with another token manager.- Parameters:
tm
- The manager which associates a token to a numeric code.factory
- The object to use to build an object representation of the given ADQL query.
-
ADQLParser
public ADQLParser(java.io.InputStream stream)
Constructor with InputStream.
-
ADQLParser
public ADQLParser(java.io.InputStream stream, java.lang.String encoding)
Constructor with InputStream and supplied encoding
-
ADQLParser
public ADQLParser(java.io.Reader stream)
Constructor.
-
ADQLParser
public ADQLParser(ADQLParserTokenManager tm)
Constructor with generated Token Manager.
-
-
Method Detail
-
parseQuery
public final ADQLQuery parseQuery() throws ParseException
Parses the query given at the creation of this parser or in the ReInit functions.- Returns:
- The object representation of the given ADQL query.
- Throws:
ParseException
- If there is at least one syntactic error.- See Also:
Query()
-
parseQuery
public final ADQLQuery parseQuery(java.lang.String q) throws ParseException
Parses the query given in parameter.- Parameters:
q
- The ADQL query to parse.- Returns:
- The object representation of the given ADQL query.
- Throws:
ParseException
- If there is at least one syntactic error.- See Also:
ReInit(java.io.InputStream)
,setDebug(boolean)
,Query()
-
parseQuery
public final ADQLQuery parseQuery(java.io.InputStream stream) throws ParseException
Parses the query contained in the stream given in parameter.- Parameters:
stream
- The stream which contains the ADQL query to parse.- Returns:
- The object representation of the given ADQL query.
- Throws:
ParseException
- If there is at least one syntactic error.- See Also:
ReInit(java.io.InputStream)
,setDebug(boolean)
,Query()
-
setDebug
public final void setDebug(boolean debug)
-
getQueryChecker
public final QueryChecker getQueryChecker()
-
setQueryChecker
public final void setQueryChecker(QueryChecker checker)
-
getQueryFactory
public final ADQLQueryFactory getQueryFactory()
-
setQueryFactory
public final void setQueryFactory(ADQLQueryFactory factory)
-
main
public static final void main(java.lang.String[] args) throws java.lang.Exception
Gets the specified ADQL query and parses the given ADQL query. The SQL translation is then printed if the syntax is correct.ONLY the syntax is checked: the query is NOT EXECUTED !
Supplied parameters are:
- [-debug] -url http://...
- [-debug] -file ...
- [-debug] -query SELECT...
- Parameters:
args
-- Throws:
java.lang.Exception
-
Query
public final ADQLQuery Query() throws ParseException
Parses the ADQL query given at the parser creation or in theReInit(java.io.InputStream)
or in the parseQuery functions.- Returns:
- The object representation of the query.
- Throws:
ParseException
- If the query syntax is incorrect.
-
QueryExpression
public final ADQLQuery QueryExpression() throws ParseException
- Throws:
ParseException
-
SubQueryExpression
public final ADQLQuery SubQueryExpression() throws ParseException
- Throws:
ParseException
-
Select
public final void Select() throws ParseException
- Throws:
ParseException
-
SelectItem
public final SelectItem SelectItem() throws ParseException
- Throws:
ParseException
-
From
public final void From() throws ParseException
- Throws:
ParseException
-
Where
public final void Where() throws ParseException
- Throws:
ParseException
-
GroupBy
public final void GroupBy() throws ParseException
- Throws:
ParseException
-
Having
public final void Having() throws ParseException
- Throws:
ParseException
-
OrderBy
public final void OrderBy() throws ParseException
- Throws:
ParseException
-
Identifier
public final IdentifierItems.IdentifierItem Identifier() throws ParseException
- Throws:
ParseException
-
TableName
public final IdentifierItems TableName() throws ParseException
Extracts the name of a table with its possible catalog and schema prefixes.- Returns:
- A
IdentifierItems
which contains at most three items: catalogName, schemaName and tableName. - Throws:
ParseException
-
ColumnName
public final IdentifierItems ColumnName() throws ParseException
Extracts the name of a column with its possible catalog, schema and table prefixes.- Returns:
- A
IdentifierItems
which contains at most four items: catalogName, schemaName, tableName and columnName. - Throws:
ParseException
-
Column
public final ADQLColumn Column() throws ParseException
- Throws:
ParseException
-
OrderItem
public final ADQLOrder OrderItem() throws ParseException
- Throws:
ParseException
-
SimpleTableRef
public final FromContent SimpleTableRef() throws ParseException
- Throws:
ParseException
-
TableRef
public final FromContent TableRef() throws ParseException
- Throws:
ParseException
-
JoinedTable
public final FromContent JoinedTable() throws ParseException
- Throws:
ParseException
-
JoinSpecification
public final ADQLJoin JoinSpecification(FromContent leftTable) throws ParseException
- Throws:
ParseException
-
String
public final StringConstant String() throws ParseException
- Throws:
ParseException
-
UnsignedNumeric
public final NumericConstant UnsignedNumeric() throws ParseException
- Throws:
ParseException
-
UnsignedFloat
public final NumericConstant UnsignedFloat() throws ParseException
- Throws:
ParseException
-
SignedInteger
public final NumericConstant SignedInteger() throws ParseException
- Throws:
ParseException
-
NumericValueExpressionPrimary
public final ADQLOperand NumericValueExpressionPrimary() throws ParseException
- Throws:
ParseException
-
StringValueExpressionPrimary
public final ADQLOperand StringValueExpressionPrimary() throws ParseException
- Throws:
ParseException
-
ValueExpression
public final ADQLOperand ValueExpression() throws ParseException
- Throws:
ParseException
-
NumericExpression
public final ADQLOperand NumericExpression() throws ParseException
- Throws:
ParseException
-
NumericTerm
public final ADQLOperand NumericTerm() throws ParseException
- Throws:
ParseException
-
Factor
public final ADQLOperand Factor() throws ParseException
- Throws:
ParseException
-
StringExpression
public final ADQLOperand StringExpression() throws ParseException
- Throws:
ParseException
-
StringFactor
public final ADQLOperand StringFactor() throws ParseException
- Throws:
ParseException
-
GeometryExpression
public final GeometryFunction.GeometryValue<GeometryFunction> GeometryExpression() throws ParseException
- Throws:
ParseException
-
ConditionsList
public final ClauseConstraints ConditionsList(ClauseConstraints clause) throws ParseException
- Throws:
ParseException
-
Constraint
public final ADQLConstraint Constraint() throws ParseException
- Throws:
ParseException
-
Predicate
public final ADQLConstraint Predicate() throws ParseException
- Throws:
ParseException
-
ComparisonEnd
public final Comparison ComparisonEnd(ADQLOperand leftOp) throws ParseException
- Throws:
ParseException
-
BetweenEnd
public final Between BetweenEnd(ADQLOperand leftOp) throws ParseException
- Throws:
ParseException
-
InEnd
public final In InEnd(ADQLOperand leftOp) throws ParseException
- Throws:
ParseException
-
SqlFunction
public final SQLFunction SqlFunction() throws ParseException
- Throws:
ParseException
-
Coordinates
public final ADQLOperand[] Coordinates() throws ParseException
- Throws:
ParseException
-
GeometryFunction
public final GeometryFunction GeometryFunction() throws ParseException
- Throws:
ParseException
-
CoordinateSystem
public final ADQLOperand CoordinateSystem() throws ParseException
- Throws:
ParseException
-
GeometryValueFunction
public final GeometryFunction GeometryValueFunction() throws ParseException
- Throws:
ParseException
-
Point
public final PointFunction Point() throws ParseException
- Throws:
ParseException
-
ExtractCoordSys
public final GeometryFunction ExtractCoordSys() throws ParseException
- Throws:
ParseException
-
NumericFunction
public final ADQLFunction NumericFunction() throws ParseException
- Throws:
ParseException
-
MathFunction
public final MathFunction MathFunction() throws ParseException
- Throws:
ParseException
-
TrigFunction
public final MathFunction TrigFunction() throws ParseException
- Throws:
ParseException
-
UserDefinedFunction
public final UserDefinedFunction UserDefinedFunction() throws ParseException
- Throws:
ParseException
-
ReInit
public void ReInit(java.io.InputStream stream)
Reinitialise.
-
ReInit
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
Reinitialise.
-
ReInit
public void ReInit(java.io.Reader stream)
Reinitialise.
-
ReInit
public void ReInit(ADQLParserTokenManager tm)
Reinitialise.
-
getNextToken
public final Token getNextToken()
Get the next Token.
-
getToken
public final Token getToken(int index)
Get the specific Token.
-
generateParseException
public ParseException generateParseException()
Generate ParseException.
-
enable_tracing
public final void enable_tracing()
Enable tracing.
-
disable_tracing
public final void disable_tracing()
Disable tracing.
-
-