public class SPARQLUpdate extends Object
SPARQLUpdate up = new SPARQLUpdate(server); up.open(); up.sendPrefixes(model); up.send(command); up.send(model, true); up.send(command); up.close(); int status = up.getStatus(); boolean ok = up.wasSuccessful();
| Modifier and Type | Field and Description |
|---|---|
protected HttpURLConnection |
conn |
protected BufferedWriter |
logFile |
protected BufferedWriter |
out |
protected String |
responseBody |
protected String |
responseMessage |
protected boolean |
started |
protected int |
status |
protected URL |
target |
| Constructor and Description |
|---|
SPARQLUpdate(String server)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Finish the update command, capturing the result status and any return message
|
String |
getResponseBody()
Get the body of the HTTP response, in the event of an error response
the server may return useful human readable information in the body.
|
String |
getResponseMessage()
Get the message part of the HTTP response, generally not interesting
|
int |
getStatus()
Get the returned status code from the request
|
boolean |
isStarted()
Return true if at least one command string has been sent, whether complete or not
|
void |
open()
Open the POST channel to the server
|
void |
performUpdate(String preamble,
com.hp.hpl.jena.rdf.model.Model model,
String postamble)
Convenience packaging of common pattern of use.
|
void |
send(InputStream in)
Write a set of formatted SPARQL Update instructions to the stream
|
void |
send(com.hp.hpl.jena.rdf.model.Model model)
Write a model as part of the update request, typically the body
of and INSERT DATA {} or DELETE DATA {} request but it is up
to the caller to send the surrounding command syntax.
|
void |
send(com.hp.hpl.jena.rdf.model.Model model,
boolean turtle)
Write a model as part of the update request, typically the body
of and INSERT DATA {} or DELETE DATA {} request but it is up
to the caller to send the surrounding command syntax.
|
void |
send(String command)
Send a string (hopefully part of a SPARQL update command!) to the server
|
void |
sendPrefixes(com.hp.hpl.jena.shared.PrefixMapping pm)
Write the prefixes from the given model (or other prefix mapping)
in SPARQL update syntax.
|
void |
sendUpdate(String preamble,
com.hp.hpl.jena.rdf.model.Model model,
String postamble)
Convenience packaging of common pattern of use.
|
void |
setLogFileBase(String filebase)
Request that the entire formatted update request be recorded in a timestamped
file with the name "
|
boolean |
wasSuccessful()
Return true if the update succeeded (response code 2xx or 3xx)
|
protected BufferedWriter logFile
protected URL target
protected int status
protected String responseMessage
protected String responseBody
protected HttpURLConnection conn
protected BufferedWriter out
protected boolean started
public SPARQLUpdate(String server)
server - URL of the of the server which should be send the requestpublic void setLogFileBase(String filebase)
file - name of the file to log topublic void open()
public void send(String command)
public boolean isStarted()
public void sendPrefixes(com.hp.hpl.jena.shared.PrefixMapping pm)
public void send(com.hp.hpl.jena.rdf.model.Model model,
boolean turtle)
model - the model to sendturtle - if true then the model will be send in compact turtle syntax using any
prefixes declared in the model (the caller must have issued sendPrefixes at the start
of the update for this to be legal), if false then N-Triple syntax will be used which
is more verbose but faster to write and does not require prefixespublic void send(com.hp.hpl.jena.rdf.model.Model model)
public void send(InputStream in) throws IOException
IOExceptionpublic void performUpdate(String preamble, com.hp.hpl.jena.rdf.model.Model model, String postamble)
public void sendUpdate(String preamble, com.hp.hpl.jena.rdf.model.Model model, String postamble)
public void close()
public int getStatus()
public String getResponseMessage()
public String getResponseBody()
public boolean wasSuccessful()
Copyright © 2015. All rights reserved.