java.lang.Object
org.apache.jena.sparql.exec.http.GSP

public class GSP extends Object
Client for the SPARQL 1.1 Graph Store Protocol.

This is extended to include operations GET, POST and PUT on datasets.

Examples:

   // Get the default graph.
   Graph graph = GSP.service("http://example/dataset").defaultGraph().GET();
 
   // Get a named graph.
   Graph graph = GSP.service("http://example/dataset").namedGraph("http://my/graph").GET();
 
   // POST (add) to a named graph.
   Graph myData = ...;
   GSP.service("http://example/dataset").namedGraph("http://my/graph").POST(myData);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    accept(Lang lang)
    Set the accept header on GET requests.
    acceptHeader(String acceptHeader)
    Set the accept header on GET requests.
    void
    Clear - delete named graphs, empty the default graph - SPARQL "CLEAR ALL"
    Set the Content-type for a POST, PUT request of a file or serialization of a graph opf dataset is necessary.
    Set the Content-type for a POST, PUT request of a file or serialization of a graph opf dataset is necessary.
    Send request for the dataset.
    Send request for the default graph (that is, ?default)
    void
    Delete a graph.
    endpoint(String serviceURL)
    Set the URL of the query endpoint.
    GET()
    Get a graph
    GET dataset.
    graphName(String graphName)
    Send request for a named graph (that is, ?graph=)
    graphName(Node graphName)
    Send request for a named graph (that is, ?graph=)
    httpClient(java.net.http.HttpClient httpClient)
     
    httpHeader(String headerName, String headerValue)
    Set an HTTP header that is added to the request.
    void
    POST(String file)
    POST the contents of a file using the filename extension to determine the Content-Type to use if it is not already set.
    void
    POST(Graph graph)
    POST a graph.
    void
    POST the contents of a file using the filename extension to determine the Content-Type to use if not already set.
    void
    POST a dataset
    void
    PUT(String file)
    PUT the contents of a file using the filename extension to determine the Content-Type to use if it is not already set.
    void
    PUT(Graph graph)
    PUT a graph.
    void
    PUT the contents of a file using the filename extension to determine the Content-Type to use if not already set.
    void
    PUT a dataset
    static GSP
    Create a request to the remote service (without GSP naming).
    static GSP
    service(String service)
    Create a request to the remote service (without GSP naming).

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • service

      public static GSP service(String service)
      Create a request to the remote service (without GSP naming). Call defaultGraph() or graphName(String) to select the target graph.
      Parameters:
      service -
    • request

      public static GSP request()
      Create a request to the remote service (without GSP naming). Call endpoint(java.lang.String) to set the target. Call defaultGraph() or graphName(String) to select the target graph.
    • endpoint

      public GSP endpoint(String serviceURL)
      Set the URL of the query endpoint. This replaces any value set in the service(String) call.
    • httpClient

      public GSP httpClient(java.net.http.HttpClient httpClient)
    • httpHeader

      public GSP httpHeader(String headerName, String headerValue)
      Set an HTTP header that is added to the request. See accept(org.apache.jena.riot.Lang), acceptHeader(java.lang.String) and contentType(RDFFormat). for specific handling of Accept: and Content-Type.
    • graphName

      public GSP graphName(String graphName)
      Send request for a named graph (that is, ?graph=)
    • graphName

      public GSP graphName(Node graphName)
      Send request for a named graph (that is, ?graph=)
    • defaultGraph

      public GSP defaultGraph()
      Send request for the default graph (that is, ?default)
    • dataset

      public GSP dataset()
      Send request for the dataset. This is "no GSP naming".
    • acceptHeader

      public GSP acceptHeader(String acceptHeader)
      Set the accept header on GET requests. Optional; if not set, a system default is used.
    • accept

      public GSP accept(Lang lang)
      Set the accept header on GET requests. Optional; if not set, a system default is used.
    • contentTypeHeader

      public GSP contentTypeHeader(String contentType)
      Set the Content-type for a POST, PUT request of a file or serialization of a graph opf dataset is necessary. Optional; if not set, the file extension is used or the system default RDF syntax encoding.
    • contentType

      public GSP contentType(RDFFormat rdfFormat)
      Set the Content-type for a POST, PUT request of a file or serialization of a graph opf dataset is necessary. Optional; if not set, the file extension is used or the system default RDF syntax encoding.
    • GET

      public Graph GET()
      Get a graph
    • POST

      public void POST(String file)
      POST the contents of a file using the filename extension to determine the Content-Type to use if it is not already set.

      This operation does not parse the file.

    • POST

      public void POST(Graph graph)
      POST a graph.
    • PUT

      public void PUT(String file)
      PUT the contents of a file using the filename extension to determine the Content-Type to use if it is not already set.

      This operation does not parse the file.

      If the data may have quads (named graphs), use putDataset(String).

    • PUT

      public void PUT(Graph graph)
      PUT a graph.
    • DELETE

      public void DELETE()
      Delete a graph.
    • getDataset

      public DatasetGraph getDataset()
      GET dataset.

      If the remote end is a graph, the result is a dataset with that graph data in the default graph of the dataset.

    • postDataset

      public void postDataset(String file)
      POST the contents of a file using the filename extension to determine the Content-Type to use if not already set.

      This operation does not parse the file.

    • postDataset

      public void postDataset(DatasetGraph dataset)
      POST a dataset
    • putDataset

      public void putDataset(String file)
      PUT the contents of a file using the filename extension to determine the Content-Type to use if not already set.

      This operation does not parse the file.

    • putDataset

      public void putDataset(DatasetGraph dataset)
      PUT a dataset
    • clearDataset

      public void clearDataset()
      Clear - delete named graphs, empty the default graph - SPARQL "CLEAR ALL"