Class SparqlClient
- java.lang.Object
-
- org.topbraidlive.client.java.impl.SparqlClient
-
- All Implemented Interfaces:
ApiFunction
,GetSparqlConnectionApiFunction
,QuerySparqlApiFunction
public final class SparqlClient extends Object implements GetSparqlConnectionApiFunction, QuerySparqlApiFunction
-
-
Constructor Summary
Constructors Constructor Description SparqlClient(ClientConfiguration clientConfiguration, org.apache.http.impl.client.CloseableHttpClient httpClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.http.client.methods.CloseableHttpResponse
execute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
protected org.apache.http.client.methods.CloseableHttpResponse
get(org.apache.http.client.utils.URIBuilder uriBuilder)
protected ClientConfiguration
getClientConfiguration()
protected org.apache.http.impl.client.CloseableHttpClient
getHttpClient()
org.apache.jena.rdfconnection.RDFConnection
getSparqlConnection()
Interact with the server via SPARQL.protected ClientException
newClientException(org.apache.http.HttpResponse httpResponse)
protected org.apache.http.client.utils.URIBuilder
newUriBuilder(String relativeUriPath)
protected org.apache.http.client.methods.CloseableHttpResponse
postForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)
org.apache.jena.query.QueryExecution
querySparql(org.apache.jena.query.Query query, Optional<String> defaultGraph)
Query the EDG SPARQL endpoint.protected String
toString(org.apache.http.HttpResponse httpResponse)
Convert an HttpResponse to a string, usually for logging.protected String
toString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity)
Convert an HttpResponse to a string, usually for logging.protected static RuntimeException
wrap(IOException e)
-
-
-
Constructor Detail
-
SparqlClient
public SparqlClient(ClientConfiguration clientConfiguration, org.apache.http.impl.client.CloseableHttpClient httpClient)
-
-
Method Detail
-
getSparqlConnection
public final org.apache.jena.rdfconnection.RDFConnection getSparqlConnection()
Description copied from interface:GetSparqlConnectionApiFunction
Interact with the server via SPARQL.- Specified by:
getSparqlConnection
in interfaceGetSparqlConnectionApiFunction
-
querySparql
public final org.apache.jena.query.QueryExecution querySparql(org.apache.jena.query.Query query, Optional<String> defaultGraph)
Description copied from interface:QuerySparqlApiFunction
Query the EDG SPARQL endpoint.- Specified by:
querySparql
in interfaceQuerySparqlApiFunction
- Parameters:
query
- SPARQL querydefaultGraph
- optional default graph URI- Returns:
- Jena QueryExecution, which must be closed by the caller
-
wrap
protected static final RuntimeException wrap(IOException e)
-
getClientConfiguration
protected final ClientConfiguration getClientConfiguration()
-
execute
protected final org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
-
get
protected final org.apache.http.client.methods.CloseableHttpResponse get(org.apache.http.client.utils.URIBuilder uriBuilder)
-
getHttpClient
protected final org.apache.http.impl.client.CloseableHttpClient getHttpClient()
-
newClientException
protected final ClientException newClientException(org.apache.http.HttpResponse httpResponse) throws IOException
- Throws:
IOException
-
newUriBuilder
protected final org.apache.http.client.utils.URIBuilder newUriBuilder(String relativeUriPath)
-
postForm
protected final org.apache.http.client.methods.CloseableHttpResponse postForm(List<org.apache.http.NameValuePair> nameValuePairs, org.apache.http.client.utils.URIBuilder uriBuilder)
-
toString
protected final String toString(org.apache.http.HttpResponse httpResponse) throws IOException
Convert an HttpResponse to a string, usually for logging.Consumes the entity (body) in order to convert it to a string.
- Throws:
IOException
-
toString
protected final String toString(org.apache.http.HttpResponse httpResponse, String httpResponseEntity) throws IOException
Convert an HttpResponse to a string, usually for logging.Uses an entity (body) that has been previously converted to a string.
- Throws:
IOException
-
-