Search in sources :

Example 1 with Binding

use of com.hp.hpl.jena.sparql.engine.binding.Binding in project stanbol by apache.

the class CreateURI method execEvaluated.

@Override
public QueryIterator execEvaluated(Binding binding, PropFuncArg argumentSubject, Node predicate, PropFuncArg argumentObject, ExecutionContext execCxt) {
    Binding b = null;
    if (argumentObject.getArg().isLiteral()) {
        Node ref = argumentSubject.getArg();
        if (ref.isVariable()) {
            String argumentString = argumentObject.getArg().toString().replace("\"", "");
            //STANBOL-621: Binding1 has no longer a public constructor
            //b = new Binding1(binding, Var.alloc(ref), NodeFactory.createURI(argumentString));
            b = BindingFactory.binding(binding, Var.alloc(ref), NodeFactory.createURI(argumentString));
        }
    }
    if (b == null) {
        b = binding;
    }
    return IterLib.result(b, execCxt);
}
Also used : Binding(com.hp.hpl.jena.sparql.engine.binding.Binding) Node(com.hp.hpl.jena.graph.Node)

Example 2 with Binding

use of com.hp.hpl.jena.sparql.engine.binding.Binding in project stanbol by apache.

the class RdfIndexingSource method debug.

public void debug() {
    String entityVar = "s";
    String fieldVar = "p";
    String valueVar = "o";
    StringBuilder qb = new StringBuilder();
    qb.append(String.format("SELECT ?%s ?%s ?%s \n", entityVar, fieldVar, //for the select
    valueVar));
    qb.append("{ \n");
    qb.append(String.format("    ?%s ?%s ?%s . \n", entityVar, fieldVar, //for the where
    valueVar));
    qb.append("} \n");
    log.debug("EntityDataIterator Query: \n" + qb.toString());
    Query q = QueryFactory.create(qb.toString(), Syntax.syntaxARQ);
    ResultSet rs = QueryExecutionFactory.create(q, indexingDataset.toDataset()).execSelect();
    Var s = Var.alloc(entityVar);
    Var p = Var.alloc(fieldVar);
    Var o = Var.alloc(valueVar);
    while (rs.hasNext()) {
        Binding b = rs.nextBinding();
        log.debug("{} {} {}", new Object[] { b.get(s), b.get(p), b.get(o) });
    }
}
Also used : Binding(com.hp.hpl.jena.sparql.engine.binding.Binding) Query(com.hp.hpl.jena.query.Query) Var(com.hp.hpl.jena.sparql.core.Var) ResultSet(com.hp.hpl.jena.query.ResultSet)

Aggregations

Binding (com.hp.hpl.jena.sparql.engine.binding.Binding)2 Node (com.hp.hpl.jena.graph.Node)1 Query (com.hp.hpl.jena.query.Query)1 ResultSet (com.hp.hpl.jena.query.ResultSet)1 Var (com.hp.hpl.jena.sparql.core.Var)1