Class QueryParserUtil


  • public class QueryParserUtil
    extends java.lang.Object
    Utility class for creating query parsers and parsing queries in various query languages.
    • Constructor Detail

      • QueryParserUtil

        public QueryParserUtil()
    • Method Detail

      • parseOperation

        public static ParsedOperation parseOperation​(QueryLanguage ql,
                                                     java.lang.String operation,
                                                     java.lang.String baseURI)
                                              throws MalformedQueryException
        Parses the supplied operation into a query model.
        Parameters:
        ql - The language in which the operation is formulated.
        operation - The operation.
        baseURI - The base URI to resolve any relative URIs that are in the operation against, can be null if the operation does not contain any relative URIs.
        Returns:
        The model for the parsed operation.
        Throws:
        MalformedQueryException - If the supplied operation was malformed.
        UnsupportedQueryLanguageException - If the specified query language is not supported.
      • parseUpdate

        public static ParsedUpdate parseUpdate​(QueryLanguage ql,
                                               java.lang.String update,
                                               java.lang.String baseURI)
                                        throws MalformedQueryException,
                                               UnsupportedQueryLanguageException
        Parses the supplied update operation into a query model.
        Parameters:
        ql - The language in which the update operation is formulated.
        update - The update operation.
        baseURI - The base URI to resolve any relative URIs that are in the operation against, can be null if the update operation does not contain any relative URIs.
        Returns:
        The model for the parsed update operation.
        Throws:
        MalformedQueryException - If the supplied update operation was malformed.
        UnsupportedQueryLanguageException - If the specified query language is not supported.
      • removeSPARQLQueryProlog

        public static java.lang.String removeSPARQLQueryProlog​(java.lang.String queryString)
        Removes SPARQL prefix and base declarations, if any, from the supplied SPARQL query string. The supplied query string is assumed to be syntactically legal.
        Parameters:
        queryString - a syntactically legal SPARQL query string
        Returns:
        a substring of queryString, with prefix and base declarations removed.