public class AskBuilder extends AbstractQueryBuilder<AskBuilder> implements DatasetClause<AskBuilder>, WhereClause<AskBuilder>, SolutionModifierClause<AskBuilder>
The AskBuilder provides chainable methods to programmatically generate SPARQL Ask Queries.
The application order of the methods is not relevant for the resulting query.
An ExprFactory is intended for use along with the AskBuilder to generate needed Expr parameter values.
An ExprFactory that works with the same prefixes can be obtained with AbstractQueryBuilder.getExprFactory().
The AskBuilder can be used as prepared 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.
ConstructBuilder,
DescribeBuilder,
SelectBuilder,
UpdateBuilder| Constructor and Description |
|---|
AskBuilder() |
| Modifier and Type | Method and Description |
|---|---|
AskBuilder |
addBind(Expr expression,
Object var)
Add a bind statement to the query *
http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
|
AskBuilder |
addBind(String expression,
Object var)
Add a bind statement to the query
http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
|
AskBuilder |
addFilter(Expr expr)
Adds a filter to the where clause
Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr
methods to create the expression.
|
AskBuilder |
addFilter(String s)
Adds a filter to the where clause
|
AskBuilder |
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.
|
AskBuilder |
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.
|
AskBuilder |
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.
|
AskBuilder |
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.
|
AskBuilder |
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.
|
AskBuilder |
addGroupBy(Expr groupBy)
Add an expression to the group by clause.
|
AskBuilder |
addGroupBy(Object groupBy)
Add a variable to the group by clause.
|
AskBuilder |
addGroupBy(Object var,
Expr expr)
Add var and expression to the group by clause.
|
AskBuilder |
addGroupBy(Object var,
String expr)
Add var and expression to the group by clause.
|
AskBuilder |
addHaving(Expr expression)
Add a having expression.
|
AskBuilder |
addHaving(Object var)
Add a having expression.
|
AskBuilder |
addHaving(String having)
Add a having expression.
|
AskBuilder |
addMinus(AbstractQueryBuilder<?> t)
Add a minus clause to the query.
|
AskBuilder |
addOptional(AbstractQueryBuilder<?> t)
Adds an optional group pattern to the where clause.
|
AskBuilder |
addOptional(FrontsTriple t)
Adds an optional triple as to the where clause.
|
AskBuilder |
addOptional(Object s,
Object p,
Object o)
Adds an optional triple or triple path to the where clause.
|
AskBuilder |
addOptional(Triple t)
Adds an optional triple to the where clause.
|
AskBuilder |
addOptional(TriplePath t)
Adds an optional triple path to the where clause.
|
AskBuilder |
addOrderBy(Expr orderBy)
Add an ascending order by.
|
AskBuilder |
addOrderBy(Expr orderBy,
Order order)
Add an order by with direction specified.
|
AskBuilder |
addOrderBy(Object orderBy)
Add an ascending order by.
|
AskBuilder |
addOrderBy(Object orderBy,
Order order)
Add an order by with direction specified.
|
AskBuilder |
addOrderBy(SortCondition orderBy)
Add an ascending order by.
|
AskBuilder |
addSubQuery(AbstractQueryBuilder<?> subQuery)
Add a sub query.
|
AskBuilder |
addUnion(AbstractQueryBuilder<?> subQuery)
Add a union.
|
AskBuilder |
addWhere(FrontsTriple t)
Adds a triple to the where clause.
|
AskBuilder |
addWhere(Object s,
Object p,
Object o)
Adds a triple or triple path to the where clause.
|
AskBuilder |
addWhere(Triple t)
Adds a triple to the where clause.
|
AskBuilder |
addWhere(TriplePath t)
Adds a triple path to the where clause.
|
AskBuilder |
addWhereValueRow(Collection<?> values)
Add a collection of objects as row of values.
|
AskBuilder |
addWhereValueRow(Object... values)
Add objects as a row of values.
|
AskBuilder |
addWhereValueVar(Object var)
Add a variable or variable and values to the value statement.
|
AskBuilder |
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.
|
AskBuilder |
clearWhereValues()
Reset the values table in the where clause to the initial
undefined state.
|
AskBuilder |
clone() |
AskBuilder |
from(Collection<String> graphName)
Add several "FROM" graph names.
|
AskBuilder |
from(String graphName)
Add the "FROM" graph name.
|
AskBuilder |
fromNamed(Collection<String> graphNames)
Add several "FROM NAMED" graph names.
|
AskBuilder |
fromNamed(String graphName)
Add the "FROM NAMED" graph name.
|
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.
|
AskBuilder |
setLimit(int limit)
Set the limit.
|
AskBuilder |
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 HandlerBlock getHandlerBlock()
AbstractQueryBuildergetHandlerBlock in class AbstractQueryBuilder<AskBuilder>public DatasetHandler getDatasetHandler()
DatasetClausegetDatasetHandler in interface DatasetClause<AskBuilder>public AskBuilder clone()
public AskBuilder fromNamed(String graphName)
DatasetClausefromNamed in interface DatasetClause<AskBuilder>graphName - the graph name to add.public AskBuilder fromNamed(Collection<String> graphNames)
DatasetClausefromNamed in interface DatasetClause<AskBuilder>graphNames - the collection graph names to add.public AskBuilder from(String graphName)
DatasetClausefrom in interface DatasetClause<AskBuilder>graphName - the graph name to add.public AskBuilder from(Collection<String> graphName)
DatasetClausefrom in interface DatasetClause<AskBuilder>graphName - the collection graph names to add.public AskBuilder addWhere(TriplePath t)
WhereClauseaddWhere in interface WhereClause<AskBuilder>t - The triple path to addpublic AskBuilder addWhere(Triple t)
WhereClauseaddWhere in interface WhereClause<AskBuilder>t - The triple path to addpublic AskBuilder addWhere(FrontsTriple t)
WhereClauseaddWhere in interface WhereClause<AskBuilder>t - The triple to addpublic AskBuilder 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<AskBuilder>s - The subject.p - The predicate.o - The object.public AskBuilder addWhereValueVar(Object var)
WhereClauseaddWhereValueVar in interface WhereClause<AskBuilder>var - The variable or collection to add.AbstractQueryBuilder.makeNode(Object),
Converters.makeVar(Object)public AskBuilder addWhereValueVar(Object var, Object... values)
WhereClauseaddWhereValueVar in interface WhereClause<AskBuilder>var - The variable to add.values - The values for the variableAbstractQueryBuilder.makeNode(Object),
Converters.makeVar(Object)public <K extends Collection<?>> AskBuilder addWhereValueVars(Map<?,K> dataTable)
WhereClauseaddWhereValueVars in interface WhereClause<AskBuilder>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 AskBuilder addWhereValueRow(Object... values)
WhereClauseaddWhereValueRow in interface WhereClause<AskBuilder>values - the collection of values to add.AbstractQueryBuilder.makeNode(Object)public AskBuilder addWhereValueRow(Collection<?> values)
WhereClauseaddWhereValueRow in interface WhereClause<AskBuilder>values - the collection of values to add.AbstractQueryBuilder.makeNode(Object)public List<Var> getWhereValuesVars()
WhereClausegetWhereValuesVars in interface WhereClause<AskBuilder>public Map<Var,List<Node>> getWhereValuesMap()
WhereClausegetWhereValuesMap in interface WhereClause<AskBuilder>public AskBuilder clearWhereValues()
WhereClauseclearWhereValues in interface WhereClause<AskBuilder>public AskBuilder addOptional(TriplePath t)
WhereClauseaddOptional in interface WhereClause<AskBuilder>t - The triple path to addpublic AskBuilder addOptional(Triple t)
WhereClauseaddOptional in interface WhereClause<AskBuilder>t - The triple to addpublic AskBuilder addOptional(AbstractQueryBuilder<?> t)
WhereClauseaddOptional in interface WhereClause<AskBuilder>t - The select builder to add as an optional patternpublic AskBuilder addOptional(FrontsTriple t)
WhereClauseaddOptional in interface WhereClause<AskBuilder>t - The triple to addpublic AskBuilder 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<AskBuilder>s - The subject.p - The predicate.o - The object.public AskBuilder addFilter(Expr expr)
WhereClauseaddFilter in interface WhereClause<AskBuilder>expr - the expression to evaluate for the filter.ExprFactory,
NodeValue,
AbstractQueryBuilder.makeExpr(String)public AskBuilder addFilter(String s) throws ParseException
WhereClauseaddFilter in interface WhereClause<AskBuilder>s - the expression to evaluate for the filter.ParseException - If the expression can not be parsed.public AskBuilder addSubQuery(AbstractQueryBuilder<?> subQuery)
WhereClauseaddSubQuery in interface WhereClause<AskBuilder>subQuery - The subquery as defined by a SelectBuilder.public AskBuilder addUnion(AbstractQueryBuilder<?> subQuery)
WhereClauseaddUnion in interface WhereClause<AskBuilder>subQuery - The union as defined by a SelectBuilder.public AskBuilder addGraph(Object graph, AbstractQueryBuilder<?> subQuery)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<AskBuilder>graph - The iri or variable identifying the graph.subQuery - The graph to add.public AskBuilder addGraph(Object graph, FrontsTriple triple)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<AskBuilder>graph - The iri or variable identifying the graph.triple - a single s, p, o triple for the query.public AskBuilder addGraph(Object graph, Object subject, Object predicate, Object object)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<AskBuilder>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 AskBuilder addGraph(Object graph, Triple triple)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<AskBuilder>graph - The iri or variable identifying the graph.triple - a single triple for the query.public AskBuilder addGraph(Object graph, TriplePath triplePath)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the graph
param.addGraph in interface WhereClause<AskBuilder>graph - The iri or variable identifying the graph.triplePath - a single triple path for the query.public AskBuilder addBind(Expr expression, Object var)
WhereClauseaddBind in interface WhereClause<AskBuilder>expression - The expression to bind to the var.var - The variable to bind to.public AskBuilder addBind(String expression, Object var) throws ParseException
WhereClauseaddBind in interface WhereClause<AskBuilder>expression - The expression to bind to the var.var - The variable to bind to.ParseExceptionpublic AskBuilder addOrderBy(Expr orderBy)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<AskBuilder>orderBy - The expression to order by.ExprFactory,
NodeValue,
AbstractQueryBuilder.makeExpr(String)public AskBuilder addOrderBy(Object orderBy)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<AskBuilder>orderBy - The object to order by.public AskBuilder addOrderBy(SortCondition orderBy)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<AskBuilder>orderBy - The SortCondition to order by.public AskBuilder addOrderBy(Expr orderBy, Order order)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<AskBuilder>orderBy - The expression to order by.order - The direction to order.public AskBuilder addOrderBy(Object orderBy, Order order)
SolutionModifierClauseaddOrderBy in interface SolutionModifierClause<AskBuilder>orderBy - The object to order by.order - The direction to order.public AskBuilder addGroupBy(Object groupBy)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<AskBuilder>groupBy - The object to group by.public AskBuilder addGroupBy(Expr groupBy)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<AskBuilder>groupBy - The expression to add.public AskBuilder addGroupBy(Object var, Expr expr)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<AskBuilder>var - The variable to add.expr - The expression to add.public AskBuilder addGroupBy(Object var, String expr)
SolutionModifierClauseaddGroupBy in interface SolutionModifierClause<AskBuilder>var - The variable to add.expr - The expression to add.public AskBuilder addHaving(String having) throws ParseException
SolutionModifierClauseaddHaving in interface SolutionModifierClause<AskBuilder>having - Expression to evaluate for the having.ParseExceptionpublic AskBuilder addHaving(Expr expression) throws ParseException
SolutionModifierClauseaddHaving in interface SolutionModifierClause<AskBuilder>expression - Expression to evaluate for the having.ParseExceptionExprFactory,
NodeValue,
AbstractQueryBuilder.makeExpr(String)public AskBuilder addHaving(Object var) throws ParseException
SolutionModifierClauseaddHaving in interface SolutionModifierClause<AskBuilder>var - the variable to have.ParseExceptionpublic AskBuilder setLimit(int limit)
SolutionModifierClausesetLimit in interface SolutionModifierClause<AskBuilder>limit - the maximum number of results to return.public AskBuilder setOffset(int offset)
SolutionModifierClausesetOffset in interface SolutionModifierClause<AskBuilder>offset - the number of results to skip before returning results..public SolutionModifierHandler getSolutionModifierHandler()
SolutionModifierClausegetSolutionModifierHandler in interface SolutionModifierClause<AskBuilder>public Node list(Object... objs)
WhereClauseAbstractQueryBuilder.makeNode(java.lang.Object) for conversion of the param
values.
usage:
list in interface WhereClause<AskBuilder>objs - the list of objects for the list.public AskBuilder addMinus(AbstractQueryBuilder<?> t)
WhereClauseaddMinus in interface WhereClause<AskBuilder>t - The select builder to add as a minus patternLicensed under the Apache License, Version 2.0