Package org.topbraid.jenax.util
Class ARQFactory
java.lang.Object
org.topbraid.jenax.util.ARQFactory
A singleton that can create ARQ SPARQL Queries and QueryExecution objects.
SHACL and SPIN API users should use the provided methods here.
- Author:
- Holger Knublauch
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanFine-grained control for development : switch on and off query printing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadjustQueryExecution(org.apache.jena.query.QueryExecution qexec) Can be overloaded to install extra things such as Lucene indices to all local QueryExecutions generated by this factory.static java.net.http.HttpClientbuildHttpClient(String user, String password) voidProgrammatically resets any cached queries.org.apache.jena.query.QuerycreateExpressionQuery(String expression) createPrefixDeclarations(org.apache.jena.rdf.model.Model model) Same ascreatePrefixDeclarations(model, true).createPrefixDeclarations(org.apache.jena.rdf.model.Model model, boolean includeExtraPrefixes) Creates SPARQL prefix declarations for a given Model.org.apache.jena.query.QuerycreateQuery(String queryString) org.apache.jena.query.QuerycreateQuery(org.apache.jena.rdf.model.Model model, String partialQuery) Creates a new Query from a partial query (possibly lacking PREFIX declarations), using the ARQ syntax specified bygetSyntax.org.apache.jena.query.QueryExecutioncreateQueryExecution(org.apache.jena.query.Query query, org.apache.jena.query.Dataset dataset) org.apache.jena.query.QueryExecutioncreateQueryExecution(org.apache.jena.query.Query query, org.apache.jena.query.Dataset dataset, org.apache.jena.query.QuerySolution initialBinding) org.apache.jena.query.QueryExecutioncreateQueryExecution(org.apache.jena.query.Query query, org.apache.jena.rdf.model.Model model) Creates a QueryExecution for a given Query in a given Model, with no initial bindings.org.apache.jena.query.QueryExecutioncreateQueryExecution(org.apache.jena.query.Query query, org.apache.jena.rdf.model.Model model, org.apache.jena.query.QuerySolution initialBinding) Creates a QueryExecution for a given Query in a given Model, with some given initial bindings.org.apache.jena.query.QuerycreateQueryWithPrefixMapping(String partialQuery, org.apache.jena.shared.PrefixMapping prefixMapping) Creates a new Query from a partial query (possibly lacking PREFIX declarations), using the ARQ syntax specified bygetSyntax.org.apache.jena.sparql.exec.http.QueryExecutionHTTPcreateRemoteQueryExecution(String service, org.apache.jena.query.Query query, List<String> defaultGraphURIs, List<String> namedGraphURIs, String user, String password) org.apache.jena.sparql.exec.http.QueryExecutionHTTPcreateRemoteQueryExecution(org.apache.jena.query.Query query) Creates a remote QueryExecution on a given Query.org.apache.jena.sparql.exec.http.QueryExecutionHTTPcreateRemoteQueryExecution(org.apache.jena.query.Query query, List<String> graphURIs) org.apache.jena.update.UpdateRequestcreateUpdateRequest(String parsableString) org.apache.jena.query.QuerydoCreateQuery(String queryString) protected org.apache.jena.query.QuerydoCreateQuery(String queryString, org.apache.jena.shared.PrefixMapping prefixMapping) Creates the "physical" Jena Query instance.static ARQFactoryget()Gets the singleton instance of this class.org.apache.jena.query.DatasetgetDataset(org.apache.jena.rdf.model.Model defaultModel) Specifies a Dataset that shall be used for query execution.getNamedGraphURIs(org.apache.jena.query.Query query) Gets a list of named graphs (GRAPH elements) mentioned in a given Query.static org.apache.jena.rdf.model.ModelgetNamedModel(String graphURI) Convenience method to get a named graph from the current ARQFactory's Dataset.org.apache.jena.query.SyntaxThe ARQ Syntax used by default: Syntax.syntaxARQ.booleanstatic voidset(ARQFactory value) Changes the singleton to some subclass.voidsetUseCaches(boolean value) Tells the ARQFactory whether to use caches for the various createXY functions.
-
Field Details
-
LOG_QUERIES
public static boolean LOG_QUERIESFine-grained control for development : switch on and off query printing
-
-
Constructor Details
-
ARQFactory
public ARQFactory()
-
-
Method Details
-
get
Gets the singleton instance of this class.- Returns:
- the singleton
-
getNamedModel
Convenience method to get a named graph from the current ARQFactory's Dataset.- Parameters:
graphURI- the URI of the graph to get- Returns:
- the named graph or null
-
set
Changes the singleton to some subclass.- Parameters:
value- the new ARQFactory (not null)
-
adjustQueryExecution
protected void adjustQueryExecution(org.apache.jena.query.QueryExecution qexec) Can be overloaded to install extra things such as Lucene indices to all local QueryExecutions generated by this factory. Does nothing by default.- Parameters:
qexec- the QueryExecution to modify
-
clearCaches
public void clearCaches()Programmatically resets any cached queries. -
createExpressionQuery
-
createPrefixDeclarations
Same ascreatePrefixDeclarations(model, true).- Parameters:
model- the Model to create prefix declarations for- Returns:
- the prefix declarations
-
createPrefixDeclarations
public String createPrefixDeclarations(org.apache.jena.rdf.model.Model model, boolean includeExtraPrefixes) Creates SPARQL prefix declarations for a given Model.- Parameters:
model- the Model to get the prefixes fromincludeExtraPrefixes- true to also include implicit prefixes like afn- Returns:
- the prefix declarations
-
createQuery
-
doCreateQuery
-
createQuery
public org.apache.jena.query.Query createQuery(org.apache.jena.rdf.model.Model model, String partialQuery) Creates a new Query from a partial query (possibly lacking PREFIX declarations), using the ARQ syntax specified bygetSyntax. This will also use the ExtraPrefixes, e.g. for function definitions.- Parameters:
model- the Model to use the prefixes frompartialQuery- the (partial) query string- Returns:
- the Query
-
createQueryExecution
public org.apache.jena.query.QueryExecution createQueryExecution(org.apache.jena.query.Query query, org.apache.jena.rdf.model.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 bygetDataset(model).- Parameters:
query- the Querymodel- the Model to query- Returns:
- a QueryExecution
-
createQueryExecution
public org.apache.jena.query.QueryExecution createQueryExecution(org.apache.jena.query.Query query, org.apache.jena.rdf.model.Model model, org.apache.jena.query.QuerySolution 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 bygetDataset(model).- Parameters:
query- the Querymodel- the Model to queryinitialBinding- the initial variable bindings or null- Returns:
- a QueryExecution
-
createQueryExecution
public org.apache.jena.query.QueryExecution createQueryExecution(org.apache.jena.query.Query query, org.apache.jena.query.Dataset dataset) -
createQueryExecution
public org.apache.jena.query.QueryExecution createQueryExecution(org.apache.jena.query.Query query, org.apache.jena.query.Dataset dataset, org.apache.jena.query.QuerySolution initialBinding) -
createRemoteQueryExecution
public org.apache.jena.sparql.exec.http.QueryExecutionHTTP createRemoteQueryExecution(org.apache.jena.query.Query query) Creates a remote QueryExecution on a given Query.- Parameters:
query- the Query to execute- Returns:
- a remote QueryExecution
-
createRemoteQueryExecution
-
createRemoteQueryExecution
-
buildHttpClient
-
createUpdateRequest
-
getDataset
public org.apache.jena.query.Dataset getDataset(org.apache.jena.rdf.model.Model defaultModel) Specifies a Dataset that shall be used for query execution. Returns a new DatasetImpl by default but may be overloaded in subclasses. For example, TopBraid delegates this to the currently open Graphs.- Parameters:
defaultModel- the default Model of the Dataset- Returns:
- the Dataset
-
getNamedGraphURIs
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 org.apache.jena.query.Syntax getSyntax()The ARQ Syntax used by default: Syntax.syntaxARQ.- Returns:
- the default syntax
-
isUsingCaches
public boolean isUsingCaches() -
setUseCaches
public void setUseCaches(boolean value) Tells the ARQFactory whether to use caches for the various createXY functions. These are on by default. Warning: there may be memory leaks if the first executed query of its kind keeps a reference to a E_Function which keeps a reference to a Function, and FunctionBase to a FunctionEnv with an active graph.- Parameters:
value- false to switch caches off
-