public class ADQLParser extends java.lang.Object implements ADQLParserConstants
Parses an ADQL query thanks to the Query()
function.
This parser is able, thanks to a QueryChecker
object, to check each ADQLQuery 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 no QueryChecker
. Thus you must extend QueryChecker
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 of ADQLQueryFactory
(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.
QueryChecker
,
ADQLQueryFactory
Modifier and Type | Field and Description |
---|---|
Token |
jj_nt
Next token.
|
Token |
token
Current token.
|
ADQLParserTokenManager |
token_source
Generated Token Manager.
|
ABS, ACOS, AND, AREA, AS, ASC, ASIN, ASTERISK, ATAN, ATAN2, AVG, BETWEEN, BOX, 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_BY, 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_BY, OUTER, PI, PLUS, POINT, POLYGON, POWER, QUANTIFIER, RADIANS, RAND, REGION, REGULAR_IDENTIFIER, RIGHT, RIGHT_PAR, ROUND, SCIENTIFIC_NUMBER, SELECT, SIN, SQRT, STRING_LITERAL, SUM, TAN, tokenImage, TOP, TRUNCATE, UNSIGNED_FLOAT, UNSIGNED_INTEGER, USING, WHERE, WithinComment, WithinDelimitedId, WithinString
Constructor and 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 a ADQLQueryFactory.
|
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 encoding
|
ADQLParser(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(QueryChecker checker)
Builds an ADQL parser without a query to parse but with a QueryChecker.
|
ADQLParser(QueryChecker checker,
ADQLQueryFactory factory)
Builds an ADQL parser without a query to parse but with a QueryChecker and a ADQLQueryFactory.
|
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.
|
public ADQLParserTokenManager token_source
public Token token
public Token jj_nt
public ADQLParser()
public ADQLParser(QueryChecker checker, ADQLQueryFactory factory)
checker
- The object to use to check each ADQLQuery.factory
- The object to use to build an object representation of the given ADQL query.public ADQLParser(QueryChecker checker)
checker
- The object to use to check each ADQLQuery.public ADQLParser(ADQLQueryFactory factory)
factory
- The object to use to build an object representation of the given ADQL query.public ADQLParser(java.io.InputStream stream, QueryChecker checker, ADQLQueryFactory factory)
stream
- The stream in which the ADQL query to parse is given.checker
- The object to use to check each ADQLQuery.factory
- The object to use to build an object representation of the given ADQL query.public ADQLParser(java.io.InputStream stream, QueryChecker checker)
stream
- The stream in which the ADQL query to parse is given.checker
- The object to use to check each ADQLQuery.public ADQLParser(java.io.InputStream stream, ADQLQueryFactory factory)
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.public ADQLParser(java.io.InputStream stream, java.lang.String encoding, QueryChecker checker, ADQLQueryFactory factory)
stream
- The stream in which the ADQL query to parse is given.encoding
- The supplied encoding.checker
- The object to use to check each ADQLQuery.factory
- The object to use to build an object representation of the given ADQL query.public ADQLParser(java.io.InputStream stream, java.lang.String encoding, QueryChecker checker)
stream
- The stream in which the ADQL query to parse is given.encoding
- The supplied encoding.checker
- The object to use to check each ADQLQuery.public ADQLParser(java.io.InputStream stream, java.lang.String encoding, ADQLQueryFactory factory)
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.public ADQLParser(java.io.Reader reader, QueryChecker checker, ADQLQueryFactory factory)
reader
- The reader in which the ADQL query to parse is given.checker
- The object to use to check each ADQLQuery.factory
- The object to use to build an object representation of the given ADQL query.public ADQLParser(java.io.Reader reader, QueryChecker checker)
reader
- The reader in which the ADQL query to parse is given.checker
- The object to use to check each ADQLQuery.public ADQLParser(java.io.Reader reader, ADQLQueryFactory factory)
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.public ADQLParser(ADQLParserTokenManager tm, QueryChecker checker, ADQLQueryFactory factory)
tm
- The manager which associates a token to a numeric code.checker
- The object to use to check each ADQLQuery.factory
- The object to use to build an object representation of the given ADQL query.public ADQLParser(ADQLParserTokenManager tm, QueryChecker checker)
tm
- The manager which associates a token to a numeric code.checker
- The object to use to check each ADQLQuery.public ADQLParser(ADQLParserTokenManager tm, ADQLQueryFactory factory)
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.public ADQLParser(java.io.InputStream stream)
public ADQLParser(java.io.InputStream stream, java.lang.String encoding)
public ADQLParser(java.io.Reader stream)
public ADQLParser(ADQLParserTokenManager tm)
public final ADQLQuery parseQuery() throws ParseException
ParseException
- If there is at least one syntactic error.Query()
public final ADQLQuery parseQuery(java.lang.String q) throws ParseException
q
- The ADQL query to parse.ParseException
- If there is at least one syntactic error.ReInit(java.io.InputStream)
,
setDebug(boolean)
,
Query()
public final ADQLQuery parseQuery(java.io.InputStream stream) throws ParseException
stream
- The stream which contains the ADQL query to parse.ParseException
- If there is at least one syntactic error.ReInit(java.io.InputStream)
,
setDebug(boolean)
,
Query()
public final void setDebug(boolean debug)
public final QueryChecker getQueryChecker()
public final void setQueryChecker(QueryChecker checker)
public final ADQLQueryFactory getQueryFactory()
public final void setQueryFactory(ADQLQueryFactory factory)
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:
args
- java.lang.Exception
public final ADQLQuery Query() throws ParseException
ReInit(java.io.InputStream)
or in the parseQuery functions.ParseException
- If the query syntax is incorrect.public final ADQLQuery QueryExpression() throws ParseException
ParseException
public final ADQLQuery SubQueryExpression() throws ParseException
ParseException
public final void Select() throws ParseException
ParseException
public final SelectItem SelectItem() throws ParseException
ParseException
public final void From() throws ParseException
ParseException
public final void Where() throws ParseException
ParseException
public final void GroupBy() throws ParseException
ParseException
public final void Having() throws ParseException
ParseException
public final void OrderBy() throws ParseException
ParseException
public final IdentifierItems.IdentifierItem Identifier() throws ParseException
ParseException
public final IdentifierItems TableName() throws ParseException
IdentifierItems
which contains at most three items: catalogName, schemaName and tableName.ParseException
public final IdentifierItems ColumnName() throws ParseException
IdentifierItems
which contains at most four items: catalogName, schemaName, tableName and columnName.ParseException
public final ADQLColumn Column() throws ParseException
ParseException
public final ColumnReference ColumnRef() throws ParseException
ParseException
public final ADQLOrder OrderItem() throws ParseException
ParseException
public final FromContent SimpleTableRef() throws ParseException
ParseException
public final FromContent TableRef() throws ParseException
ParseException
public final FromContent JoinedTable() throws ParseException
ParseException
public final ADQLJoin JoinSpecification(FromContent leftTable) throws ParseException
ParseException
public final java.lang.String String() throws ParseException
ParseException
public final java.lang.String UnsignedNumeric() throws ParseException
ParseException
public final java.lang.String UnsignedFloat() throws ParseException
ParseException
public final java.lang.String SignedInteger() throws ParseException
ParseException
public final ADQLOperand NumericValueExpressionPrimary() throws ParseException
ParseException
public final ADQLOperand StringValueExpressionPrimary() throws ParseException
ParseException
public final ADQLOperand ValueExpression() throws ParseException
ParseException
public final ADQLOperand NumericExpression() throws ParseException
ParseException
public final ADQLOperand NumericTerm() throws ParseException
ParseException
public final ADQLOperand Factor() throws ParseException
ParseException
public final ADQLOperand StringExpression() throws ParseException
ParseException
public final ADQLOperand StringFactor() throws ParseException
ParseException
public final GeometryFunction.GeometryValue<GeometryFunction> GeometryExpression() throws ParseException
ParseException
public final ClauseConstraints ConditionsList(ClauseConstraints clause) throws ParseException
ParseException
public final ADQLConstraint Constraint() throws ParseException
ParseException
public final ADQLConstraint Predicate() throws ParseException
ParseException
public final Comparison ComparisonEnd(ADQLOperand leftOp) throws ParseException
ParseException
public final Between BetweenEnd(ADQLOperand leftOp) throws ParseException
ParseException
public final In InEnd(ADQLOperand leftOp) throws ParseException
ParseException
public final SQLFunction SqlFunction() throws ParseException
ParseException
public final ADQLOperand[] Coordinates() throws ParseException
ParseException
public final GeometryFunction GeometryFunction() throws ParseException
ParseException
public final ADQLOperand CoordinateSystem() throws ParseException
ParseException
public final GeometryFunction GeometryValueFunction() throws ParseException
ParseException
public final PointFunction Point() throws ParseException
ParseException
public final GeometryFunction ExtractCoordSys() throws ParseException
ParseException
public final ADQLFunction NumericFunction() throws ParseException
ParseException
public final MathFunction MathFunction() throws ParseException
ParseException
public final MathFunction TrigFunction() throws ParseException
ParseException
public final UserDefinedFunction UserDefinedFunction() throws ParseException
ParseException
public void ReInit(java.io.InputStream stream)
public void ReInit(java.io.InputStream stream, java.lang.String encoding)
public void ReInit(java.io.Reader stream)
public void ReInit(ADQLParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()