org.eaglei.repository.util
Class SPARQL

java.lang.Object
  extended by org.eaglei.repository.util.SPARQL

public class SPARQL
extends java.lang.Object

Constants and utilities helpful in building SPARQL queries. Also houses the tuple-result output formatter.

Version:
$Id: $
Author:
Larry Stone

Field Summary
static org.openrdf.query.impl.DatasetImpl InternalGraphs
          Constant InternalGraphs
 
Constructor Summary
SPARQL()
           
 
Method Summary
static void addGraph(org.openrdf.query.impl.DatasetImpl ds, org.openrdf.model.URI graphName)
          Add a single named graph explicitly to the dataset.
static org.openrdf.query.impl.DatasetImpl copyDataset(org.openrdf.query.Dataset src)
          Create copy of given Dataset with same default- and named-graph contents
static org.openrdf.query.Dataset getInternalAndMetadataGraphs(javax.servlet.http.HttpServletRequest request)
          Get a Dataset including all Internal and Metadata named graphs
static void sendTupleQueryResults(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String format, java.lang.Iterable<org.openrdf.query.BindingSet> bindings)
          Sends HTTP result document for a list of artificially-generated tuple-query results.
static void tupleQueryRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String query, java.lang.String format, org.openrdf.query.Dataset ds)
          Generic code to implement a Servlet body whose main purpose is to execute a tabular (Select) SPARQL query and return the results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

InternalGraphs

public static final org.openrdf.query.impl.DatasetImpl InternalGraphs
Constant InternalGraphs

Constructor Detail

SPARQL

public SPARQL()
Method Detail

getInternalAndMetadataGraphs

public static org.openrdf.query.Dataset getInternalAndMetadataGraphs(javax.servlet.http.HttpServletRequest request)

Get a Dataset including all Internal and Metadata named graphs

Parameters:
request - a HttpServletRequest object.
Returns:
a Dataset object.

copyDataset

public static org.openrdf.query.impl.DatasetImpl copyDataset(org.openrdf.query.Dataset src)

Create copy of given Dataset with same default- and named-graph contents

Parameters:
src - the source Dataset object.
Returns:
a new DatasetImpl object.

addGraph

public static void addGraph(org.openrdf.query.impl.DatasetImpl ds,
                            org.openrdf.model.URI graphName)
Add a single named graph explicitly to the dataset. Used to create custom dataset, or extend a View. Add to both default graph and named graphs to facilitate use of "GRAPH ?g" expressions.

Parameters:
ds - desintation dataset, a DatasetImpl object.
graphName - the graph to add, a URI object.

tupleQueryRequest

public static void tupleQueryRequest(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.String query,
                                     java.lang.String format,
                                     org.openrdf.query.Dataset ds)
                              throws javax.servlet.ServletException,
                                     java.io.IOException
Generic code to implement a Servlet body whose main purpose is to execute a tabular (Select) SPARQL query and return the results. This encapsulates all the machinery to run the query, handle errors, and encode the results in an acceptable format.

Parameters:
request - a HttpServletRequest object.
response - a HttpServletResponse object.
query - SPARQL query as a String object.
format - output format as MIME type, a String object.
ds - dataset for query, a Dataset object.
Throws:
javax.servlet.ServletException - if any.
java$io$IOException - if any.
java.io.IOException

sendTupleQueryResults

public static void sendTupleQueryResults(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         java.lang.String format,
                                         java.lang.Iterable<org.openrdf.query.BindingSet> bindings)
                                  throws javax.servlet.ServletException,
                                         java.io.IOException
Sends HTTP result document for a list of artificially-generated tuple-query results. This lets anything that generates tabular data leverage the Sesame query result infrastructure to format results in a wide variety of formats, and likewise the recipient can use their favorite result parser.

Parameters:
request - a HttpServletRequest object.
response - a HttpServletResponse object.
format - output format as MIME type, a String object.
bindings - tuple result bindings as a Iterable object.
Throws:
javax.servlet.ServletException - if any.
java$io$IOException - if any.
java.io.IOException


Copyright © 2009-2010 Eagle-I. All Rights Reserved.