org.eclipse.rdf4j.query.parser

## Class QueryParserUtil

- java.lang.Object
- - org.eclipse.rdf4j.query.parser.QueryParserUtil

-     public class QueryParserUtil
      extends Object

  Utility class for creating query parsers and parsing queries in various query languages.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryParserUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static QueryParser` | `createParser(QueryLanguage ql)`
    `static ParsedBooleanQuery` | `parseBooleanQuery(QueryLanguage ql, String query, String baseURI)` Parses the supplied query into a query model.
    `static ParsedGraphQuery` | `parseGraphQuery(QueryLanguage ql, String query, String baseURI)` Parses the supplied query into a query model.
    `static ParsedOperation` | `parseOperation(QueryLanguage ql, String operation, String baseURI)` Parses the supplied operation into a query model.
    `static ParsedQuery` | `parseQuery(QueryLanguage ql, String query, String baseURI)` Parses the supplied query into a query model.
    `static ParsedTupleQuery` | `parseTupleQuery(QueryLanguage ql, String query, String baseURI)` Parses the supplied query into a query model.
    `static ParsedUpdate` | `parseUpdate(QueryLanguage ql, String update, String baseURI)` Parses the supplied update operation into a query model.
    `static String` | `removeSPARQLQueryProlog(String queryString)` Removes SPARQL prefix and base declarations, if any, from the supplied SPARQL query string.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryParserUtil

          public QueryParserUtil()

  - ### Method Detail

    - #### createParser

          public static QueryParser createParser(QueryLanguage ql)
                                          throws UnsupportedQueryLanguageException

      Throws:
        `UnsupportedQueryLanguageException`

    - #### parseOperation

          public static ParsedOperation parseOperation(QueryLanguage ql,
                                                       String operation,
                                                       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,
                                                 String update,
                                                 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.

    - #### parseQuery

          public static ParsedQuery parseQuery(QueryLanguage ql,
                                               String query,
                                               String baseURI)
                                        throws MalformedQueryException,
                                               UnsupportedQueryLanguageException

      Parses the supplied query into a query model.
      Parameters:
        `ql` - The language in which the query is formulated.
        `query` - The query.
        `baseURI` - The base URI to resolve any relative URIs that are in the query against, can be `null` if the query does not contain any relative URIs.
      Returns:
        The query model for the parsed query.
      Throws:
        `MalformedQueryException` - If the supplied query was malformed.
        `UnsupportedQueryLanguageException` - If the specified query language is not supported.

    - #### parseTupleQuery

          public static ParsedTupleQuery parseTupleQuery(QueryLanguage ql,
                                                         String query,
                                                         String baseURI)
                                                  throws MalformedQueryException,
                                                         UnsupportedQueryLanguageException

      Parses the supplied query into a query model.
      Parameters:
        `ql` - The language in which the query is formulated.
        `query` - The query.
      Returns:
        The query model for the parsed query.
      Throws:
        `IllegalArgumentException` - If the supplied query is not a tuple query.
        `MalformedQueryException` - If the supplied query was malformed.
        `UnsupportedQueryLanguageException` - If the specified query language is not supported.

    - #### parseGraphQuery

          public static ParsedGraphQuery parseGraphQuery(QueryLanguage ql,
                                                         String query,
                                                         String baseURI)
                                                  throws MalformedQueryException,
                                                         UnsupportedQueryLanguageException

      Parses the supplied query into a query model.
      Parameters:
        `ql` - The language in which the query is formulated.
        `query` - The query.
      Returns:
        The query model for the parsed query.
      Throws:
        `IllegalArgumentException` - If the supplied query is not a graph query.
        `MalformedQueryException` - If the supplied query was malformed.
        `UnsupportedQueryLanguageException` - If the specified query language is not supported.

    - #### parseBooleanQuery

          public static ParsedBooleanQuery parseBooleanQuery(QueryLanguage ql,
                                                             String query,
                                                             String baseURI)
                                                      throws MalformedQueryException,
                                                             UnsupportedQueryLanguageException

      Parses the supplied query into a query model.
      Parameters:
        `ql` - The language in which the query is formulated.
        `query` - The query.
      Returns:
        The query model for the parsed query.
      Throws:
        `IllegalArgumentException` - If the supplied query is not a graph query.
        `MalformedQueryException` - If the supplied query was malformed.
        `UnsupportedQueryLanguageException` - If the specified query language is not supported.

    - #### removeSPARQLQueryProlog

          public static String removeSPARQLQueryProlog(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.

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.