Class ModelStore

java.lang.Object
org.apache.jena.query.ModelStore

public class ModelStore extends Object
Client for the SPARQL 1.1 Graph Store Protocol working at the Model/Resource API level.

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

Examples:

   // Get the default graph.
   Model model = ModelStore.service("http://example/dataset").defaultModel().GET();
 
   // Get a named graph.
   Model model = ModelStore.service("http://example/dataset").namedGraph("http://my/graph").GET();
 
   // POST (add) to a named graph.
   Model myData = ...;
   ModelStore.request("http://example/dataset").namedGraph("http://my/graph").POST(myData);
 
See Also:
  • Method Details

    • service

      public static ModelStore service(String service)
      Create a request to the remote service (without Graph Store Protocol naming). Call defaultModel() or namedGraph(String) to select the target graph.
      Parameters:
      service -
    • endpoint

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

      public ModelStore httpClient(HttpClient httpClient)
    • httpHeader

      public ModelStore 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.
    • namedGraph

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

      public ModelStore defaultModel()
      Send request for the default graph (that is, ?default)
    • defaultGraph

      public ModelStore defaultGraph()
      Send request for the default graph (that is, ?default)
    • acceptHeader

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

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

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

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

      public org.apache.jena.rdf.model.Model 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(org.apache.jena.rdf.model.Model model)
      POST a model.
    • 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(org.apache.jena.rdf.model.Model model)
      PUT a graph.
    • DELETE

      public void DELETE()
      Delete a graph.
    • getDataset

      public Dataset 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(Dataset 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(Dataset dataset)
      PUT a dataset
    • clearDataset

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