Java Code Examples for org.apache.jena.sparql.engine.binding.BindingFactory#create()

The following examples show how to use org.apache.jena.sparql.engine.binding.BindingFactory#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogUtils.java    From sparql-generate with Apache License 2.0 6 votes vote down vote up
private static ElementData compress(List<Binding> input) {
    ElementData el = new ElementData();

    if (input.size() < 10) {
        input.forEach((b) -> {
            addCompressedToElementData(el, b);
        });
        return el;
    }
    for (int i = 0; i < 5; i++) {
        addCompressedToElementData(el, input.get(i));
    }
    BindingMap binding = BindingFactory.create();
    Node n = NodeFactory.createLiteral("[ " + (input.size() - 10) + " more ]");
    el.getVars().forEach((v) -> binding.add(v, n));
    el.add(binding);
    for (int i = input.size() - 5; i < input.size(); i++) {
        addCompressedToElementData(el, input.get(i));
    }
    return el;
}
 
Example 2
Source File: LogUtils.java    From sparql-generate with Apache License 2.0 6 votes vote down vote up
private static ElementData compress(List<Var> variables, List<Binding> input) {
    ElementData el = new ElementData();
    variables.forEach(el::add);
    if (input.size() < 10) {
        input.forEach((b) -> el.add(compress(variables, b)));
        return el;
    }
    for (int i = 0; i < 5; i++) {
        el.add(compress(variables, input.get(i)));
    }
    BindingMap binding = BindingFactory.create();
    Node n = NodeFactory.createLiteral("[ " + (input.size() - 10) + " more ]");
    variables.forEach((v) -> binding.add(v, n));
    el.add(binding);
    for (int i = input.size() - 5; i < input.size(); i++) {
        el.add(compress(variables, input.get(i)));
    }
    return el;
}
 
Example 3
Source File: QueryIterTripleStarPattern.java    From RDFstarTools with Apache License 2.0 5 votes vote down vote up
protected Binding mapper(Triple r)
{
    final BindingMap results = BindingFactory.create(binding);

    if ( ! insert(r, s, p, o, results, sIsTripleWithVars, oIsTripleWithVars) )
        return null;

    return results;
}
 
Example 4
Source File: LogUtils.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
public static Binding compress(List<Var> variables, Binding input) {
    final BindingMap binding = BindingFactory.create();
    for (Var v : variables) {
        Node n = input.get(v);
        if (n != null) {
            binding.add(v, compress(input.get(v)));
        }
    }
    return binding;
}
 
Example 5
Source File: EvalUtils.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
public static Binding createBinding(QuerySolution sol) {
	final BindingMap binding = BindingFactory.create();
	for (Iterator<String> it = sol.varNames(); it.hasNext();) {
		final String varName = it.next();
		binding.add(VarUtils.allocVar(varName), sol.get(varName).asNode());
	}
	return binding;
}
 
Example 6
Source File: VarUtils.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
public static Binding getBinding(
        final QuerySolution sol) {
    final BindingMap binding = BindingFactory.create();
    for (Iterator<String> it = sol.varNames(); it.hasNext();) {
        String varName = it.next();
        binding.add(allocVar(varName), sol.get(varName).asNode());
    }
    return binding;
}