org.apache.jena.sparql.engine.binding.BindingHashMap Java Examples
The following examples show how to use
org.apache.jena.sparql.engine.binding.BindingHashMap.
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: QueryPatternNormalizer.java From sparql-generate with Apache License 2.0 | 6 votes |
@Override public void visit(ElementData el) { final NodeExprNormalizer nenzer = new NodeExprNormalizer(); final ElementData nzed = new ElementData(); final List<Var> vars = el.getVars(); vars.forEach((v) -> { nzed.add(v); }); el.getRows().forEach((b) -> { final BindingHashMap binding = new BindingHashMap(); vars.forEach((v) -> { final Node n = b.get(v); if (n != null) { n.visitWith(nenzer); binding.add(v, nenzer.getResult()); } }); nzed.add(binding); }); endVisit(nzed, nenzer); }
Example #2
Source File: SelectPlan.java From sparql-generate with Apache License 2.0 | 6 votes |
private ElementData mergeValues(final ElementData qData, final List<Var> variables, final List<Binding> values) { if (values.isEmpty()) { return qData; } List<Var> vars = qData.getVars(); if (!Collections.disjoint(vars, variables)) { throw new SPARQLExtException("Variables " + vars.retainAll(variables) + "were already bound."); } ElementData data = new ElementData(); qData.getVars().forEach(data::add); variables.forEach(data::add); qData.getRows().forEach((qbinding) -> { values.forEach((binding) -> { BindingHashMap newb = new BindingHashMap(qbinding); variables.forEach((v) -> newb.add(v, binding.get(v))); data.add(newb); }); }); return data; }
Example #3
Source File: QueryExecutor.java From sparql-generate with Apache License 2.0 | 6 votes |
private List<Binding> getNewValues(String queryName, SPARQLExtQuery query, List<Var> signature, List<List<Node>> callParameters) { final int size = signature.size(); final List<Binding> bindings = new ArrayList<>(); for (List<Node> callParams : callParameters) { if (callParams.size() != size) { throw new SPARQLExtException("Query " + queryName + " called with " + callParams.size() + " parameters but accepts only " + size); } final BindingHashMap b = new BindingHashMap(); for (int i = 0; i < size; i++) { if(callParams.get(i) != null) { b.add(signature.get(i), callParams.get(i)); } } bindings.add(b); } return bindings; }
Example #4
Source File: JenaUtil.java From shacl with Apache License 2.0 | 6 votes |
/** * Turns a QuerySolution into a Binding. * @param map the input QuerySolution * @return a Binding or null if the input is null */ public static Binding asBinding(final QuerySolution map) { if(map != null) { BindingHashMap result = new BindingHashMap(); Iterator<String> varNames = map.varNames(); while(varNames.hasNext()) { String varName = varNames.next(); RDFNode node = map.get(varName); if(node != null) { result.add(Var.alloc(varName), node.asNode()); } } return result; } else { return null; } }
Example #5
Source File: CSVParser.java From tarql with BSD 2-Clause "Simplified" License | 5 votes |
private Binding toBinding(String[] row) { BindingHashMap result = new BindingHashMap(); for (int i = 0; i < row.length; i++) { if (isUnboundValue(row[i])) continue; result.add(getVar(i), NodeFactory.createLiteral(sanitizeString(row[i]))); } // Add current row number as ?ROWNUM result.add(TarqlQuery.ROWNUM, NodeFactory.createLiteral( Integer.toString(rownum), XSDDatatype.XSDinteger)); return result; }
Example #6
Source File: Helpers.java From tarql with BSD 2-Clause "Simplified" License | 5 votes |
public static Binding binding(List<Var> header, String... values) { if (header.size() != values.length) { throw new IllegalArgumentException( "header and values must have same length: " + header + ", " + Arrays.toString(values)); } BindingHashMap result = new BindingHashMap(); for (int i = 0; i < header.size(); i++) { result.add(header.get(i), NodeFactoryExtra.parseNode(values[i])); } return result; }
Example #7
Source File: Helpers.java From tarql with BSD 2-Clause "Simplified" License | 5 votes |
public static Binding removePseudoVars(Binding binding) { BindingHashMap result = new BindingHashMap(); Iterator<Var> it = binding.vars(); while (it.hasNext()) { Var var = it.next(); if (var.equals(TarqlQuery.ROWNUM)) continue; result.add(var, binding.get(var)); } return result; }