@Override public boolean equals(Object other) { if (other instanceof If) { If o = (If)other; boolean equal = condition.equals(o.getCondition()); if (!equal) { return equal; } equal = (result == null) ? o.getResult() == null : result.equals(o.getResult()); if (!equal) { return equal; } equal = (alternative == null) ? o.getAlternative() == null : alternative.equals(o.getAlternative()); return equal; } return false; }
@Override public void meet(If node) throws RuntimeException { builder.append("CASE WHEN "); optypes.push(ValueType.BOOL); node.getCondition().visit(this); optypes.pop(); optypes.push(new OPTypeFinder(node).coerce()); builder.append(" THEN "); node.getResult().visit(this); builder.append(" ELSE "); node.getAlternative().visit(this); builder.append(" END"); optypes.pop(); }
@Override public void meet(If node) throws RuntimeException { node.getResult().visit(this); node.getAlternative().visit(this); }
@Override public void meet(If node) { super.meet(node); if (isConstant(node.getCondition())) { try { if (strategy.isTrue(node.getCondition(), EmptyBindingSet.getInstance())) { node.replaceWith(node.getResult()); } else { node.replaceWith(node.getAlternative()); } } catch (ValueExprEvaluationException e) { logger.debug("Failed to evaluate UnaryValueOperator with a constant argument", e); } catch (QueryEvaluationException e) { logger.error("Query evaluation exception caught", e); } } }
public Value evaluate(If node, BindingSet bindings) throws QueryEvaluationException { Value result = null; boolean conditionIsTrue; try { Value value = evaluate(node.getCondition(), bindings); conditionIsTrue = QueryEvaluationUtil.getEffectiveBooleanValue(value); } catch (ValueExprEvaluationException e) { // in case of type error, if-construction should result in empty // binding. return null; } if (conditionIsTrue) { result = evaluate(node.getResult(), bindings); } else { result = evaluate(node.getAlternative(), bindings); } return result; }
@Override public void meet(final If n) { emit("IF(").emit(n.getCondition()).emit(", ").emit(n.getResult()).emit(", ") .emit(n.getAlternative()).emit(")"); }
@Override public void meet(final If n) { emit("IF(").emit(n.getCondition()).emit(", ").emit(n.getResult()).emit(", ") .emit(n.getAlternative()).emit(")"); }
@Override public void meet(If node) throws RDFHandlerException { Resource currentSubj = subject; flushPendingStatement(); handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.IF)); predicate = SP.ARG1_PROPERTY; node.getCondition().visit(this); predicate = SP.ARG2_PROPERTY; node.getResult().visit(this); predicate = SP.ARG3_PROPERTY; node.getAlternative().visit(this); subject = currentSubj; predicate = null; }