@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; }
//Begin Validation If(field1 != ""){ //do something (stop to save data) }else If(encontrado == 1){ //do something (stop to save data) } If(field2 != ""){ //do something (stop to save data) }
@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 If(ValueExpr condition, ValueExpr result, ValueExpr alternative) { setCondition(condition); setResult(result); setAlternative(alternative); }
@Override public void meet(If node) throws RuntimeException { node.getResult().visit(this); node.getAlternative().visit(this); }
return ValueType.BOOL; } else if(expr instanceof If) { return getProjectionType(((If) expr).getResult()); } else if(expr instanceof Exists) { return ValueType.BOOL;
@Override public void replaceChildNode(QueryModelNode current, QueryModelNode replacement) { if (condition == current) { setCondition((ValueExpr)replacement); } else if (result == current) { setResult((ValueExpr)replacement); } else if (alternative == current) { setAlternative((ValueExpr)replacement); } else { super.replaceChildNode(current, replacement); } }
@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(); }
typefaceB.isBold() && typefaceA.isItalic() If (spannable.getTypeface.isItalic()) { } else { }
@Override public If clone() { If clone = (If)super.clone(); clone.setCondition(condition.clone()); if (result != null) { clone.setResult(result.clone()); } if (alternative != null) { clone.setAlternative(alternative.clone()); } return clone; }
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; }
"select timestamp_column from `settings_table` order by timestamp_column limimt 1" If ($result["timestamp_column"]+1000>=time()){ //do the refreshnow.php code here }
@Override public void meet(final If n) { emit("IF(").emit(n.getCondition()).emit(", ").emit(n.getResult()).emit(", ") .emit(n.getAlternative()).emit(")"); }
@Override public If visit(ASTIf node, Object data) throws VisitorException { If result = null; if (node.jjtGetNumChildren() < 3) { throw new VisitorException("IF construction missing required number of arguments"); } ValueExpr condition = (ValueExpr)node.jjtGetChild(0).jjtAccept(this, null); ValueExpr resultExpr = (ValueExpr)node.jjtGetChild(1).jjtAccept(this, null); ValueExpr alternative = (ValueExpr)node.jjtGetChild(2).jjtAccept(this, null); result = new If(condition, resultExpr, alternative); return result; }
@Override public void meet(final If n) { emit("IF(").emit(n.getCondition()).emit(", ").emit(n.getResult()).emit(", ") .emit(n.getAlternative()).emit(")"); }
String.format("Invalid number of arguments for function: %s", func)); expr = new If(args.get(0), args.get(1), args.get(2));
@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; }