public class Query extends Prologue implements Cloneable, Printable
QueryExecutionFactory
,
ResultSet
Modifier and Type | Field and Description |
---|---|
static long |
NOLIMIT |
static int |
ORDER_ASCENDING |
static int |
ORDER_DEFAULT |
static int |
ORDER_DESCENDING |
static int |
ORDER_UNKNOW |
static int |
QueryTypeAsk |
static int |
QueryTypeConstruct |
static int |
QueryTypeDescribe |
static int |
QueryTypeSelect |
static int |
QueryTypeUnknown |
Constructor and Description |
---|
Query()
Creates a new empty query
|
Query(Prologue prologue)
Creates a new empty query with the given prologue
|
Modifier and Type | Method and Description |
---|---|
void |
addDescribeNode(Node node) |
void |
addGraphURI(String s)
Location of the source for the data.
|
void |
addGroupBy(Expr expr) |
void |
addGroupBy(Node v) |
void |
addGroupBy(String varName) |
void |
addGroupBy(Var v,
Expr expr) |
void |
addHavingCondition(Expr expr) |
void |
addNamedGraphURI(String uri)
Location of the source for the data.
|
void |
addOrderBy(Expr expr,
int direction) |
void |
addOrderBy(Node var,
int direction) |
void |
addOrderBy(SortCondition condition) |
void |
addOrderBy(String varName,
int direction) |
void |
addProjectVars(Collection<?> vars)
Add a collection of projection variables to a SELECT query
|
void |
addResultVar(Expr expr)
Add an to a SELECT query (a name will be created for it)
|
void |
addResultVar(Node v) |
void |
addResultVar(Node v,
Expr expr) |
void |
addResultVar(String varName)
Add a projection variable to a SELECT query
|
void |
addResultVar(String varName,
Expr expr)
Add a named expression to a SELECT query
|
Expr |
allocAggregate(Aggregator agg) |
Object |
clone() |
Query |
cloneQuery()
Makes a copy of this query.
|
Query |
cloneQuery(boolean useRawQuery)
Makes a copy of this query.
|
boolean |
equals(Object other)
Are two queries equals - tests shape and details.
|
List<ExprAggregator> |
getAggregators() |
Template |
getConstructTemplate()
Get the template pattern for a construct query
|
DatasetDescription |
getDatasetDescription()
Return a dataset description (FROM/FROM NAMED clauses) for the query.
|
List<String> |
getGraphURIs()
Return the list of URIs (strings) for the unnamed graph
|
VarExprList |
getGroupBy() |
List<Expr> |
getHavingExprs() |
long |
getLimit() |
List<String> |
getNamedGraphURIs()
Return the list of URIs (strings) for the named graphs (FROM NAMED clause)
|
long |
getOffset() |
List<SortCondition> |
getOrderBy() |
VarExprList |
getProject() |
List<Var> |
getProjectVars()
Return a list of the variables requested (SELECT)
|
Prologue |
getPrologue() |
Element |
getQueryPattern() |
int |
getQueryType() |
List<Node> |
getResultURIs()
Get the result list (things wanted - not the results themselves)
of a DESCRIBE query.
|
List<String> |
getResultVars()
Return a list of the variables requested (SELECT)
|
Syntax |
getSyntax() |
List<Binding> |
getValuesData()
VALUES data - null for a Node means undef
|
List<Var> |
getValuesVariables() |
boolean |
hasAggregators() |
boolean |
hasDatasetDescription()
Return true if the query has either some graph
URIs or some named graph URIs in its description.
|
boolean |
hasGroupBy() |
boolean |
hasHaving() |
int |
hashCode() |
boolean |
hasLimit() |
boolean |
hasOffset() |
boolean |
hasOrderBy() |
boolean |
hasValues()
Does the query have a VALUES trailing block?
|
boolean |
isAskType() |
boolean |
isConstructType() |
boolean |
isDescribeType() |
boolean |
isDistinct() |
boolean |
isOrdered() |
boolean |
isQueryResultStar()
Answer whether the query had SELECT/DESCRIBE/CONSTRUCT *
|
boolean |
isReduced() |
boolean |
isSelectType() |
boolean |
isStrict() |
boolean |
isUnknownType() |
void |
output(IndentedWriter out) |
String |
serialize()
Convert the query to a string
|
void |
serialize(IndentedLineBuffer buff)
Format the query into the buffer
|
void |
serialize(IndentedLineBuffer buff,
Syntax outSyntax)
Format the query
|
void |
serialize(IndentedWriter writer)
Format the query
|
void |
serialize(IndentedWriter writer,
Syntax outSyntax)
Format the query
|
void |
serialize(OutputStream out)
Output the query
|
void |
serialize(OutputStream out,
Syntax syntax)
Output the query
|
String |
serialize(Syntax syntax)
Convert the query to a string in the given syntax
|
void |
setConstructTemplate(Template templ)
Set triple patterns for a construct query
|
void |
setDistinct(boolean b) |
void |
setLimit(long limit) |
void |
setOffset(long offset) |
void |
setQueryAskType() |
void |
setQueryConstructType() |
void |
setQueryDescribeType() |
void |
setQueryPattern(Element elt) |
void |
setQueryResultStar(boolean isQueryStar)
Set whether the query had SELECT/DESCRIBE *
Strictly, this just means whether the projection is
|
void |
setQuerySelectType() |
void |
setReduced(boolean b) |
void |
setResultVars()
Fix up when the query has "*" (when SELECT * or DESCRIBE *)
and for a construct query.
|
void |
setStrict(boolean isStrict) |
void |
setSyntax(Syntax syntax) |
void |
setValuesDataBlock(List<Var> variables,
List<Binding> values) |
String |
toString() |
String |
toString(Syntax syntax) |
boolean |
usesGraphURI(String uri)
Test whether the query mentions a URI in forming the default graph (FROM clause)
|
boolean |
usesNamedGraphURI(String uri)
Test whether the query mentions a URI for a named graph.
|
void |
visit(QueryVisitor visitor) |
copy, expandPrefixedName, explicitlySetBaseURI, getBaseURI, getPrefix, getPrefixMapping, getResolver, setBaseURI, setBaseURI, setPrefix, setPrefixMapping, setResolver, shortForm, sub, sub, sub, usePrologueFrom
public static final int QueryTypeUnknown
public static final int QueryTypeSelect
public static final int QueryTypeConstruct
public static final int QueryTypeDescribe
public static final int QueryTypeAsk
public static final long NOLIMIT
public static final int ORDER_ASCENDING
public static final int ORDER_DESCENDING
public static final int ORDER_DEFAULT
public static final int ORDER_UNKNOW
public Query()
public Query(Prologue prologue)
public void setQuerySelectType()
public void setQueryConstructType()
public void setQueryDescribeType()
public void setQueryAskType()
public int getQueryType()
public boolean isSelectType()
public boolean isConstructType()
public boolean isDescribeType()
public boolean isAskType()
public boolean isUnknownType()
public Prologue getPrologue()
public void setStrict(boolean isStrict)
public boolean isStrict()
public void setDistinct(boolean b)
public boolean isDistinct()
public void setReduced(boolean b)
public boolean isReduced()
public Syntax getSyntax()
public void setSyntax(Syntax syntax)
syntax
- The syntax to set.public long getLimit()
public void setLimit(long limit)
public boolean hasLimit()
public long getOffset()
public void setOffset(long offset)
public boolean hasOffset()
public boolean hasOrderBy()
public boolean isOrdered()
public void addOrderBy(SortCondition condition)
public void addOrderBy(Expr expr, int direction)
public void addOrderBy(Node var, int direction)
public void addOrderBy(String varName, int direction)
public List<SortCondition> getOrderBy()
public boolean isQueryResultStar()
public void setQueryResultStar(boolean isQueryStar)
isQueryStar
- public void setQueryPattern(Element elt)
public Element getQueryPattern()
public void addGraphURI(String s)
public void addNamedGraphURI(String uri)
public List<String> getGraphURIs()
public boolean usesGraphURI(String uri)
uri
- public List<String> getNamedGraphURIs()
public boolean usesNamedGraphURI(String uri)
uri
- public boolean hasDatasetDescription()
public DatasetDescription getDatasetDescription()
public VarExprList getProject()
public void addProjectVars(Collection<?> vars)
public void addResultVar(String varName)
public void addResultVar(Node v)
public void addResultVar(Expr expr)
public void addResultVar(String varName, Expr expr)
public boolean hasGroupBy()
public boolean hasHaving()
public VarExprList getGroupBy()
public void addGroupBy(String varName)
public void addGroupBy(Node v)
public void addGroupBy(Expr expr)
public void addHavingCondition(Expr expr)
public boolean hasAggregators()
public List<ExprAggregator> getAggregators()
public Expr allocAggregate(Aggregator agg)
public boolean hasValues()
public Template getConstructTemplate()
public void setConstructTemplate(Template templ)
public void addDescribeNode(Node node)
public List<Node> getResultURIs()
public void setResultVars()
public void visit(QueryVisitor visitor)
public Query cloneQuery()
public Query cloneQuery(boolean useRawQuery)
useRawQuery
- Copy from raw query if presentpublic boolean equals(Object other)
public void output(IndentedWriter out)
public String serialize()
public String serialize(Syntax syntax)
syntax
- public void serialize(OutputStream out)
out
- OutputStreampublic void serialize(OutputStream out, Syntax syntax)
out
- OutputStreamsyntax
- Syntax URIpublic void serialize(IndentedLineBuffer buff)
buff
- IndentedLineBufferpublic void serialize(IndentedLineBuffer buff, Syntax outSyntax)
buff
- IndentedLineBuffer in which to place the unparsed queryoutSyntax
- Syntax URIpublic void serialize(IndentedWriter writer)
writer
- IndentedWriterpublic void serialize(IndentedWriter writer, Syntax outSyntax)
writer
- IndentedWriteroutSyntax
- Syntax URILicenced under the Apache License, Version 2.0