@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 protected void describeMismatchSafely(BindingSet item, Description mismatchDescription) { Binding binding = item.getBinding(name); mismatchDescription.appendText("instead it was bound to").appendValue(binding.getValue()); }
public Value getValue(String bindingName) { Binding binding = getBinding(bindingName); if (binding != null) { return binding.getValue(); } return null; }
public Value getValue(String bindingName) { Binding binding = getBinding(bindingName); if (binding != null) { return binding.getValue(); } return null; }
@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 protected boolean matchesSafely(BindingSet item) { Binding binding = item.getBinding(name); if (binding == null) { return false; } return valueMatcher.matches(binding.getValue()); } }
@Override protected void describeMismatchSafely(BindingSet item, Description mismatchDescription) { Binding binding = item.getBinding(name); if (binding == null) { mismatchDescription.appendText("but did not contain such a binding"); return; } mismatchDescription.appendText("instead it was bound to").appendValue(binding.getValue()); }
@Override public Value getValue(String bindingName) { return createBinding(bindingName).getValue(); }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append(" names: "); for (final String name : getBindingNames()) { sb.append("\n [name]: " + name + " --- [value]: " + getBinding(name).getValue().toString()); } return sb.toString(); } }
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; }
private void printBindingSet(StringBuilder message, BindingSet bs) { // message.append(bs); for (String bn: bs.getBindingNames()) { Value v = bs.getBinding(bn).getValue(); message.append(bn).append('=').append(v); if (v instanceof BigdataValue) { message.append(' ').append(((BigdataValue)v).getIV()).append(' '); } } }
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()); }
private void setEnhancementData(Enhancement enhancement, BindingSet result) { if (result.hasBinding("confidence")) { enhancement.setConfidence(Double.parseDouble(result .getBinding("confidence").getValue().stringValue())); } else { enhancement.setConfidence(1.0); // Rupert says this should be the default value... } }
private void printBindingSet(StringBuilder message, BindingSet bs) { // message.append(bs); for (String bn: bs.getBindingNames()) { Value v = bs.getBinding(bn).getValue(); message.append(bn).append('=').append(v); if (v instanceof BigdataValue) { message.append(' ').append(((BigdataValue)v).getIV()).append(' '); } } }
@Override public void meet(final Var var) { final Binding binding = bindings.getBinding(var.getName()); if (binding != null) { if (var.getParentNode() instanceof StatementPattern) { var.setValue(binding.getValue()); var.setName("_const-" + var.getName()); } else { replaceNode(result, var, new ValueConstant(binding.getValue())); } } }
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()); } } }