/** * @inheritDoc */ @Override public void meet(CompareAll theOp) throws Exception { mBuffer.append("("); theOp.getArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" all "); mBuffer.append("("); mBuffer.append(renderTupleExpr(theOp.getSubQuery())); mBuffer.append(")"); mBuffer.append(")"); }
public CompareAll(ValueExpr valueExpr, TupleExpr subQuery, CompareOp operator) { super(valueExpr, subQuery); setOperator(operator); }
@Override public CompareAll visit(ASTCompareAll node, Object data) throws VisitorException { ValueExpr valueExpr = (ValueExpr)node.getLeftOperand().jjtAccept(this, null); TupleExpr tupleExpr = (TupleExpr)node.getRightOperand().jjtAccept(this, null); CompareOp op = node.getOperator().getValue(); return new CompareAll(valueExpr, tupleExpr, op); }
@Override public boolean equals(Object other) { if (other instanceof CompareAll && super.equals(other)) { CompareAll o = (CompareAll)other; return operator.equals(o.getOperator()); } return false; }
} else if (COMPARE_OPS.containsKey(op)) { if (expr.getArg(1) instanceof SubQueryExpression<?>) { return new CompareAll(toValue(expr.getArg(0), md), toTuple(expr.getArg(1), md), COMPARE_OPS.get(op)); } else { return new Compare(toValue(expr.getArg(0), md), toValue(expr.getArg(1), md), COMPARE_OPS.get(op));
@Override public void meet(CompareAll node) { handleType(SeRQO.COMPAREALL); handleLiteral(SeRQO.OPERATOR, node.getOperator().name()); super.meet(node); }
/** * @inheritDoc */ @Override public void meet(CompareAll theOp) throws Exception { mBuffer.append("("); theOp.getArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" all "); mBuffer.append("("); // TODO: query render this theOp.getSubQuery().visit(this); mBuffer.append(")"); mBuffer.append(")"); }
}else if (COMPARE_OPS.containsKey(op)){ if (expr.getArg(1) instanceof SubQueryExpression<?>){ return new CompareAll(toValue(expr.getArg(0), md), toTuple(expr.getArg(1), md), COMPARE_OPS.get(op)); }else{ return new Compare(toValue(expr.getArg(0), md), toValue(expr.getArg(1), md), COMPARE_OPS.get(op));
@Override public void meet(CompareAll node) { if (predicate.equals(SeRQO.OPERATOR)) { Literal lit = (Literal) object; node.setOperator(CompareOp.valueOf(lit.getLabel())); } else { super.meet(node); } }
public Value evaluate(CompareAll node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftValue = evaluate(node.getArg(), bindings); // Result is true until a mismatch has been found boolean result = true; // Use first binding name from tuple expr to compare values String bindingName = node.getSubQuery().getBindingNames().iterator().next(); CloseableIteration<BindingSet, QueryEvaluationException> iter = evaluate(node.getSubQuery(), bindings); try { while (result == true && iter.hasNext()) { BindingSet bindingSet = iter.next(); Value rightValue = bindingSet.getValue(bindingName); try { result = QueryEvaluationUtil.compare(leftValue, rightValue, node.getOperator()); } catch (ValueExprEvaluationException e) { // Exception thrown by ValueCompare.isTrue(...) result = false; } } } finally { iter.close(); } return BooleanLiteral.valueOf(result); }
} else if (COMPARE_OPS.containsKey(op)) { if (expr.getArg(1) instanceof SubQueryExpression<?>) { return new CompareAll(toValue(expr.getArg(0), md), toTuple(expr.getArg(1), md), COMPARE_OPS.get(op)); } else { return new Compare(toValue(expr.getArg(0), md), toValue(expr.getArg(1), md), COMPARE_OPS.get(op));