public class ConstructBuilder extends AbstractQueryBuilder<ConstructBuilder> implements DatasetClause<ConstructBuilder>, WhereClause<ConstructBuilder>, SolutionModifierClause<ConstructBuilder>, ConstructClause<ConstructBuilder>
The ConstructBuilder provides chainable methods to programmatically generate SPARQL Construct Queries.
The application order of the methods is not relevant for the resulting query.
An ExprFactory is intended for use along with the ConstructBuilder to generate needed Expr parameter values.
An ExprFactory that works with the same prefixes can be obtained with AbstractQueryBuilder.getExprFactory().
The ConstructBuilder can be used asprepared query.
Values for variables in the created query can be set with AbstractQueryBuilder.setVar(Object, Object) and AbstractQueryBuilder.setVar(Var, Node).
The method clearWhereValues() allows to clear the set values.
AskBuilder,
DescribeBuilder,
SelectBuilder,
UpdateBuilder| Constructor and Description |
|---|
ConstructBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ConstructBuilder |
addBind(Expr expression,
Object var)
Add a bind statement to the query *
http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
|
ConstructBuilder |
addBind(String expression,
Object var)
Add a bind statement to the query
http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
|
ConstructBuilder |
addConstruct(FrontsTriple t)
Add a construct triple.
|
ConstructBuilder |
addConstruct(Object s,
Object p,
Object o)
Add a construct triple.
|
ConstructBuilder |
addConstruct(Triple t)
Add a construct triple.
|
ConstructBuilder |
addFilter(Expr expr)
Adds a filter to the where clause
Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr
methods to create the expression.
|
ConstructBuilder |
addFilter(String s)
Adds a filter to the where clause
|
ConstructBuilder |
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.
|
ConstructBuilder |
addGraph(Object graph,
FrontsTriple triple)
Add a graph statement to the query as per
http://www.w3.org/TR/2013/REC-sparql11
-query-20130321/#rGraphGraphPattern.
|
ConstructBuilder |
addGraph(Object graph,
Object subject,
Object predicate,
Object object)
Add a graph statement to the query as per
http://www.w3.org/TR/2013/REC-sparql11
-query-20130321/#rGraphGraphPattern.
|
ConstructBuilder |
addGraph(Object graph,
Triple triple)
Add a graph statement to the query as per
http://www.w3.org/TR/2013/REC-sparql11
-query-20130321/#rGraphGraphPattern.
|
ConstructBuilder |
addGraph(Object graph,
TriplePath triplePath)
Add a graph statement to the query as per
http://www.w3.org/TR/2013/REC-sparql11
-query-20130321/#rGraphGraphPattern.
|
ConstructBuilder |
addGroupBy(Expr groupBy)
Add an expression to the group by clause.
|
ConstructBuilder |
addGroupBy(Object groupBy)
Add a variable to the group by clause.
|
ConstructBuilder |
addGroupBy(Object var,
Expr expr)
Add var and expression to the group by clause.
|
ConstructBuilder |
addGroupBy(Object var,
String expr)
Add var and expression to the group by clause.
|
ConstructBuilder |
addHaving(Expr expression)
Add a having expression.
|
ConstructBuilder |
addHaving(Object var)
Add a having expression.
|
ConstructBuilder |
addHaving(String having)
Add a having expression.
|
ConstructBuilder |
addMinus(AbstractQueryBuilder<?> t)
Add a minus clause to the query.
|
ConstructBuilder |
addOptional(AbstractQueryBuilder<?> t)
Adds an optional group pattern to the where clause.
|
ConstructBuilder |
addOptional(FrontsTriple t)
Adds an optional triple as to the where clause.
|
ConstructBuilder |
addOptional(Object s,
Object p,
Object o)
Adds an optional triple or triple path to the where clause.
|
ConstructBuilder |
addOptional(Triple t)
Adds an optional triple to the where clause.
|
ConstructBuilder |
addOptional(TriplePath t)
Adds an optional triple path to the where clause.
|
ConstructBuilder |
addOrderBy(Expr orderBy)
Add an ascending order by.
|
ConstructBuilder |
addOrderBy(Expr orderBy,
Order order)
Add an order by with direction specified.
|
ConstructBuilder |
addOrderBy(Object orderBy)
Add an ascending order by.
|
ConstructBuilder |
addOrderBy(Object orderBy,
Order order)
Add an order by with direction specified.
|
ConstructBuilder |
addOrderBy(SortCondition orderBy)
Add an ascending order by.
|
ConstructBuilder |
addSubQuery(AbstractQueryBuilder<?> subQuery)
Add a sub query.
|
ConstructBuilder |
addUnion(AbstractQueryBuilder<?> subQuery)
Add a union.
|
ConstructBuilder |
addWhere(FrontsTriple t)
Adds a triple to the where clause.
|
ConstructBuilder |
addWhere(Object s,
Object p,
Object o)
Adds a triple or triple path to the where clause.
|
ConstructBuilder |
addWhere(Triple t)
Adds a triple to the where clause.
|
ConstructBuilder |
addWhere(TriplePath t)
Adds a triple path to the where clause.
|
ConstructBuilder |
addWhereValueRow(Collection<?> values)
Add a collection of objects as row of values.
|
ConstructBuilder |
addWhereValueRow(Object... values)
Add objects as a row of values.
|
ConstructBuilder |
addWhereValueVar(Object var)
Add a variable or variable and values to the value statement.
|
ConstructBuilder |
addWhereValueVar(Object var,
Object... values)
Add a variable and values to the value statement.
|
<K extends Collection<?>> |
addWhereValueVars(Map<?,K> dataTable)
Add a data table to the value statement.
|
ConstructBuilder |
clearWhereValues()
Reset the values table in the where clause to the initial
undefined state.
|
ConstructBuilder |
clone() |
ConstructBuilder |
from(Collection<String> graphName)
Add several "FROM" graph names.
|
ConstructBuilder |
from(String graphName)
Add the "FROM" graph name.
|
ConstructBuilder |
fromNamed(Collection<String> graphNames)
Add several "FROM NAMED" graph names.
|
ConstructBuilder |
fromNamed(String graphName)
Add the "FROM NAMED" graph name.
|
ConstructHandler |
getConstructHandler()
Get the Construct handler for this construct clause.
|
DatasetHandler |
getDatasetHandler()
Get the Dataset handler for this clause.
|
HandlerBlock |
getHandlerBlock()
Get the HandlerBlock for this query builder.
|
SolutionModifierHandler |
getSolutionModifierHandler()
Get the Solution modifier for this clause.
|
Map<Var,List<Node>> |
getWhereValuesMap()
Get an unmodifiable map of vars from the where clause values and their values.
|
List<Var> |
getWhereValuesVars()
Get an unmodifiable list of vars from the where clause values in the order that they appear
in the values table.
|
Node |
list(Object... objs)
Create a list node from a list of objects as per RDF Collections.
|
ConstructBuilder |
setLimit(int limit)
Set the limit.
|
ConstructBuilder |
setOffset(int offset)
Set the offset.
|
addPrefix, addPrefix, addPrefix, addPrefixes, addPrefixes, addValueRow, addValueRow, addValueVar, addValueVar, addValueVars, addWhere, asSubQuery, build, buildString, checkVar, clearValues, clone, getExprFactory, getPrologHandler, getValuesHandler, getValuesMap, getValuesVars, getWhereHandler, makeExpr, makeNode, makeNode, makeNodeOrPath, makeTriplePath, makeValueNodes, makeValueNodes, makeVar, quote, rewrite, setBase, setBase, setVar, setVar, toStringequals, getClass, hashCode, notify, notifyAll, wait, wait, waitaddWhere, getWhereHandlerpublic DatasetHandler getDatasetHandler()
DatasetClausegetDatasetHandler in interface DatasetClause<ConstructBuilder>public ConstructHandler getConstructHandler()
ConstructClausegetConstructHandler in interface ConstructClause<ConstructBuilder>public SolutionModifierHandler getSolutionModifierHandler()
SolutionModifierClausegetSolutionModifierHandler in interface SolutionModifierClause<ConstructBuilder>public HandlerBlock getHandlerBlock()
AbstractQueryBuildergetHandlerBlock in class AbstractQueryBuilder<ConstructBuilder>public ConstructBuilder clone()
public ConstructBuilder fromNamed(String graphName)
DatasetClausefromNamed in interface DatasetClause<ConstructBuilder>graphName - the graph name to add.public ConstructBuilder fromNamed(Collection<String> graphNames)
DatasetClausefromNamed in interface DatasetClause<ConstructBuilder>graphNames - the collection graph names to add.public ConstructBuilder from(String graphName)
DatasetClausefrom in interface DatasetClause<ConstructBuilder>graphName - the graph name to add.public ConstructBuilder from(Collection<String> graphName)
DatasetClausefrom in interface DatasetClause<ConstructBuilder>graphName - the collection graph names to add.public ConstructBuilder addOrderBy(Expr orderBy)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<ConstructBuilder>orderBy - The expression to order by.ExprFactory,
NodeValue,
AbstractQueryBuilder.makeExpr(String)public ConstructBuilder addOrderBy(Object orderBy)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<ConstructBuilder>orderBy - The object to order by.public ConstructBuilder addOrderBy(SortCondition orderBy)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<ConstructBuilder>orderBy - The SortCondition to order by.public ConstructBuilder addOrderBy(Expr orderBy, Order order)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<ConstructBuilder>orderBy - The expression to order by.order - The direction to order.public ConstructBuilder addOrderBy(Object orderBy, Order order)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<ConstructBuilder>orderBy - The object to order by.order - The direction to order.public ConstructBuilder addGroupBy(Object groupBy)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<ConstructBuilder>groupBy - The object to group by.public ConstructBuilder addGroupBy(Expr groupBy)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<ConstructBuilder>groupBy - The expression to add.public ConstructBuilder addGroupBy(Object var, Expr expr)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<ConstructBuilder>var - The variable to add.expr - The expression to add.public ConstructBuilder addGroupBy(Object var, String expr)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<ConstructBuilder>var - The variable to add.expr - The expression to add.public ConstructBuilder addHaving(String having) throws ParseException
SolutionModifierClauseaddHaving in interface SolutionModifierClause<ConstructBuilder>having - Expression to evaluate for the having.ParseExceptionpublic ConstructBuilder addHaving(Expr expression) throws ParseException
SolutionModifierClauseaddHaving in interface SolutionModifierClause<ConstructBuilder>expression - Expression to evaluate for the having.ParseExceptionExprFactory,
NodeValue,
AbstractQueryBuilder.makeExpr(String)public ConstructBuilder addHaving(Object var) throws ParseException
SolutionModifierClauseaddHaving in interface SolutionModifierClause<ConstructBuilder>var - the variable to have.ParseExceptionpublic ConstructBuilder setLimit(int limit)
SolutionModifierClausesetLimit in interface SolutionModifierClause<ConstructBuilder>limit - the maximum number of results to return.public ConstructBuilder setOffset(int offset)
SolutionModifierClausesetOffset in interface SolutionModifierClause<ConstructBuilder>offset - the number of results to skip before returning results..public ConstructBuilder addWhere(TriplePath t)
WhereClauseaddWhere in interface WhereClause<ConstructBuilder>t - The triple path to addpublic ConstructBuilder addWhere(Triple t)
WhereClauseaddWhere in interface WhereClause<ConstructBuilder>t - The triple path to addpublic ConstructBuilder addWhere(FrontsTriple t)
WhereClauseaddWhere in interface WhereClause<ConstructBuilder>t - The triple to addpublic ConstructBuilder addWhere(Object s, Object p, Object o)
WhereClauseAbstractQueryBuilder.makeTriplePath(java.lang.Object, java.lang.Object, java.lang.Object) for conversion of the
param values.addWhere in interface WhereClause<ConstructBuilder>s - The subject.p - The predicate.o - The object.public ConstructBuilder addWhereValueVar(Object var)
WhereClauseaddWhereValueVar in interface WhereClause<ConstructBuilder>var - The variable or collection to add.AbstractQueryBuilder.makeNode(Object),
Converters.makeVar(Object)public ConstructBuilder addWhereValueVar(Object var, Object... values)
WhereClauseaddWhereValueVar in interface WhereClause<ConstructBuilder>var - The variable to add.values - The values for the variableAbstractQueryBuilder.makeNode(Object),
Converters.makeVar(Object)public <K extends Collection<?>> ConstructBuilder addWhereValueVars(Map<?,K> dataTable)
WhereClauseaddWhereValueVars in interface WhereClause<ConstructBuilder>dataTable - The data table to add.Each item in the value collection is converted into a node using makeNode() strategy except that null values are converted
to UNDEF.
If there are already values in the value statement the data table is adds as follows:
- If the variable already exists in the table the map values are appended to the list of values
- If the variable does not exist in the table and there are other variables defined, an appropriate
number of nulls is added to the front of the map values to create UNDEF entries for the existing rows
- If there are variables in the value statement that are not specified in the map additional UNDEF
entries are appended to them to account for new rows that are added.
,
AbstractQueryBuilder.makeNode(Object),
Converters.makeVar(Object)public ConstructBuilder addWhereValueRow(Object... values)
WhereClauseaddWhereValueRow in interface WhereClause<ConstructBuilder>values - the collection of values to add.AbstractQueryBuilder.makeNode(Object)public ConstructBuilder addWhereValueRow(Collection<?> values)
WhereClauseaddWhereValueRow in interface WhereClause<ConstructBuilder>values - the collection of values to add.AbstractQueryBuilder.makeNode(Object)public List<Var> getWhereValuesVars()
WhereClausegetWhereValuesVars in interface WhereClause<ConstructBuilder>public Map<Var,List<Node>> getWhereValuesMap()
WhereClausegetWhereValuesMap in interface WhereClause<ConstructBuilder>public ConstructBuilder clearWhereValues()
WhereClauseclearWhereValues in interface WhereClause<ConstructBuilder>public ConstructBuilder addOptional(TriplePath t)
WhereClauseaddOptional in interface WhereClause<ConstructBuilder>t - The triple path to addpublic ConstructBuilder addOptional(Triple t)
WhereClauseaddOptional in interface WhereClause<ConstructBuilder>t - The triple to addpublic ConstructBuilder addOptional(AbstractQueryBuilder<?> t)
WhereClauseaddOptional in interface WhereClause<ConstructBuilder>t - The select builder to add as an optional patternpublic ConstructBuilder addOptional(FrontsTriple t)
WhereClauseaddOptional in interface WhereClause<ConstructBuilder>t - The triple to addpublic ConstructBuilder addOptional(Object s, Object p, Object o)
WhereClauseAbstractQueryBuilder.makeTriplePath(java.lang.Object, java.lang.Object, java.lang.Object) for conversion of the
param values.addOptional in interface WhereClause<ConstructBuilder>s - The subject.p - The predicate.o - The object.public ConstructBuilder addFilter(Expr expr)
WhereClauseaddFilter in interface WhereClause<ConstructBuilder>expr - the expression to evaluate for the filter.ExprFactory,
NodeValue,
AbstractQueryBuilder.makeExpr(String)public ConstructBuilder addFilter(String s) throws ParseException
WhereClauseaddFilter in interface WhereClause<ConstructBuilder>s - the expression to evaluate for the filter.ParseException - If the expression can not be parsed.public ConstructBuilder addSubQuery(AbstractQueryBuilder<?> subQuery)
WhereClauseaddSubQuery in interface WhereClause<ConstructBuilder>subQuery - The subquery as defined by a SelectBuilder.public ConstructBuilder addUnion(AbstractQueryBuilder<?> subQuery)
WhereClauseaddUnion in interface WhereClause<ConstructBuilder>subQuery - The union as defined by a SelectBuilder.public ConstructBuilder addGraph(Object graph, AbstractQueryBuilder<?> subQuery)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<ConstructBuilder>graph - The iri or variable identifying the graph.subQuery - The graph to add.public ConstructBuilder addGraph(Object graph, FrontsTriple triple)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<ConstructBuilder>graph - The iri or variable identifying the graph.triple - a single s, p, o triple for the query.public ConstructBuilder addGraph(Object graph, Object subject, Object predicate, Object object)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<ConstructBuilder>graph - The iri or variable identifying the graph.subject - The subject for the graph querypredicate - The predicate for the graph query.object - The object for the graph query.public ConstructBuilder addGraph(Object graph, Triple triple)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<ConstructBuilder>graph - The iri or variable identifying the graph.triple - a single triple for the query.public ConstructBuilder addGraph(Object graph, TriplePath triplePath)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<ConstructBuilder>graph - The iri or variable identifying the graph.triplePath - a single triple path for the query.public ConstructBuilder addBind(Expr expression, Object var)
WhereClauseaddBind in interface WhereClause<ConstructBuilder>expression - The expression to bind to the var.var - The variable to bind to.public ConstructBuilder addBind(String expression, Object var) throws ParseException
WhereClauseaddBind in interface WhereClause<ConstructBuilder>expression - The expression to bind to the var.var - The variable to bind to.ParseExceptionpublic ConstructBuilder addConstruct(Triple t)
ConstructClauseaddConstruct in interface ConstructClause<ConstructBuilder>t - The triple to add.public ConstructBuilder addConstruct(FrontsTriple t)
ConstructClauseaddConstruct in interface ConstructClause<ConstructBuilder>t - The triple to add.public ConstructBuilder addConstruct(Object s, Object p, Object o)
ConstructClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the param values.addConstruct in interface ConstructClause<ConstructBuilder>s - The subject of the triple,p - The predicate of the triple.o - The object of the triple.public Node list(Object... objs)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the param
values.
usage:
list in interface WhereClause<ConstructBuilder>objs - the list of objects for the list.public ConstructBuilder addMinus(AbstractQueryBuilder<?> t)
WhereClauseaddMinus in interface WhereClause<ConstructBuilder>t - The select builder to add as a minus patternLicensed under the Apache License, Version 2.0