Package com.complexible.common.rdf.query

# 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

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `SPARQLUtil.QueryType`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `NO_LIMIT`
  `static final long`
  `NO_OFFSET`
  `static final String`
  `PLAN_HEADER`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `buildRemoveQuery(Statement theStmtPattern)`
  Builds a SPARQL Update remove query based on a Statement Pattern
  `static Iterable<Namespace>`
  `getNamespaces(String theQuery)`
  Creates an iterable of namespaces by parsing the prefix declarations in a query string but does so lazily.
  `static SPARQLUtil.QueryType`
  `getType(String theQuery)`
  Return the type of SPARQL query contained in the string.
  `static boolean`
  `isWriteOnlyUpdate(String theQuery)`
  Checks if the given SPARQL query is a write-only update operation (no read/WHERE component).
  `static String`
  `removeSPARQLQueryProlog(String theQuery)`
  Forked from Sesame's `QueryParserUtil#removeSPARQLQueryProlog` to use pre-compiled Patterns.
  `static String`
  `toQuery(String theQuery, String reasoningSchema, long theOffset, long theLimit, Map<String,Value> theBindings, Dataset theDataset)`

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

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

- ## Field Details

  - ### PLAN_HEADER

    public static final String PLAN_HEADER
    See Also:
      - Constant Field Values

  - ### NO_LIMIT

    public static final long NO_LIMIT
    See Also:
      - Constant Field Values

  - ### NO_OFFSET

    public static final long NO_OFFSET
    See Also:
      - Constant Field Values

- ## 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