/** * Localized factory. Only for use when the predicate is a localized node. * * @param e0 The first statement constraint. * @param e1 The constraint predicate. This must be a localized node for MULGARA_IS. * @param e2 The third statement constraint. * @param e3 The fourth (meta) statement constraint. * @return A new ConstraintIs with a localized predicate. */ public static ConstraintIs newLocalConstraintIs( ConstraintElement e0, ConstraintElement e1, ConstraintElement e2, ConstraintElement e3 ) { ConstraintIs ci = new ConstraintIs(e0, e2, e3 != null ? e3 : Variable.FROM); ci.element[1] = e1; return ci; }
/** * Equality is by value. * * @param object The ConstraintIs object to compare to * @return <code>true</code> if object is the same as this. */ public boolean equals(Object object) { if (object == null) return false; if (object == this) return true; // Check that the given object is the correct class if (!object.getClass().equals(this.getClass())) return false; // Check each element. ConstraintIs tmpConstraint = (ConstraintIs) object; return element[0].equals(tmpConstraint.getElement(0)) && element[2].equals(tmpConstraint.getElement(2)) && element[3].equals(tmpConstraint.getElement(3)); }
public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception { ConstraintIs constraint = (ConstraintIs)constraintExpr; return TuplesOperations.assign((Variable)context.localize(constraint.getVariable()), ((LocalNode)context.localize(constraint.getValueNode())).getValue()); } }),
/** * Get all constraints which are variables. This * method now uses the fourth element of the triple. * * @return A set containing all variable constraints. */ public Set<Variable> getVariables() { if (variables == null) { Set<Variable> v = new HashSet<Variable>(); Variable e = getVariable(); if (!e.getName().startsWith("_")) v.add(e); // now check the graph if (element[3] instanceof Variable && !((Variable)element[3]).getName().startsWith("_")) { v.add((Variable)element[3]); } variables = Collections.unmodifiableSet(v); } return variables; }
private ConstraintExpression constrainBindings(Map bindings) throws LocalizeException { List args = new ArrayList(); Iterator i = bindings.entrySet().iterator(); logger.debug("FIXME:localize should be lookup, need to preallocate MULGARA_IS"); while (i.hasNext()) { Map.Entry entry = (Map.Entry)i.next(); args.add(ConstraintIs.newLocalConstraintIs( (Variable)entry.getKey(), new LocalNode(resolverSession.localize(ConstraintIs.MULGARA_IS)), (ValueElement)entry.getValue(), null)); } return new ConstraintConjunction(args); }
protected ConstraintExpression constrainBindings(Map<Variable,Value> bindings) throws TuplesException { List<ConstraintExpression> args = new ArrayList<ConstraintExpression>(); for (Map.Entry<Variable,Value> entry: bindings.entrySet()) { args.add(new ConstraintIs((ConstraintElement) entry.getKey(), (ConstraintElement) entry.getValue())); } return new ConstraintConjunction(args); } }
return new ConstraintIs(e0, e2, e3);