org.dllearner.kb.sparql
Class SparqlQuery

java.lang.Object
  extended by org.dllearner.kb.sparql.SparqlQuery

public class SparqlQuery
extends Object

Represents one SPARQL query. It includes support for stopping the SPARQL query (which may be necessary if a timeout is reached) and is designed to be able to run a query in a separate thread.

Author:
Jens Lehmann, Sebastian Hellmann

Constructor Summary
SparqlQuery(String sparqlQueryString, SparqlEndpoint sparqlEndpoint)
          Standard constructor.
 
Method Summary
static com.hp.hpl.jena.query.ResultSetRewindable convertJSONtoResultSet(String json)
          Converts from JSON to internal Jena format.
static String convertJSONtoXML(String json)
          Converts from JSON to xml format.
static String convertResultSetToJSON(com.hp.hpl.jena.query.ResultSetRewindable resultSet)
          Converts Jena result set to JSON.
static String convertResultSetToXMLString(com.hp.hpl.jena.query.ResultSetRewindable resultSet)
          Converts Jena result set to XML.
 String getJson()
          Return the result in JSON format.
 SparqlEndpoint getSparqlEndpoint()
           
 String getSparqlQueryString()
          Gets the String representation of the SPARQL query.
 String getXMLString()
          Converts the result set to an XML string.
 boolean isRunning()
           
 com.hp.hpl.jena.query.ResultSetRewindable send()
          Sends a SPARQL query using the Jena library.
 boolean sendAsk()
           
 void stop()
          Stops the execution of the query.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparqlQuery

public SparqlQuery(String sparqlQueryString,
                   SparqlEndpoint sparqlEndpoint)
Standard constructor.

Parameters:
sparqlQueryString - A SPARQL query string
sparqlEndpoint - An Endpoint object
Method Detail

send

public com.hp.hpl.jena.query.ResultSetRewindable send()
Sends a SPARQL query using the Jena library.


sendAsk

public boolean sendAsk()

stop

public void stop()
Stops the execution of the query.


getSparqlQueryString

public String getSparqlQueryString()
Gets the String representation of the SPARQL query.

Returns:
sparqlQueryString

getSparqlEndpoint

public SparqlEndpoint getSparqlEndpoint()
Returns:
sparqlEndpoint object

isRunning

public boolean isRunning()
Returns:
boolean

getJson

public String getJson()
Return the result in JSON format.

Returns:
A JSON string converted from the result set or null if the query has not been executed.

getXMLString

public String getXMLString()
Converts the result set to an XML string.

Returns:
An XML String

convertResultSetToXMLString

public static String convertResultSetToXMLString(com.hp.hpl.jena.query.ResultSetRewindable resultSet)
Converts Jena result set to XML. To make a ResultSet rewindable use: ResultSetRewindable rsRewind = ResultSetFactory.makeRewindable(resultSet);

Parameters:
resultSet - The result set to transform, must be rewindable to prevent errors.
Returns:
String xml

convertResultSetToJSON

public static String convertResultSetToJSON(com.hp.hpl.jena.query.ResultSetRewindable resultSet)
Converts Jena result set to JSON.

Parameters:
resultSet - The result set to transform, must be rewindable to prevent errors.
Returns:
JSON representation of the result set.

convertJSONtoResultSet

public static com.hp.hpl.jena.query.ResultSetRewindable convertJSONtoResultSet(String json)
Converts from JSON to internal Jena format.

Parameters:
json - A JSON representation if a SPARQL query result.
Returns:
A Jena ResultSet.

convertJSONtoXML

public static String convertJSONtoXML(String json)
Converts from JSON to xml format.

Parameters:
json - A JSON representation if a SPARQL query result.
Returns:
A Jena ResultSet.


SourceForge.net Logo DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2011 Jens Lehmann