java.lang.Object
org.apache.jena.arq.querybuilder.UpdateBuilder
Class to build update requests.
-
Constructor Summary
ConstructorDescriptionCreates an UpdateBuilder with an empty prefix mapping.UpdateBuilder
(PrologClause<?> prologClause) Creates an UpdateBuilder with the prefixes defined in the prolog clause.UpdateBuilder
(org.apache.jena.shared.PrefixMapping pMap) Creates an UpdateBuilder with the specified PrefixMapping. -
Method Summary
Modifier and TypeMethodDescriptionaddAll
(WhereHandler whereHandler) Add all where attributes from the Where Handler argument.Add a bind statement to the query http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.Add a binding to the where clause.Add a bind statement to the query * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.addBind
(org.apache.jena.sparql.expr.Expr expr, org.apache.jena.sparql.core.Var var) Add a binding to the where clause.Add a triple to the delete statement.Add a quad to the delete statement.addDelete
(Object g, Collection<org.apache.jena.graph.Triple> collection) Add all the statements in the model to the delete statement.Add all the statements in the model to the delete statement.addDelete
(Object graph, AbstractQueryBuilder<?> queryBuilder) Add the statements from the where clause in the specified query builder to the delete statements for the specified graph.Add a triple to the delete statement.Add all the statements in the model a specified graph to the delete statement.addDelete
(Collection<org.apache.jena.graph.Triple> collection) Add all triples to the delete statement.Add all the triples in the iterator to the delete statement.addDelete
(AbstractQueryBuilder<?> queryBuilder) Add the statements from the where clause in the specified query builder to the delete statement.addDelete
(org.apache.jena.graph.Triple t) Add a triple to the delete statement.addDelete
(org.apache.jena.rdf.model.Model model) Add all the statements in the model to the delete statement.addDelete
(org.apache.jena.sparql.core.Quad quad) Add a quad to the delete statement.addDeleteQuads
(Collection<org.apache.jena.sparql.core.Quad> collection) Add all the quads collection to the delete statement.Add an expression string as a filter.addFilter
(org.apache.jena.sparql.expr.Expr expression) Adds a filter to the where clause Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr methods to create the expression.addGraph
(Object graph, AbstractQueryBuilder<?> subQuery) Add a graph statement to the query as per http://www.w3.org/TR/2013/REC-sparql11 -query-20130321/#rGraphGraphPattern.addGraph
(org.apache.jena.graph.Node graph, WhereHandler subQuery) Add a graph to the where clause.Add a triple to the insert statement.Add a quad to the insert statement.addInsert
(Object g, Collection<org.apache.jena.graph.Triple> collection) Add triples to the insert statement.Add triples to the insert statement.addInsert
(Object graph, AbstractQueryBuilder<?> queryBuilder) Add the statements from the where clause in the specified query builder to the insert statements for the specified graph.Add a triple in a specified graph to the insert statement.Add all the statements in the model a specified graph to the insert statement.addInsert
(Collection<org.apache.jena.graph.Triple> collection) Add all the triples in the model to the insert statement.Add all the triples to the insert statement.addInsert
(AbstractQueryBuilder<?> queryBuilder) Add the statements from the where clause in the specified query builder to the insert statement.addInsert
(org.apache.jena.graph.Triple t) Add a triple to the insert statement.addInsert
(org.apache.jena.rdf.model.Model model) Add all the statements in the model to the insert statement.addInsert
(org.apache.jena.sparql.core.Quad quad) Add a quad to the insert statement.addInsertQuads
(Collection<org.apache.jena.sparql.core.Quad> collection) Add all the quads in the collection to the insert statement.addMinus
(AbstractQueryBuilder<?> t) Add a minus clause to the query.addOptional
(Object s, Object p, Object o) Adds an optional triple or triple path to the where clause.addOptional
(Collection<org.apache.jena.sparql.core.TriplePath> collection) Add an optional triple to the where clauseAdds an optional group pattern to the where clause.addOptional
(WhereHandler whereHandler) Add the contents of a where handler as an optional statement.addOptional
(org.apache.jena.graph.FrontsTriple t) Adds an optional triple as to the where clause.addOptional
(org.apache.jena.graph.Triple t) Adds an optional triple to the where clause.addOptional
(org.apache.jena.sparql.core.TriplePath t) Add an optional triple to the where clauseAdd the prefix to the prefix mapping.Add the prefix to the prefix mapping.Add the prefix to the prefix mapping.addPrefixes
(Map<String, String> prefixes) Add the prefixes to the prefix mapping.addPrefixes
(org.apache.jena.shared.PrefixMapping prefixes) Add the prefixes to the prefix mapping.addSubQuery
(AbstractQueryBuilder<?> subQuery) Add a subquery to the where clause.addUnion
(AbstractQueryBuilder<?> subQuery) Add a union to the where clause.Adds a triple or triple path to the where clause.addWhere
(WhereClause<?> whereClause) Add the WhereClauseaddWhere
(org.apache.jena.graph.FrontsTriple t) Adds a triple to the where clause.addWhere
(org.apache.jena.graph.Triple t) Adds a triple to the where clause.addWhere
(org.apache.jena.sparql.core.TriplePath t) Add the triple path to the where clauseorg.apache.jena.update.UpdateRequest
appendTo
(org.apache.jena.update.UpdateRequest req) Appends the new Update to the UpdateRequest.org.apache.jena.update.Update
build()
Build the update.org.apache.jena.sparql.modify.request.UpdateDeleteWhere
Create a DeleteWhere from the where clause.org.apache.jena.sparql.modify.request.UpdateDeleteWhere
buildDeleteWhere
(AbstractQueryBuilder<?> queryBuilder) Create a DeleteWhere from the where clause.org.apache.jena.update.UpdateRequest
Build as an UpdateRequest with prefix mapping set.Get an ExprFactory that uses the prefixes from this builder.boolean
isEmpty()
Checks that no deletes or inserts have been added to the builder.org.apache.jena.graph.Node
Deprecated.use makeListorg.apache.jena.graph.Node
Create a list node from a list of objects as per RDF Collections.org.apache.jena.graph.Node
Convert the object to a node.org.apache.jena.sparql.core.TriplePath
makeTriplePath
(Object s, Object p, Object o) Deprecated.Collection<org.apache.jena.sparql.core.TriplePath>
makeTriplePaths
(Object s, Object p, Object o) Make a collection of one or moreTriplePath
objects from the objects.org.apache.jena.sparql.core.Var
Deprecated.Deprecated.Use quoted()void
Set a variable replacement.void
setVar
(org.apache.jena.sparql.core.Var var, org.apache.jena.graph.Node value) Set a variable replacement.Specify the graph for all inserts and deletes.
-
Constructor Details
-
UpdateBuilder
public UpdateBuilder()Creates an UpdateBuilder with an empty prefix mapping. -
UpdateBuilder
Creates an UpdateBuilder with the prefixes defined in the prolog clause. May modify the contents of the prefix mapping in the prolog handler- Parameters:
prologClause
- the default prefixes for this builder.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Checks that no deletes or inserts have been added to the builder.- Returns:
- true if there are no delete or insert statements.
-
build
public org.apache.jena.update.Update build()Build the update. Note: the update does not include the prefix statements use buildRequest() or appendTo() methods to include the prefix statements.- Returns:
- the update.
-
buildRequest
public org.apache.jena.update.UpdateRequest buildRequest()Build as an UpdateRequest with prefix mapping set.- Returns:
- a new UpdateRequest
-
appendTo
public org.apache.jena.update.UpdateRequest appendTo(org.apache.jena.update.UpdateRequest req) Appends the new Update to the UpdateRequest.- Parameters:
req
- the UpdateRequest to append this Update to.- Returns:
- the req parameter for chaining.
-
makeTriplePath
@Deprecated(since="5.0.0") public org.apache.jena.sparql.core.TriplePath makeTriplePath(Object s, Object p, Object o) Deprecated.Make a triple path from the objects. For subject, predicate and objects nodes- Will return Node.ANY if object is null.
- Will return the enclosed Node from a FrontsNode
- Will return the object if it is a Node.
- If the object is a String
- For
predicate
only will attempt to parse as a path - for subject, predicate and object will call NodeFactoryExtra.parseNode() using the currently defined prefixes if the object is a String
- For
- Will create a literal representation if the parseNode() fails or for any other object type.
- Parameters:
s
- The subject objectp
- the predicate objecto
- the object object.- Returns:
- a TriplePath
-
makeTriplePaths
public Collection<org.apache.jena.sparql.core.TriplePath> makeTriplePaths(Object s, Object p, Object o) Make a collection of one or moreTriplePath
objects from the objects. UsesConverters.makeTriplePaths
to perform the conversions using the prefixes defined in this UpdateBuilder.- Parameters:
s
- The subject objectp
- the predicate objecto
- the object object.- Returns:
- a collection of
TriplePath
s
-
makeNode
Convert the object to a node. Shorthand for AbstractQueryBuilder.makeNode( o, prefixes )- Parameters:
o
- the object to convert to a node.- Returns:
- the Node.
- See Also:
-
makeVar
Deprecated.Convert the object to a node. Shorthand for AbstractQueryBuilder.makeVar( o )- Parameters:
o
- the object to convert to a var.- Returns:
- the Var.
- See Also:
-
quote
Deprecated.Use quoted()Quote a string. Shorthand for AbstractQueryBuilder.quote( s )- Parameters:
s
- the string to quote.- Returns:
- the quoted string.
- See Also:
-
addInsert
Add a quad to the insert statement. Arguments are converted to nodes using the makeNode() method.- Parameters:
g
- the graphs
- the subjectp
- the predicateo
- the object- Returns:
- this builder for chaining.
- See Also:
-
addInsert
Add a quad to the insert statement.- Parameters:
quad
- the quad to add.- Returns:
- this builder for chaining.
-
addInsert
Add a triple to the insert statement. Arguments are converted to nodes using the makeNode() method.- Parameters:
s
- the subjectp
- the predicateo
- the object- Returns:
- this builder for chaining.
- See Also:
-
addInsert
Add a triple to the insert statement.- Parameters:
t
- the triple to add.- Returns:
- this builder for chaining.
-
addInsert
Add a triple in a specified graph to the insert statement. The graph object is converted by a call to makeNode().- Parameters:
g
- the graph for the triple.t
- the triple to add.- Returns:
- this builder for chaining.
- See Also:
-
addInsert
Add all the statements in the model to the insert statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
model
- The model to insert.- Returns:
- this builder for chaining.
-
addInsert
Add all the triples in the model to the insert statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
collection
- The triples to insert.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
addInsertQuads
Add all the quads in the collection to the insert statement.- Parameters:
collection
- The quads to insert.- Returns:
- this builder for chaining.
-
addInsert
Add all the triples to the insert statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
iter
- The iterator of triples to insert.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
addInsert
Add all the statements in the model a specified graph to the insert statement. The graph object is converted by a call to makeNode().- Parameters:
g
- the graph for the triple.model
- the model to add.- Returns:
- this builder for chaining.
- See Also:
-
addInsert
Add triples to the insert statement.- Parameters:
g
- the name of the graph to add the triples to.collection
- The triples to insert.- Returns:
- this builder for chaining.
-
addInsert
Add triples to the insert statement.- Parameters:
g
- the name of the graph to add the triples to.iter
- The iterator of triples to insert.- Returns:
- this builder for chaining.
-
addInsert
Add the statements from the where clause in the specified query builder to the insert statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
queryBuilder
- The query builder to extract the where clause from.- Returns:
- this builder for chaining.
- See Also:
-
makeNode(Object)
Quad.defaultGraphNodeGenerated
-
addInsert
Add the statements from the where clause in the specified query builder to the insert statements for the specified graph. The graph object is converted by a call to makeNode().- Parameters:
graph
- the graph to add the statements to.queryBuilder
- The query builder to extract the where clause from.- Returns:
- this builder for chaining.
- See Also:
-
addDelete
Add a quad to the delete statement. Arguments are converted to nodes using the makeNode() method.- Parameters:
g
- the graphs
- the subjectp
- the predicateo
- the object- Returns:
- this builder for chaining.
- See Also:
-
addDelete
Add a quad to the delete statement.- Parameters:
quad
- the quad to add.- Returns:
- this builder for chaining.
-
addDeleteQuads
Add all the quads collection to the delete statement.- Parameters:
collection
- The quads to insert.- Returns:
- this builder for chaining.
-
addDelete
Add a triple to the delete statement. Arguments are converted to nodes using the makeNode() method.- Parameters:
s
- the subjectp
- the predicateo
- the object- Returns:
- this builder for chaining.
- See Also:
-
addDelete
Add a triple to the delete statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
t
- the triple to add.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
addDelete
Add a triple to the delete statement. The graph object is converted by a call to makeNode().- Parameters:
g
- the graph for the triple.t
- the triple to add.- Returns:
- this builder for chaining.
- See Also:
-
addDelete
Add all the statements in the model to the delete statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
model
- The model to insert.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
addDelete
Add all triples to the delete statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
collection
- The collection of triples to insert.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
addDelete
Add all the triples in the iterator to the delete statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
iter
- The iterator of triples to insert.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
addDelete
Add all the statements in the model a specified graph to the delete statement. The graph object is converted by a call to makeNode().- Parameters:
g
- the graph for the triples.model
- the model to add.- Returns:
- this builder for chaining.
- See Also:
-
addDelete
Add all the statements in the model to the delete statement.- Parameters:
g
- the graph for the triples.collection
- The collection of triples to insert.- Returns:
- this builder for chaining.
-
addDelete
Add all the statements in the model to the delete statement.- Parameters:
g
- the graph for the triples.iter
- The iterator of triples to insert.- Returns:
- this builder for chaining.
-
addDelete
Add the statements from the where clause in the specified query builder to the delete statement. Uses Quad.defaultGraphNodeGenerated as the graph name.- Parameters:
queryBuilder
- The query builder to extract the where clause from.- Returns:
- this builder for chaining.
- See Also:
-
makeNode(Object)
Quad.defaultGraphNodeGenerated
-
addDelete
Add the statements from the where clause in the specified query builder to the delete statements for the specified graph. The graph object is converted by a call to makeNode().- Parameters:
graph
- the graph to add the statements to.queryBuilder
- The query builder to extract the where clause from.- Returns:
- this builder for chaining.
- See Also:
-
addPrefix
Add the prefix to the prefix mapping.- Parameters:
pfx
- the prefix to add.uri
- the uri for the prefix.- Returns:
- this builder for chaining
-
addPrefix
Add the prefix to the prefix mapping.- Parameters:
pfx
- the prefix to add.uri
- the uri for the prefix.- Returns:
- this builder for chaining
-
addPrefix
Add the prefix to the prefix mapping.- Parameters:
pfx
- the prefix to add.uri
- the uri for the prefix.- Returns:
- this builder for chaining
-
addPrefixes
Add the prefixes to the prefix mapping.- Parameters:
prefixes
- the prefixes to add.- Returns:
- this builder for chaining
-
getExprFactory
Get an ExprFactory that uses the prefixes from this builder.- Returns:
- the ExpressionFactory.
-
setVar
public void setVar(org.apache.jena.sparql.core.Var var, org.apache.jena.graph.Node value) Set a variable replacement. During build all instances of var in the query will be replaced with value. If value is null the replacement is cleared.- Parameters:
var
- The variable to replacevalue
- The value to replace it with or null to remove the replacement.
-
setVar
Set a variable replacement. During build all instances of var in the query will be replaced with value. If value is null the replacement is cleared. SeemakeVar(java.lang.Object)
for conversion of the var param. SeemakeNode(java.lang.Object)
for conversion of the value param.- Parameters:
var
- The variable to replace.value
- The value to replace it with or null to remove the replacement.
-
addAll
Add all where attributes from the Where Handler argument.- Parameters:
whereHandler
- The Where Handler to copy from.
-
addWhere
public UpdateBuilder addWhere(org.apache.jena.sparql.core.TriplePath t) throws IllegalArgumentException Add the triple path to the where clause- Parameters:
t
- The triple path to add.- Throws:
IllegalArgumentException
- If the triple path is not a valid triple path for a where clause.
-
addWhere
Add the WhereClause- Parameters:
whereClause
-- Throws:
IllegalArgumentException
- If the triple path is not a valid triple path for a where clause.
-
addOptional
public UpdateBuilder addOptional(org.apache.jena.sparql.core.TriplePath t) throws IllegalArgumentException Add an optional triple to the where clause- Parameters:
t
- The triple path to add.- Returns:
- The Builder for chaining.
- Throws:
IllegalArgumentException
- If the triple is not a valid triple for a where clause.
-
addOptional
public UpdateBuilder addOptional(Collection<org.apache.jena.sparql.core.TriplePath> collection) throws IllegalArgumentException Add an optional triple to the where clause- Parameters:
collection
- The collection ofTriplePath
path to add.- Returns:
- The Builder for chaining.
- Throws:
IllegalArgumentException
- If the triple is not a valid triple for a where clause.
-
addOptional
Add the contents of a where handler as an optional statement.- Parameters:
whereHandler
- The where handler to use as the optional statement.
-
addFilter
Add an expression string as a filter.- Parameters:
expression
- The expression string to add.- Returns:
- The Builder for chaining.
-
addSubQuery
Add a subquery to the where clause.- Parameters:
subQuery
- The sub query to add.- Returns:
- The Builder for chaining.
-
addUnion
Add a union to the where clause.- Parameters:
subQuery
- The subquery to add as the union.- Returns:
- The Builder for chaining.
-
addGraph
Add a graph to the where clause.- Parameters:
graph
- The name of the graph.subQuery
- The where handler that defines the graph.
-
addBind
public UpdateBuilder addBind(org.apache.jena.sparql.expr.Expr expr, org.apache.jena.sparql.core.Var var) Add a binding to the where clause.- Parameters:
expr
- The expression to bind.var
- The variable to bind it to.
-
addBind
Add a binding to the where clause.- Parameters:
expression
- The expression to bind.var
- The variable to bind it to.
-
list
Deprecated.use makeListCreate a list node from a list of objects as per RDF Collections. http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections SeeAbstractQueryBuilder.makeNode(java.lang.Object)
for conversion of the param values.usage:
- list( param1, param2, param3, ... )
- addWhere( list( param1, param2, param3, ... ), p, o )
- addOptional( list( param1, param2, param3, ... ), p, o )
- Parameters:
objs
- the list of objects for the list.- Returns:
- the first blank node in the list.
- See Also:
-
makeList
Create a list node from a list of objects as per RDF Collections. http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections SeeAbstractQueryBuilder.makeNode(java.lang.Object)
for conversion of the param values.usage:
- list( param1, param2, param3, ... )
- addWhere( list( param1, param2, param3, ... ), p, o )
- addOptional( list( param1, param2, param3, ... ), p, o )
- Parameters:
objs
- the list of objects for the list.- Returns:
- the first blank node in the list.
-
addWhere
Adds a triple to the where clause.- Parameters:
t
- The triple path to add- Returns:
- The Builder for chaining.
-
addWhere
Adds a triple to the where clause.- Parameters:
t
- The triple to add- Returns:
- The Builder for chaining.
-
addWhere
Adds a triple or triple path to the where clause. SeeAbstractQueryBuilder.makeTriplePath(java.lang.Object, java.lang.Object, java.lang.Object)
for conversion of the param values.- Parameters:
s
- The subject.p
- The predicate.o
- The object.- Returns:
- The Builder for chaining.
-
addOptional
Adds an optional triple to the where clause.- Parameters:
t
- The triple to add- Returns:
- The Builder for chaining.
-
addOptional
Adds an optional triple as to the where clause.- Parameters:
t
- The triple to add- Returns:
- The Builder for chaining.
-
addOptional
Adds an optional triple or triple path to the where clause. SeeAbstractQueryBuilder.makeTriplePath(java.lang.Object, java.lang.Object, java.lang.Object)
for conversion of the param values.- Parameters:
s
- The subject.p
- The predicate.o
- The object.- Returns:
- The Builder for chaining.
-
addOptional
Adds an optional group pattern to the where clause.- Parameters:
t
- The select builder to add as an optional pattern- Returns:
- The Builder for chaining.
-
addFilter
Adds a filter to the where clause Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr methods to create the expression.- Parameters:
expression
- the expression to evaluate for the filter.- Returns:
- The Builder for chaining.
- See Also:
-
addGraph
Add a graph statement to the query as per http://www.w3.org/TR/2013/REC-sparql11 -query-20130321/#rGraphGraphPattern. SeeAbstractQueryBuilder.makeNode(java.lang.Object)
for conversion of the graph param.- Parameters:
graph
- The iri or variable identifying the graph.subQuery
- The graph to add.- Returns:
- This builder for chaining.
-
addBind
Add a bind statement to the query * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.- Parameters:
expression
- The expression to bind to the var.var
- The variable to bind to.- Returns:
- This builder for chaining.
-
addBind
Add a bind statement to the query http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.- Parameters:
expression
- The expression to bind to the var.var
- The variable to bind to.- Returns:
- This builder for chaining.
-
addMinus
Add a minus clause to the query. https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rMinusGraphPattern- Parameters:
t
- The select builder to add as a minus pattern- Returns:
- this builder for chaining
-
with
Specify the graph for all inserts and deletes.- Parameters:
iri
- the IRI for the graph to use.- Returns:
- this builder for chaining.
- See Also:
-
Quad.defaultGraphNodeGenerated
-
buildDeleteWhere
public org.apache.jena.sparql.modify.request.UpdateDeleteWhere buildDeleteWhere()Create a DeleteWhere from the where clause.- Returns:
- a DeleteWhere update.
-
buildDeleteWhere
public org.apache.jena.sparql.modify.request.UpdateDeleteWhere buildDeleteWhere(AbstractQueryBuilder<?> queryBuilder) Create a DeleteWhere from the where clause.- Parameters:
queryBuilder
- the query builder to extract the where clause from.- Returns:
- a DeleteWhere update.
-