public class SPARQL extends Object
| Modifier and Type | Field and Description |
|---|---|
private org.slf4j.Logger |
log |
org.aksw.jena_sparql_api.core.QueryExecutionFactory |
qef |
private long |
timeToLive |
| Constructor and Description |
|---|
SPARQL()
SPARQLEndpoints.DBPEDIA_ORG as endpoint used. |
SPARQL(String endpoint) |
| Modifier and Type | Method and Description |
|---|---|
private static void |
closeExecFactory(org.aksw.jena_sparql_api.core.QueryExecutionFactory qef) |
static Boolean |
executeAsk(String query,
String endpoint)
Executes an ask query for the given endpoint and query.
|
static Results |
executeSelect(String query,
String endpoint)
Executes a select query for the given endpoint and query.
|
static Set<String> |
extractAnswerStrings(Set<org.apache.jena.rdf.model.RDFNode> answers)
For use with
sparql(String) Extracts answer strings. |
long |
getCacheTimeToLive() |
static boolean |
isEndpointAlive(String endpoint)
Checks if the given endpoint is alive.
|
static boolean |
isValidSparqlQuery(String sparql)
Tries to parse query with apache.jena .
|
void |
setCacheTimeToLive(long timeToLive) |
Set<org.apache.jena.rdf.model.RDFNode> |
sparql(String query)
Fire a sparql query against endpoint defined in constructor.
|
private org.slf4j.Logger log
public org.aksw.jena_sparql_api.core.QueryExecutionFactory qef
private long timeToLive
public SPARQL()
SPARQLEndpoints.DBPEDIA_ORG as endpoint used.public SPARQL(String endpoint)
endpoint - - A sparql endpoint, e.g. SPARQLEndpoints.DBPEDIA_ORGpublic Set<org.apache.jena.rdf.model.RDFNode> sparql(String query)
NOTE: This will block. To set a maximum execution time, use ThreadedSPARQL
For string representation of answers, see extractAnswerStrings(Set)
query - - a sparql querypublic static Set<String> extractAnswerStrings(Set<org.apache.jena.rdf.model.RDFNode> answers)
sparql(String) Extracts answer strings. Can be directly set as golden answers in an IQuestion.answers - public static Results executeSelect(String query, String endpoint)
Results object.query - endpoint - public static Boolean executeAsk(String query, String endpoint)
query - endpoint - public long getCacheTimeToLive()
public void setCacheTimeToLive(long timeToLive)
public static boolean isValidSparqlQuery(String sparql)
sparql - public static boolean isEndpointAlive(String endpoint)
endpoint - private static void closeExecFactory(org.aksw.jena_sparql_api.core.QueryExecutionFactory qef)
Copyright © 2016–2020. All rights reserved.