本文整理了Java中com.hp.hpl.jena.query.Query.getResultVars
方法的一些代码示例,展示了Query.getResultVars
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getResultVars
方法的具体详情如下:
包路径:com.hp.hpl.jena.query.Query
类名称:Query
方法名:getResultVars
[英]Return a list of the variables requested (SELECT)
[中]返回所请求变量的列表(选择)
代码示例来源:origin: Quetzal-RDF/quetzal
public List<String> getResultVars() {
return query.getResultVars();
}
public void addResultVar(String var) {
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
@Override
public void visitDescribeResultForm(Query query)
{
x ^= query.getResultVars().hashCode() ;
x ^= query.getResultURIs().hashCode() ;
}
代码示例来源:origin: com.hp.hpl.jena/arq
public void visitDescribeResultForm(Query query)
{
x ^= query.getResultVars().hashCode() ;
x ^= query.getResultURIs().hashCode() ;
}
代码示例来源:origin: fr.inria.eventcloud/eventcloud-core
public synchronized Set<Var> getResultVars() {
if (this.resultVars == null) {
this.resultVars = new HashSet<Var>();
for (String varName : QueryFactory.create(this.sparqlQuery)
.getResultVars()) {
this.resultVars.add(Var.alloc(varName));
}
}
return this.resultVars;
}
代码示例来源:origin: com.hp.hpl.jena/arq
/** Execute a query, expecting the result to be one row, one column. Return that one RDFNode */
public static RDFNode getExactlyOne(String qs, Dataset ds)
{
Query q = QueryFactory.create(qs) ;
if ( q.getResultVars().size() != 1 )
throw new ARQException("getExactlyOne: Must have exactly one result columns") ;
String varname = q.getResultVars().get(0) ;
QueryExecution qExec = QueryExecutionFactory.create(q, ds);
return getExactlyOne(qExec, varname) ;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** Execute a query, expecting the result to be one row, one column. Return that one RDFNode */
public static RDFNode getExactlyOne(String qs, Dataset ds)
{
Query q = QueryFactory.create(qs) ;
if ( q.getResultVars().size() != 1 )
throw new ARQException("getExactlyOne: Must have exactly one result columns") ;
String varname = q.getResultVars().get(0) ;
QueryExecution qExec = QueryExecutionFactory.create(q, ds);
return getExactlyOne(qExec, varname) ;
}
代码示例来源:origin: org.semweb4j/rdf2go.impl.jena
public QueryResultTableImpl(Query query, Dataset jenaDataset) throws ModelRuntimeException {
if(!query.isSelectType()) {
throw new ModelRuntimeException("The given query is not a SELECT query");
}
// else
this.varnames = new ArrayList<String>();
for(Object o : query.getResultVars()) {
this.varnames.add((String)o);
}
this.qexec = QueryExecutionFactory.create(query, jenaDataset);
}
代码示例来源:origin: org.semweb4j/rdf2go.impl.jena
public QueryResultTableImpl(Query query, Model jenaModel) throws ModelRuntimeException {
if(!query.isSelectType()) {
throw new ModelRuntimeException("The given query is not a SELECT query");
}
// else
this.varnames = new ArrayList<String>();
for(Object o : query.getResultVars()) {
this.varnames.add((String)o);
}
this.qexec = QueryExecutionFactory.create(query, jenaModel);
}
代码示例来源:origin: Quetzal-RDF/quetzal
protected static Element instantiateBody(Query cq, List<? extends Expr> args ) {
Map<Var, Node> oldVar2NewValue = new HashMap<Var, Node>();
List<String> resultVars = cq.getResultVars();
Set<String> alreadySeenVars = new HashSet<String>();
assert resultVars.size() == args.size() : resultVars+", " +args ;
for (int i=0;i<resultVars.size();i++) {
String old = resultVars.get(i);
if (alreadySeenVars.add(old)) {
Expr newE = args.get(i);
Node newN = toNode(newE);
oldVar2NewValue.put(Var.alloc(old), newN);
}
}
VariableSubstitutionElementVisitor visitor = new VariableSubstitutionElementVisitor(oldVar2NewValue);
cq.getQueryPattern().visit(visitor);
Element result = visitor.getResult();
return result;
}
代码示例来源:origin: org.semweb4j/rdf2go.impl.jena
public QueryResultTableImpl(QueryExecution qe) {
if(!qe.getQuery().isSelectType()) {
throw new ModelRuntimeException("The given query execution is not a SELECT query");
}
this.varnames = new ArrayList<String>();
for(Object o : qe.getQuery().getResultVars()) {
this.varnames.add((String)o);
}
this.qexec = qe;
}
代码示例来源:origin: com.hp.hpl.jena/arq
public void visitDescribeResultForm(Query query1)
{
check("Not both DESCRIBE queries", query2.isDescribeType()) ;
check("Result variables",
query1.getResultVars(), query2.getResultVars() ) ;
check("Result URIs",
query1.getResultURIs(), query2.getResultURIs() ) ;
}
代码示例来源:origin: com.hp.hpl.jena/arq
private ResultSet asResultSet(QueryIterator qIter)
{
Model model = null ;
if ( dataset != null )
model = dataset.getDefaultModel() ;
else
model = ModelFactory.createDefaultModel() ;
ResultSetStream rStream = new ResultSetStream(query.getResultVars(), model, qIter) ;
return rStream ;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
@Override
public void visitDescribeResultForm(Query query1)
{
check("Not both DESCRIBE queries", query2.isDescribeType()) ;
check("Result variables",
query1.getResultVars(), query2.getResultVars() ) ;
check("Result URIs",
query1.getResultURIs(), query2.getResultURIs() ) ;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
private ResultSet asResultSet(QueryIterator qIter)
{
Model model = null ;
if ( dataset != null )
model = dataset.getDefaultModel() ;
else
model = ModelFactory.createDefaultModel() ;
ResultSetStream rStream = new ResultSetStream(query.getResultVars(), model, qIter) ;
return rStream ;
}
代码示例来源:origin: com.hp.hpl.jena/arq
public void visitDescribeResultForm(Query query)
{
out.print("DESCRIBE ") ;
if ( query.isQueryResultStar() )
out.print("*") ;
else
{
appendVarList(query, out, query.getResultVars()) ;
if ( query.getResultVars().size() > 0 &&
query.getResultURIs().size() > 0 )
out.print(" ") ;
appendURIList(query, out, query.getResultURIs()) ;
}
out.newline() ;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
@Override
public void visitDescribeResultForm(Query query)
{
out.print("DESCRIBE ") ;
if ( query.isQueryResultStar() )
out.print("*") ;
else
{
appendVarList(query, out, query.getResultVars()) ;
if ( query.getResultVars().size() > 0 &&
query.getResultURIs().size() > 0 )
out.print(" ") ;
appendURIList(query, out, query.getResultURIs()) ;
}
out.newline() ;
}
代码示例来源:origin: fr.lirmm.graphik/graal-io-sparql
private void execute(String queryString) {
this.prefixes = new LinkedList<Prefix>();
List<Term> ans = new LinkedList<Term>();
Query sparql = QueryFactory.create(queryString);
for (Map.Entry<String, String> e : sparql.getPrefixMapping().getNsPrefixMap().entrySet()) {
this.prefixes.add(new Prefix(e.getKey(), e.getValue()));
}
if (sparql.isSelectType()) {
for (String v : sparql.getResultVars()) {
ans.add(DefaultTermFactory.instance().createVariable(v));
}
}
ElementVisitorImpl visitor = new ElementVisitorImpl(DefaultAtomSetFactory.instance().create());
sparql.getQueryPattern().visit(visitor);
// check if answer variables appear in the query body
Set<Variable> bodyVars = visitor.getAtomSet().getVariables();
for(Term t : ans) {
if(t.isVariable() && !bodyVars.contains(t)) {
throw new ParseError("The variable ["+ t +"] of the answer list does not appear in the query body.");
}
}
this.query = DefaultConjunctiveQueryFactory.instance().create(visitor.getAtomSet(), ans);
}
代码示例来源:origin: com.github.ansell.pellet/pellet-query
return parse( triples, sparql.getResultVars(), kb, sparql.isDistinct() );
代码示例来源:origin: Quetzal-RDF/quetzal
/**
* returns all variables mentioned in a query
* @param query
* @return
*/
public static Set<Var> getAllVariables(Query query) {
Set<Var> vars= getAllVariables(query.getQueryPattern());
if (query.hasGroupBy() && query.getGroupBy()!=null && query.getGroupBy().getExprs()!=null) {
for (Map.Entry<Var, Expr> e: query.getGroupBy().getExprs().entrySet()) {
vars.add(e.getKey());
ExprVars.varsMentioned(vars, e.getValue());
}
}
if (query.hasHaving() && query.getHavingExprs()!=null) {
for (Expr e: query.getHavingExprs()) {
ExprVars.varsMentioned(vars, e);
}
}
if (query.hasAggregators() && query.getAggregators()!=null) {
for (ExprAggregator e: query.getAggregators()) {
ExprVars.varsMentioned(vars, e);
}
}
for (String v: query.getResultVars()) {
vars.add(Var.alloc(v));
}
return vars;
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
for ( String varName : query.getResultVars() )
内容来源于网络,如有侵权,请联系作者删除!