/** * Adds a binding to the binding set. * * @param binding * The binding to add to the binding set. */ public void addBinding(Binding binding) { bindings.put(binding.getName(), binding); }
/** * Adds a binding to the solution. * * @param binding * The binding to add to the solution. */ public void addBinding(Binding binding) { bindings.put(binding.getName(), binding); }
/** * Return an ordered collection of the distinct variable names used in the * given caller's solution set. * * @param bindingSets * The solution set. * * @return The distinct, ordered collection of variables used. */ protected LinkedHashSet<String> getDistinctVars(final BindingSet[] bindingSets) { final LinkedHashSet<String> vars = new LinkedHashSet<String>(); for (BindingSet bindingSet : bindingSets) { for (Binding binding : bindingSet) { vars.add(binding.getName()); } } return vars; }
/** * Return an ordered collection of the distinct variable names used in the * given caller's solution set. * * @param bindingSets * The solution set. * * @return The distinct, ordered collection of variables used. */ protected LinkedHashSet<String> getDistinctVars(final BindingSet[] bindingSets) { final LinkedHashSet<String> vars = new LinkedHashSet<String>(); for (BindingSet bindingSet : bindingSets) { for (Binding binding : bindingSet) { vars.add(binding.getName()); } } return vars; }
@Override public final int hashCode() { int hashCode = 0; for (Binding binding : this) { hashCode ^= binding.getName().hashCode() ^ binding.getValue().hashCode(); } return hashCode; }
@Override public boolean equals(Object o) { if (o instanceof Binding) { Binding other = (Binding)o; return name.equals(other.getName()) && value.equals(other.getValue()); } return false; }
@Override public boolean equals(Object o) { if (o instanceof Binding) { Binding other = (Binding)o; return name.equals(other.getName()) && value.equals(other.getValue()); } return false; }
public JSONObject toJSON(final BindingSet solution, final Long expirationTime) throws JSONException { JSONObject j = new JSONObject(); JSONObject solutionObj = new JSONObject(); for (Binding b : solution) { solutionObj.put(b.getName(), toJSON(b.getValue())); } j.put("solution", solutionObj); j.put("expirationTime", expirationTime); return j; }
public JSONObject toJSON(final BindingSet solution, final Long expirationTime) throws JSONException { JSONObject j = new JSONObject(); JSONObject solutionObj = new JSONObject(); for (Binding b : solution) { solutionObj.put(b.getName(), toJSON(b.getValue())); } j.put("solution", solutionObj); j.put("expirationTime", expirationTime); return j; }
public JSONObject toJSON(final BindingSet bs) throws JSONException { JSONObject j = new JSONObject(); for (Binding b : bs) { j.put(b.getName(), toJSON(b.getValue())); } return j; }
/** * Adds a new binding to the binding set. The binding's name must not already * be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
/** * Adds a new binding to the binding set. The binding's name must not already * be part of this binding set. * * @param binding * The binding to add this this BindingSet. */ public void addBinding(Binding binding) { addBinding(binding.getName(), binding.getValue()); }
public void setBinding(Binding binding) { setBinding(binding.getName(), binding.getValue()); }
public void setBinding(Binding binding) { setBinding(binding.getName(), binding.getValue()); }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (other instanceof BindingSet) { int otherSize = 0; // Compare other's bindings to own for (Binding binding : (BindingSet)other) { Value ownValue = getValue(binding.getName()); if (!binding.getValue().equals(ownValue)) { // Unequal bindings for this name return false; } otherSize++; } // All bindings have been matched, sets are equal if this solution // doesn't have any additional bindings. return otherSize == bindings.size(); } return false; }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || !(other instanceof BindingSet)) { return false; } BindingSet that = (BindingSet)other; if (this.size() != that.size()) { return false; } // Compare other's bindings to own for (Binding binding : that) { Value ownValue = getValue(binding.getName()); if (!binding.getValue().equals(ownValue)) { // Unequal bindings for this name return false; } } return true; }
private static void addBindings(Resource subj, Resource opResource, ParsedOperation parsedOp, Operation op, TripleSource tripleSource, SpinParser parser) throws OpenRDFException { if (!parser.isThisUnbound(opResource, tripleSource)) { op.setBinding(THIS_VAR, subj); } if (parsedOp instanceof ParsedTemplate) { for (Binding b : ((ParsedTemplate)parsedOp).getBindings()) { op.setBinding(b.getName(), b.getValue()); } } }
@Override protected BindingSet convert(BindingSet bindingSet) { MapBindingSet result = new MapBindingSet(bindingSet.size()); for (Binding binding : bindingSet) { String name = binding.getName(); Value value = binding.getValue(); if (value instanceof URI) { value = new AURI(name, (URI)value, node); } else if (value instanceof BNode) { value = new ABNode(name, (BNode)value, node); } binding = new BindingImpl(name, value); result.addBinding(binding); } return result; } }
@Override public void write(final Kryo kryo, final Output output, final VisibilityBindingSet visBindingSet) { output.writeString(visBindingSet.getVisibility()); // write the number count for the reader. output.writeInt(visBindingSet.size()); for (final Binding binding : visBindingSet) { output.writeString(binding.getName()); final RyaType ryaValue = RdfToRyaConversions.convertValue(binding.getValue()); final String valueString = ryaValue.getData(); final URI type = ryaValue.getDataType(); output.writeString(valueString); output.writeString(type.toString()); } }
public void execute(RepositoryConnection con) throws RepositoryException { try { Update preparedUpdate = con.prepareUpdate(QueryLanguage.SPARQL, getUpdateString(), getBaseURI()); preparedUpdate.setIncludeInferred(isIncludeInferred()); preparedUpdate.setDataset(getDataset()); if (getBindings() != null) { for (Binding binding : getBindings()) { preparedUpdate.setBinding(binding.getName(), binding.getValue()); } } preparedUpdate.execute(); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (UpdateExecutionException e) { throw new RepositoryException(e); } }