本文整理了Java中org.apache.jena.query.Query.setQueryResultStar
方法的一些代码示例,展示了Query.setQueryResultStar
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setQueryResultStar
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:setQueryResultStar
[英]Set whether the query had SELECT/DESCRIBE
[中]设置查询是否已选择/描述
代码示例来源:origin: apache/jena
/**
* Add a variable to the select. If the variable is <code>null</code> the
* variables are set to star.
*
* @param var
* The variable to add.
*/
public void addVar(Var var) {
if (var == null) {
query.setQueryResultStar(true);
} else {
query.setQueryResultStar(false);
query.addResultVar(var);
}
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Add a variable to the select. If the variable is <code>null</code> the
* variables are set to star.
*
* @param var
* The variable to add.
*/
public void addVar(Var var) {
if (var == null) {
query.setQueryResultStar(true);
} else {
query.setQueryResultStar(false);
query.addResultVar(var);
}
}
代码示例来源:origin: apache/jena
/**
* Add an Expression as variable to the select.
*
* @param expr
* The expression to add.
* @param var
* The variable to add.
*/
public void addVar(Expr expr, Var var) {
if (expr == null) {
throw new IllegalArgumentException("expr may not be null");
}
if (var == null) {
throw new IllegalArgumentException("var may not be null");
}
query.setQueryResultStar(false);
query.addResultVar(var, expr);
aggHandler.add( expr, var );
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Add an Expression as variable to the select.
*
* @param expr
* The expression to add.
* @param var
* The variable to add.
*/
public void addVar(Expr expr, Var var) {
if (expr == null) {
throw new IllegalArgumentException("expr may not be null");
}
if (var == null) {
throw new IllegalArgumentException("var may not be null");
}
query.setQueryResultStar(false);
query.addResultVar(var, expr);
aggHandler.add( expr, var );
}
代码示例来源:origin: apache/jena
private static Query toQuery(Element pattern) {
Query query = QueryFactory.make() ;
query.setQueryPattern(pattern) ;
query.setQuerySelectType() ;
query.setQueryResultStar(true) ;
return query ;
}
代码示例来源:origin: apache/jena
@Override
public void build() {
if (query.getProject().getVars().isEmpty()) {
query.setQueryResultStar(true);
}
aggHandler.build();
// handle the SELECT * case
query.getProjectVars();
}
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
@Override
public void build() {
if (query.getProject().getVars().isEmpty()) {
query.setQueryResultStar(true);
}
aggHandler.build();
// handle the SELECT * case
query.getProjectVars();
}
}
代码示例来源:origin: apache/jena
protected Query elementToQuery(Element pattern) {
if ( pattern == null )
return null;
Query query = new Query();
query.setQueryPattern(pattern);
query.setQuerySelectType();
query.setQueryResultStar(true);
query.setResultVars();
return query;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query asQuery(Op op, Dialect dialect)
{
Query query = QueryFactory.make() ;
Converter v = new Converter(query, dialect) ;
//OpWalker.walk(op, v) ;
op.visit(v) ;
List<Var> vars = v.projectVars;
query.setQueryResultStar(vars.isEmpty()); // SELECT * unless we are projecting
Iterator<Var> iter = vars.iterator();
for (; iter.hasNext();) {
Var var = iter.next();
if (v.varExpression.containsKey(var))
query.addResultVar(var, v.varExpression.get(var));
else
query.addResultVar(var);
}
ElementGroup eg = v.currentGroup ;
query.setQueryPattern(eg) ;
query.setQuerySelectType() ;
query.setResultVars() ;
return query ;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query wrapAsSubQuery(Query query) {
Element esq = new ElementSubQuery(query);
Query result = new Query();
result.setQuerySelectType();
result.setQueryResultStar(true);
result.setQueryPattern(esq);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
private Iterator<Triple> executeConstructStreaming(Query query) {
if (!query.isConstructType()) {
throw new RuntimeException("CONSTRUCT query expected. Got: ["
+ query.toString() + "]");
}
Query clone = query.cloneQuery();
clone.setQuerySelectType();
//Query selectQuery = QueryUtils.elementToQuery(query.getQueryPattern());
clone.setQueryResultStar(true);
ResultSetCloseable rs = executeCoreSelect(clone);
System.out.println("Executing query as: " + clone);
// insertPrefixesInto(result) ;
Template template = query.getConstructTemplate();
Iterator<Triple> result = new ConstructIterator(template, rs);
return result;
}
代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-cache
public static Element limitElement(Element e, long limit) {
Query subQuery = new Query();
subQuery.setQuerySelectType();
subQuery.setQueryResultStar(true);
subQuery.setQueryPattern(e);
subQuery.setLimit(limit);
Element result = new ElementSubQuery(subQuery);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Element limitElement(Element e, long limit) {
Query subQuery = new Query();
subQuery.setQuerySelectType();
subQuery.setQueryResultStar(true);
subQuery.setQueryPattern(e);
subQuery.setLimit(limit);
Element result = new ElementSubQuery(subQuery);
return result;
}
代码示例来源:origin: apache/jena
@Override
public Iterator<Quad> execConstructQuads() {
checkNotClosed();
if ( ! query.isConstructType() )
throw new QueryExecException("Attempt to get a CONSTRUCT model from a "+labelForQuery(query)+" query") ;
// This causes there to be no PROJECT around the pattern.
// That in turn, exposes the initial bindings.
query.setQueryResultStar(true) ;
startQueryIterator() ;
Template template = query.getConstructTemplate() ;
return TemplateLib.calcQuads(template.getQuads(), queryIterator);
}
代码示例来源:origin: apache/jena
@Override
public Iterator<Triple> execConstructTriples() {
checkNotClosed();
if ( ! query.isConstructType() )
throw new QueryExecException("Attempt to get a CONSTRUCT model from a "+labelForQuery(query)+" query") ;
// This causes there to be no PROJECT around the pattern.
// That in turn, exposes the initial bindings.
query.setQueryResultStar(true) ;
startQueryIterator() ;
Template template = query.getConstructTemplate() ;
return TemplateLib.calcTriples(template.getTriples(), queryIterator);
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Deprecated // Remove once countQuery works as espected
public static long countQueryOld(Query query, QueryExecutionFactory qef) {
Var outputVar = Var.alloc("_c_");
if(query.isConstructType()) {
Element element = query.getQueryPattern();
query = new Query();
query.setQuerySelectType();
query.setQueryResultStar(true);
query.setQueryPattern(element);
}
Query countQuery = QueryFactory.create("Select (Count(*) As ?_c_) { {" + query + "} }", Syntax.syntaxSPARQL_11);
QueryExecution qe = qef.createQueryExecution(countQuery);
ResultSet rs = qe.execSelect();
Binding binding = rs.nextBinding();
Node node = binding.get(outputVar);
Number numeric = (Number)node.getLiteralValue();
long result = numeric.longValue();
return result;
}
代码示例来源:origin: apache/jena
@Override
public void startVisit(Query query) {
newQuery.setSyntax(query.getSyntax());
if (query.explicitlySetBaseURI())
newQuery.setBaseURI(query.getPrologue().getResolver());
newQuery.setQueryResultStar(query.isQueryResultStar());
if (query.hasDatasetDescription()) {
DatasetDescription desc = query.getDatasetDescription();
for (String x : desc.getDefaultGraphURIs())
newQuery.addGraphURI(x);
for (String x : desc.getDefaultGraphURIs())
newQuery.addNamedGraphURI(x);
}
// Aggregators.
newQuery.getAggregators().addAll(query.getAggregators());
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public void startVisit(Query query) {
newQuery.setSyntax(query.getSyntax()) ;
if ( query.explicitlySetBaseURI() )
newQuery.setBaseURI(query.getPrologue().getResolver()) ;
newQuery.setQueryResultStar(query.isQueryResultStar()) ;
if ( query.hasDatasetDescription() ) {
DatasetDescription desc = query.getDatasetDescription() ;
for (String x : desc.getDefaultGraphURIs())
newQuery.addGraphURI(x) ;
for (String x : desc.getDefaultGraphURIs())
newQuery.addNamedGraphURI(x) ;
}
// Aggregators.
newQuery.getAggregators().addAll(query.getAggregators()) ;
}
代码示例来源:origin: apache/jena
/**
* Add all the variables from the select handler variable.
*
* @param selectHandler
* The select handler to copy the variables from.
*/
public void addAll(SelectHandler selectHandler) {
setReduced(selectHandler.query.isReduced());
setDistinct(selectHandler.query.isDistinct());
query.setQueryResultStar(selectHandler.query.isQueryResultStar());
VarExprList shProjectVars = selectHandler.query.getProject();
VarExprList qProjectVars = query.getProject();
for (Var var : shProjectVars.getVars()) {
// make sure there are no duplicates
if (!qProjectVars.contains(var)) {
qProjectVars.add(var, shProjectVars.getExpr(var));
}
}
aggHandler.addAll( selectHandler.aggHandler );
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Add all the variables from the select handler variable.
*
* @param selectHandler
* The select handler to copy the variables from.
*/
public void addAll(SelectHandler selectHandler) {
setReduced(selectHandler.query.isReduced());
setDistinct(selectHandler.query.isDistinct());
query.setQueryResultStar(selectHandler.query.isQueryResultStar());
VarExprList shProjectVars = selectHandler.query.getProject();
VarExprList qProjectVars = query.getProject();
for (Var var : shProjectVars.getVars()) {
// make sure there are no duplicates
if (!qProjectVars.contains(var)) {
qProjectVars.add(var, shProjectVars.getExpr(var));
}
}
aggHandler.addAll( selectHandler.aggHandler );
}
内容来源于网络,如有侵权,请联系作者删除!