Class SPARQLUtil


  • public final class SPARQLUtil
    extends java.lang.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 class  SPARQLUtil.QueryType  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long NO_LIMIT  
      static long NO_OFFSET  
      static java.lang.String PLAN_HEADER  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildRemoveQuery​(Statement theStmtPattern)
      Builds a SPARQL Update remove query based on a Statement Pattern
      static java.lang.Iterable<Namespace> getNamespaces​(java.lang.String theQuery)
      Creates an iterable of namespaces by parsing the prefix declarations in a query string but does so lazily.
      static SPARQLUtil.QueryType getType​(java.lang.String theQuery)
      Return the type of SPARQL query contained in the string.
      static java.lang.String removeSPARQLQueryProlog​(java.lang.String theQuery)
      Forked from Sesame's QueryParserUtil#removeSPARQLQueryProlog to use pre-compiled Patterns.
      static java.lang.String toQuery​(java.lang.String theQuery, java.lang.String reasoningSchema, long theOffset, long theLimit, java.util.Map<java.lang.String,​Value> theBindings, Dataset theDataset)  
      • Methods inherited from class java.lang.Object

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

      • getType

        public static SPARQLUtil.QueryType getType​(java.lang.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
      • toQuery

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

        public static java.lang.String removeSPARQLQueryProlog​(java.lang.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 java.lang.Iterable<Namespace> getNamespaces​(java.lang.String theQuery)
        Creates an iterable of namespaces by parsing the prefix declarations in a query string but does so lazily.
      • buildRemoveQuery

        public static java.lang.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