de.derivo.sparqldlapi
Interface QueryResult

All Superinterfaces:
java.lang.Iterable<QueryBinding>

public interface QueryResult
extends java.lang.Iterable<QueryBinding>

QueryResult contains the result set of an executed query with all bindings. This class also provides some methods to export the result set in different formats like SPARQL-XML or JSON.

Author:
Mario Volke

Method Summary
 boolean ask()
          Ask if the query had a solution.
 QueryBinding get(int index)
          Returns the QueryBinding at the specified position of the result.
 Query getQuery()
          Get the query that belongs to this result.
 boolean isEmpty()
          Check whether the result set is empty.
 java.util.Iterator<QueryBinding> iterator()
          An iterator over the result set.
 int size()
          Get the size of the result set.
 java.lang.String toJSON()
          Output query results in JSON format as standardized in http://www.w3.org/TR/rdf-sparql-json-res/.
 java.lang.String toString()
          Use this method for debugging purposes.
 Document toXML()
          Output query results as JDOM XML document containing the standard SPARQL query results XML format (http://www.w3.org/TR/rdf-sparql-XMLres/).
 

Method Detail

getQuery

Query getQuery()
Get the query that belongs to this result.

Returns:

iterator

java.util.Iterator<QueryBinding> iterator()
An iterator over the result set.

Specified by:
iterator in interface java.lang.Iterable<QueryBinding>
Returns:

get

QueryBinding get(int index)
Returns the QueryBinding at the specified position of the result.

Parameters:
index -
Returns:
The QueryBinding at the specified position.

size

int size()
Get the size of the result set.

Returns:
The size of the result set.

isEmpty

boolean isEmpty()
Check whether the result set is empty.

Returns:
True if the result set is empty.

ask

boolean ask()
Ask if the query had a solution. This is the only result you get if the query was of type ASK. This could also be true if the result set is empty.

Returns:
True if the query had a solution.

toXML

Document toXML()
Output query results as JDOM XML document containing the standard SPARQL query results XML format (http://www.w3.org/TR/rdf-sparql-XMLres/). Supports both: Variable binding results and Boolean results.

Returns:
A JDOM XML document.

toJSON

java.lang.String toJSON()
Output query results in JSON format as standardized in http://www.w3.org/TR/rdf-sparql-json-res/. Supports both: Variable binding results and Boolean results.

Returns:
The JSON result as string.

toString

java.lang.String toString()
Use this method for debugging purposes. This is no standard format like SPARQL-XML or JSON.

Overrides:
toString in class java.lang.Object
Returns:
A nicely formatted string containing the results and bindings.