org.topbraid.spin.system
Class ARQFactory

java.lang.Object
  extended by org.topbraid.spin.system.ARQFactory

public class ARQFactory
extends java.lang.Object

A singleton that can create ARQ SPARQL Queries and QueryExecution objects. SPIN API users should use the provided methods here.

Author:
Holger Knublauch

Constructor Summary
ARQFactory()
           
 
Method Summary
 java.lang.String createPrefixDeclarations(Model model)
          Same as createPrefixDeclarations(model, true).
 java.lang.String createPrefixDeclarations(Model model, boolean includeExtraPrefixes)
          Creates SPARQL prefix declarations for a given Model.
 Query createQuery(Model model, java.lang.String partialQuery)
          Creates a new Query from a partial query (possibly lacking PREFIX declarations), using the ARQ syntax specified by getSyntax.
 QueryExecution createQueryExecution(Query query, Model model)
          Creates a QueryExecution for a given Query in a given Model, with no initial bindings.
 QueryExecution createQueryExecution(Query query, Model model, QuerySolutionMap initialBinding)
          Creates a QueryExecution for a given Query in a given Model, with some given initial bindings.
 QueryEngineHTTP createRemoteQueryExecution(Query query)
          Creates a remote QueryExecution on a given Query.
 QueryEngineHTTP createRemoteQueryExecution(Query query, java.util.List<java.lang.String> graphURIs)
           
static ARQFactory get()
          Gets the singleton instance of this class.
 Dataset getDataset()
          Deprecated. Use the other variation instead
 Dataset getDataset(Model defaultModel)
           
static java.util.List<java.lang.String> getNamedGraphURIs(Query query)
          Gets a list of named graphs (GRAPH elements) mentioned in a given Query.
 Syntax getSyntax()
          The ARQ Syntax used by default: Syntax.syntaxARQ.
static void set(ARQFactory value)
          Changes the singleton to some subclass.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ARQFactory

public ARQFactory()
Method Detail

get

public static ARQFactory get()
Gets the singleton instance of this class.

Returns:
the singleton

set

public static void set(ARQFactory value)
Changes the singleton to some subclass.

Parameters:
value - the new ARQFactory (not null)

createPrefixDeclarations

public java.lang.String createPrefixDeclarations(Model model)
Same as createPrefixDeclarations(model, true).

Parameters:
model - the Model to create prefix declarations for
Returns:
the prefix declarations

createPrefixDeclarations

public java.lang.String createPrefixDeclarations(Model model,
                                                 boolean includeExtraPrefixes)
Creates SPARQL prefix declarations for a given Model.

Parameters:
model - the Model to get the prefixes from
includeExtraPrefixes - true to also include implicit prefixes like afn
Returns:
the prefix declarations

createQuery

public Query createQuery(Model model,
                         java.lang.String partialQuery)
Creates a new Query from a partial query (possibly lacking PREFIX declarations), using the ARQ syntax specified by getSyntax.

Parameters:
model - the Model to operate on
partialQuery - the (partial) query string
Returns:
the Query

createQueryExecution

public QueryExecution createQueryExecution(Query query,
                                           Model model)
Creates a QueryExecution for a given Query in a given Model, with no initial bindings. The implementation basically uses Jena's QueryExecutionFactory but with the option to use different Dataset as specified by getDataset(model).

Parameters:
query - the Query
model - the Model to query
Returns:
a QueryExecution

createQueryExecution

public QueryExecution createQueryExecution(Query query,
                                           Model model,
                                           QuerySolutionMap initialBinding)
Creates a QueryExecution for a given Query in a given Model, with some given initial bindings. The implementation basically uses Jena's QueryExecutionFactory but with the option to use different Dataset as specified by getDataset(model).

Parameters:
query - the Query
model - the Model to query
initialBindings - the initial variable bindings or null
Returns:
a QueryExecution

createRemoteQueryExecution

public QueryEngineHTTP createRemoteQueryExecution(Query query)
Creates a remote QueryExecution on a given Query.

Parameters:
query - the Query to execute
Returns:
a remote QueryExecution

createRemoteQueryExecution

public QueryEngineHTTP createRemoteQueryExecution(Query query,
                                                  java.util.List<java.lang.String> graphURIs)

getDataset

public Dataset getDataset()
Deprecated. Use the other variation instead

Specifies a Dataset that shall be used for query execution. Returns null by default but may be overloaded by subclasses. For example, TopBraid delegates this to the currently open Graphs.

Returns:
the Dataset or null

getDataset

public Dataset getDataset(Model defaultModel)

getNamedGraphURIs

public static java.util.List<java.lang.String> getNamedGraphURIs(Query query)
Gets a list of named graphs (GRAPH elements) mentioned in a given Query.

Parameters:
query - the Query to traverse
Returns:
a List of those GRAPHs

getSyntax

public Syntax getSyntax()
The ARQ Syntax used by default: Syntax.syntaxARQ.

Returns:
the default syntax