Class SparqlQueryRunner
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryRunner
-
public class SparqlQueryRunner extends Object
Execute SPARQL queries against a model. Take the model in the constructor. Then execute as many queries as desired, with the query contained in a String. Exceptions are handled in a tidy manner, and the query environment is closed properly in any case.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSparqlQueryRunner.QueryParser<T>This template class provides some parsing methods to help in the parseResults() method.static interfaceSparqlQueryRunner.VariableValue
-
Constructor Summary
Constructors Constructor Description SparqlQueryRunner(org.apache.jena.rdf.model.Model model)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringbindValues(String rawString, SparqlQueryRunner.VariableValue... values)org.apache.jena.rdf.model.ModelexecuteConstruct(String queryStr)Execute the CONSTRUCT query and return the resulting model.<T> TexecuteSelect(SparqlQueryRunner.QueryParser<T> parser, String queryStr)Execute the SELECT query and parse the results, closing and cleaning up afterward.static edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryRunner.UriValueuriValue(String name, String uri)
-
-
-
Method Detail
-
executeSelect
public <T> T executeSelect(SparqlQueryRunner.QueryParser<T> parser, String queryStr)
Execute the SELECT query and parse the results, closing and cleaning up afterward. If an exception occurs, return the parser's default value.
-
executeConstruct
public org.apache.jena.rdf.model.Model executeConstruct(String queryStr)
Execute the CONSTRUCT query and return the resulting model. If an exception occurs, return an empty model.
-
bindValues
public static String bindValues(String rawString, SparqlQueryRunner.VariableValue... values)
-
-