Class SPARQLUtil

java.lang.Object
com.complexible.common.rdf.query.SPARQLUtil

public final class SPARQLUtil extends Object

Collection of utility methods for working with SPARQL strings

Since:
1.2
Version:
6.0
Author:
Evren Sirin, Michael Grove, Edgar Rodriguez-Diaz
  • Field Details

  • Method Details

    • getType

      public static SPARQLUtil.QueryType getType(String theQuery)
      Return the type of SPARQL query contained in the string. This is based on the code from the Sesame QueryParserUtil class.
      Parameters:
      theQuery - the query string
      Returns:
      the type of the SPARQL query in the string
    • isWriteOnlyUpdate

      public static boolean isWriteOnlyUpdate(String theQuery)
      Checks if the given SPARQL query is a write-only update operation (no read/WHERE component). Write-only operations include: INSERT DATA, DELETE DATA, LOAD, CLEAR, DROP, CREATE, COPY, MOVE, ADD.
      Parameters:
      theQuery - the query string
      Returns:
      true if the query is a write-only update with no read component, false otherwise
    • toQuery

      @Nonnull public static String toQuery(@Nonnull String theQuery, String reasoningSchema, long theOffset, long theLimit, @Nonnull Map<String,Value> theBindings, @Nonnull Dataset theDataset)
    • removeSPARQLQueryProlog

      public static String removeSPARQLQueryProlog(String theQuery)
      Forked from Sesame's QueryParserUtil#removeSPARQLQueryProlog to use pre-compiled Patterns.
      Parameters:
      theQuery - the original query string
      Returns:
      the query string w/o the prolog
    • getNamespaces

      public static Iterable<Namespace> getNamespaces(String theQuery)
      Creates an iterable of namespaces by parsing the prefix declarations in a query string but does so lazily.
    • buildRemoveQuery

      public static String buildRemoveQuery(Statement theStmtPattern)
      Builds a SPARQL Update remove query based on a Statement Pattern
      Parameters:
      theStmtPattern - the Statement SPOC pattern to fill up the SPARQL query
      Returns:
      the Query string