Package uk.ac.starlink.vo
Class AdqlValidator
java.lang.Object
uk.ac.starlink.vo.AdqlValidator
Handles validation of ADQL queries.
In the current implementation the heavy lifting is done by
Gregory Mantelet's ADQL parser.
- Since:
- 3 Oct 2011
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Defines table metadata for tables known to the validator. -
Method Summary
Modifier and TypeMethodDescriptionstatic AdqlValidator
Returns a basic validator instance.static AdqlValidator
createValidator
(AdqlValidator.ValidatorTable[] vtables) Returns a validator instance that knows about available tables.static AdqlValidator
createValidator
(AdqlValidator.ValidatorTable[] vtables, TapLanguage lang) Creates an instance given a set of table metadata and a TapLanguage description object.Attempts to fix common errors in a submitted query.static void
Tests parser.void
setAdqlVersion
(AdqlVersion version) Sets the version of ADQL against which this validator will check.void
setAllowAnyUdf
(boolean isAllowed) Configures whether the parser will allow undeclared functions.void
Validates an ADQL string.
-
Method Details
-
setAdqlVersion
Sets the version of ADQL against which this validator will check.- Parameters:
version
- ADQL version to use, or null for default
-
setAllowAnyUdf
public void setAllowAnyUdf(boolean isAllowed) Configures whether the parser will allow undeclared functions.- Parameters:
isAllowed
- true to allow undeclared functions, false to reject
-
validate
public void validate(String query) throws adql.parser.grammar.ParseException, adql.parser.grammar.TokenMgrError Validates an ADQL string. Any throwable returned hopefully includes useful information about the location and nature of the parse error, but that depends on the implementation.- Parameters:
query
- ADQL query string- Throws:
adql.parser.grammar.ParseException
- if the string is not valid ADQLadql.parser.grammar.TokenMgrError
- if something has gone wrong with the parsing
-
fixup
Attempts to fix common errors in a submitted query. If some changes can be made that would make the query more correct, the fixed query is returned. If no such changes can be made for whatever reason, null is returned.- Parameters:
query
- input ADQL- Returns:
- EITHER ADQL which resembles, but is not identical to, the input but which has a better chance of being correct; OR null
-
createValidator
Returns a basic validator instance.- Returns:
- new vanilla validator
-
createValidator
Returns a validator instance that knows about available tables.- Parameters:
vtables
- table metadata for database to be checked against- Returns:
- vanilla validator
-
createValidator
public static AdqlValidator createValidator(AdqlValidator.ValidatorTable[] vtables, TapLanguage lang) Creates an instance given a set of table metadata and a TapLanguage description object. The language object's TapLanguageFeature map is examined to determine what UDFs and other optional features are supported. In the case that no features are declared, no restrictions are imposed.- Parameters:
vtables
- table metadatalang
- language specifics
-
main
public static void main(String[] args) throws adql.parser.grammar.ParseException, IOException, SAXException Tests parser. Use-h
for usage.- Throws:
adql.parser.grammar.ParseException
IOException
SAXException
-