Class AdqlValidator


  • public class AdqlValidator
    extends java.lang.Object
    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 Classes 
      Modifier and Type Class Description
      static interface  AdqlValidator.ValidatorTable
      Defines table metadata for tables known to the validator.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static AdqlValidator createValidator​(AdqlValidator.ValidatorTable[] vtables, TapLanguage lang)
      Creates an instance given a set of table metadata and a TapLanguage description object.
      java.lang.String fixup​(java.lang.String query)
      Attempts to fix common errors in a submitted query.
      static void main​(java.lang.String[] args)
      Tests parser.
      void validate​(java.lang.String query)
      Validates an ADQL string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AdqlValidator

        public AdqlValidator​(AdqlValidator.ValidatorTable[] vtables,
                             adql.db.FunctionDef[] udfs,
                             java.lang.String[] geoFuncs)
        Constructor. Note empty arrays restrict possibilities (to none), but null values allow anything.
        Parameters:
        vtables - table metadata for database to be checked against
        udfs - array of permitted user-defined-functions, or null to permit all (but ignored if vtables is null)
        geoFuncs - array of permitted ADQL geometry function names, or null to permit all those defined by ADQL (sec 2.4) (but ignored if vtables is null)
    • Method Detail

      • validate

        public void validate​(java.lang.String query)
                      throws java.lang.Throwable
        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:
        java.lang.Throwable - if the string is not valid ADQL
      • fixup

        public java.lang.String fixup​(java.lang.String query)
        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

        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 ADQL geometry functions are supported. In the case of no description of UDFs and geom functions, no restrictions are imposed.
        Parameters:
        vtables - table metadata
        lang - language specifics
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Throwable,
                                java.io.IOException,
                                org.xml.sax.SAXException
        Tests parser. Use -h for usage.
        Throws:
        java.lang.Throwable
        java.io.IOException
        org.xml.sax.SAXException