/** * Get a constraint element by index. * * @param index The constraint element to retrieve, from 0 to 3. * @return The constraint element referred to by index. */ public ConstraintElement getElement(int index) { return constraint.getElement(index); }
/** * Get a constraint element by index. * * @param index The constraint element to retrieve, from 0 to 3. * @return The constraint element referred to by index. */ public ConstraintElement getElement(int index) { return transConstraint.getElement(index); }
/** * Get a constraint element by index. * * @param index The constraint element to retrieve, from 0 to 3. * @return The constraint element referred to by index. */ public ConstraintElement getElement(int index) { return unanchoredConstraint.getElement(index); }
/** * Get a constraint element by index. * * @param index The constraint element to retrieve, from 0 to 3. * @return The constraint element referred to by index. */ public ConstraintElement getElement(int index) { return unanchoredConstraint.getElement(index); }
public void renameVariables(Constraint constraint) { variables[0] = (Variable)constraint.getElement(0); }
public Constraint rewrite(ConstraintElement newModel, Constraint constraint) throws Exception { return new ConstraintImpl(constraint.getElement(0), constraint.getElement(1), constraint.getElement(2), newModel); } }),
/** * Constructor. * * @param trans The constraint defining the transitive predicate. * @throws QueryException If trans is not of the form {$var <uri> $var} */ public SingleTransitiveConstraint(Constraint trans) throws QueryException { // Validate parameters if (trans == null) { throw new IllegalArgumentException("null trans parameter"); } // Check if this constraint is anchored i.e. starting from a fixed subject // or object. if (!trans.getElement(0).getClass().equals(trans.getElement(2).getClass()) && ((trans.getElement(0) instanceof ValueElement) || (trans.getElement(2) instanceof ValueElement))) { anchored = true; } else { anchored = false; } // Initialize fields this.transConstraint = trans; }
/** * Equality is by value. * * @param object The instance to compare to * @return <code>true</code> iff objects are compatible and contain the same data. */ public boolean equals(Object object) { // FIXME: Refactor to exploit equals() method on ConstraintExpression. if (object == null) return false; if (object == this) return true; boolean returnValue = false; // Check that the given object is the correct class if so check each element. if (object.getClass().equals(this.getClass())) { Constraint tmpConstraint = (Constraint) object; returnValue = (element[0].equals(tmpConstraint.getElement(0)) && element[1].equals(tmpConstraint.getElement(1)) && element[2].equals(tmpConstraint.getElement(2)) && element[3].equals(tmpConstraint.getElement(3))); } return returnValue; }
/** * Constructor. * * @param walk1 The constraint defining the anchored constraint. * @param walk2 The constraint defining the unanchored constraint. * @throws QueryException If walk1 and walk2 are not of the form * {$var <uri> $var} */ public WalkConstraint(Constraint walk1, Constraint walk2) throws QueryException { // Validate parameters if (walk1 == null || walk2 == null) { throw new IllegalArgumentException("Null constraints parameters"); } if (!((walk1.getElement(1) instanceof ValueElement) || (walk1.getElement(1) instanceof Variable))) { throw new QueryException("Walk statement must have a predicate."); } if (!((walk2.getElement(1) instanceof ValueElement) || (walk2.getElement(1) instanceof Variable))) { throw new QueryException("Walk statement must have a predicate."); } if (!(walk1.getElement(1).equals(walk2.getElement(1)))) { throw new QueryException("Both predicates in the walk statement must be" + "equal."); } // Initialize fields anchoredConstraint = walk1; unanchoredConstraint = walk2; }
public Constraint localize(QueryEvaluationContext context, Constraint constraint) throws Exception { return new ConstraintImpl(context.localize(constraint.getElement(0)), context.localize(constraint.getElement(1)), context.localize(constraint.getElement(2)), context.localize(constraint.getElement(3))); } }),
/** * Renames the variables which label the tuples if they have the "magic" names * such as "Subject", "Predicate", "Object" and "Meta". * * @param constraint PARAMETER TO DO */ public void renameVariables(Constraint constraint) { if (variables != null) { loop:for (int i = 0; i < variables.length; ++i) { Variable v = variables[i]; for (int j = 0; j < 4; ++j) { // v will be a reference to one of the objects in Graph.VARIABLES[]. if (v.equals(StatementStore.VARIABLES[j])) { // The array obtained from getVariables() is modifiable. variables[i] = (Variable) constraint.getElement(j); continue loop; } } throw new Error("Unexpected variable: " + v); } } }
List variableList = new ArrayList(3); for (int i = 0; i < 3; i++) { if (constraint.getElement(i) instanceof Variable) { temp[length++] = i; variableList.add(constraint.getElement(i));
public static Constraint replace(Map<Variable,ValueElement> bindings, Constraint constraint) throws QueryException { return ConstraintFactory.newConstraint(replace(bindings, constraint.getElement(0)), replace(bindings, constraint.getElement(1)), replace(bindings, constraint.getElement(2)), replace(bindings, constraint.getModel())); }
int prefixIndex = 0; if (constraint.getElement(0) instanceof LocalNode) { long subject = ((LocalNode) constraint.getElement(0)).getValue(); if (subject != statements.getSubject()) { continue; if (constraint.getElement(1) instanceof LocalNode) { long predicate = ((LocalNode) constraint.getElement(1)).getValue(); if (predicate != statements.getPredicate()) { continue; if (constraint.getElement(2) instanceof LocalNode) { long object = ((LocalNode) constraint.getElement(2)).getValue(); if (object != statements.getObject()) { continue;
store = newStore; subject = toGraphTuplesIndex(constraint.getElement(0)); predicate = toGraphTuplesIndex(constraint.getElement(1)); object = toGraphTuplesIndex(constraint.getElement(2)); metanode = toGraphTuplesIndex(constraint.getModel()); if (constraint.getElement(index) instanceof Variable) { Variable var = (Variable) constraint.getElement(index); if (!var.equals(Variable.FROM)) {
assert constraint.getElement(3) instanceof Variable;
if (!(predConstraint.getAnchoredConstraint().getElement(1) instanceof ValueElement)) { throw new QueryException("Predicate in walk function, " + predConstraint.getAnchoredConstraint().getElement(1) + ", currently must be bound to a value."); if (((predConstraint.getAnchoredConstraint().getElement(0) instanceof Variable) && !(predConstraint.getAnchoredConstraint().getElement(2) instanceof ValueElement)) || ((predConstraint.getAnchoredConstraint().getElement(0) instanceof ValueElement) && !(predConstraint.getAnchoredConstraint().getElement(2) instanceof Variable))) { throw new QueryException( "The subject: " + predConstraint.getAnchoredConstraint().getElement(0) + " and the object: " + predConstraint.getAnchoredConstraint().getElement(2) + " are invalid, one must be a variable and the other a fixed value" + " around a predicate."); if (!(predConstraint.getUnanchoredConstraint().getElement(1) instanceof ValueElement)) { throw new QueryException("Predicate in transitive function, " + predConstraint.getElement(1) + ", currently must be bound to a value."); if (!((predConstraint.getUnanchoredConstraint().getElement(0) instanceof Variable) && (predConstraint.getUnanchoredConstraint().getElement(2) instanceof Variable))) { throw new QueryException( "The subject: " + predConstraint.getUnanchoredConstraint().getElement(0) + " and the object: " + predConstraint.getUnanchoredConstraint().getElement(2) + " are invalid, both must be variables."); if (anchoredConstraint.getElement(0) instanceof Variable) { ConstraintElement element = anchoredConstraint.getElement(2);
if (!(constraint.getAnchoredConstraint().getElement(1) instanceof ValueElement)) { throw new QueryException("Predicate in transitive function, " + constraint.getAnchoredConstraint().getElement(1) + ", currently must be bound to a value."); if (((constraint.getAnchoredConstraint().getElement(0) instanceof Variable) && !(constraint.getAnchoredConstraint().getElement(2) instanceof ValueElement)) || ((constraint.getAnchoredConstraint().getElement(0) instanceof ValueElement) && !(constraint.getAnchoredConstraint().getElement(2) instanceof Variable))) { throw new QueryException( "The subject: " + constraint.getAnchoredConstraint().getElement(0) + " and the object: " + constraint.getAnchoredConstraint().getElement(2) + " are invalid, one must be a variable and the other a fixed value" + " around a predicate."); if (!(constraint.getUnanchoredConstraint().getElement(1) instanceof ValueElement)) { throw new QueryException("Predicate in transitive function, " + constraint.getElement(1) + ", currently must be bound to a value."); if (!((constraint.getUnanchoredConstraint().getElement(0) instanceof Variable) && (constraint.getUnanchoredConstraint().getElement(2) instanceof Variable))) { throw new QueryException( "The subject: " + constraint.getUnanchoredConstraint().getElement(0) + " and the object: " + constraint.getUnanchoredConstraint().getElement(2) + " are invalid, both must be variables."); Variable subjectVariable = (Variable) unanchoredConstraint.getElement(0); Variable objectVariable = (Variable) unanchoredConstraint.getElement(2);
if (predConstraint.getElement(0) instanceof Variable) { value = new Long(session.lookup((Value)predConstraint.getElement(2))); variable = (Variable) predConstraint.getElement(0); predConstraint.getElement(1), tmpVariable, predConstraint.getModel()); } else { value = new Long(session.lookup((Value)predConstraint.getElement(0))); variable = (Variable)predConstraint.getElement(2); predConstraint.getElement(1), variable, predConstraint.getElement(3));
Variable subjectVariable = (Variable) predConstraint.getElement(0); Variable objectVariable = (Variable) predConstraint.getElement(2);