@Override public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors) { for (LogicalExpression e : op.args) { if (!e.accept(this, errors)) { return false; } } return true; }
@Override public Boolean visitBooleanOperator(BooleanOperator op, ErrorCollector errors) { for (LogicalExpression arg : op.args) { if (arg.accept(this, errors)) { return true; } } return false; }
public static String toString(LogicalExpression expr) { StringBuilder sb = new StringBuilder(); expr.accept(INSTANCE, sb); return sb.toString(); }
private String convertLExToStr(LogicalExpression lex) { StringBuilder sb = new StringBuilder(); ExpressionStringBuilder esb = new ExpressionStringBuilder(); lex.accept(esb, sb); return sb.toString(); }
private static int getIntArg(LogicalExpression expr) { final Ref<Integer> ref = new Ref<>(); expr.accept(new OjaiFunctionsProcessor() { @Override public Void visitIntConstant(IntExpression e, Void v) { ref.value = new Integer(e.getInt()); return null; } }, null); return ref.value != null ? ref.value.intValue() : 0; }
@Override public void serialize(LogicalExpression value, JsonGenerator jgen, SerializerProvider provider) throws IOException { StringBuilder sb = new StringBuilder(); ExpressionStringBuilder esb = new ExpressionStringBuilder(); value.accept(esb, sb); jgen.writeString(sb.toString()); } }
@Override public Void visitConvertExpression(ConvertExpression e, ErrorCollector value) throws RuntimeException { return e.getInput().accept(this, value); }
private static SchemaPath getSchemaPathArg(LogicalExpression expr) { final Ref<SchemaPath> ref = new Ref<>(); expr.accept(new OjaiFunctionsProcessor() { @Override public Void visitSchemaPath(SchemaPath e, Void v) { ref.value = e; return null; } }, null); return ref.value; }
@Override public Boolean visitCastExpression(CastExpression e, ErrorCollector errors) { return e.getInput().accept(this, errors); }
@Override public Boolean visitConvertExpression(ConvertExpression e, ErrorCollector errors) throws RuntimeException { return e.getInput().accept(this, errors); }
@Override public Void visitAnyValueExpression(AnyValueExpression e, StringBuilder sb) throws RuntimeException { sb.append("any("); e.getInput().accept(this, sb); sb.append(")"); return null; }
@Override public Void visitAnyValueExpression(AnyValueExpression e, ErrorCollector value) throws RuntimeException { return e.getInput().accept(this, value); }
@Override public Void visitConvertExpression(ConvertExpression e, StringBuilder sb) throws RuntimeException { sb.append(e.getConvertFunction()).append("("); e.getInput().accept(this, sb); sb.append(", '").append(e.getEncodingType()).append("')"); return null; }
@Override public LogicalExpression visitIfExpression(IfExpression ifExpr, Void value) throws RuntimeException{ LogicalExpression newElseExpr = ifExpr.elseExpression.accept(this, value); IfCondition conditions = ifExpr.ifCondition; LogicalExpression newCondition = conditions.condition.accept(this, value); LogicalExpression newExpr = conditions.expression.accept(this, value); conditions = new IfExpression.IfCondition(newCondition, newExpr); return IfExpression.newBuilder().setElse(newElseExpr).setIfCondition(conditions).build(); }
private static String getStringArg(LogicalExpression expr) { final Ref<QuotedString> ref = new Ref<>(); expr.accept(new OjaiFunctionsProcessor() { @Override public Void visitQuotedStringConstant(QuotedString e, Void v) { ref.value = e; return null; } }, null); return ref.value != null ? ref.value.getString() : null; }
public JsonScanSpec parseTree() { JsonScanSpec parsedSpec = le.accept(this, null); if (parsedSpec != null) { parsedSpec.mergeScanSpec("booleanAnd", this.groupScan.getScanSpec()); } return parsedSpec; }
@Override public LogicalExpression visitFunctionHolderExpression(FunctionHolderExpression holder, Void value) throws RuntimeException { List<LogicalExpression> args = Lists.newArrayList(); for (int i = 0; i < holder.args.size(); ++i) { LogicalExpression newExpr = holder.args.get(i).accept(this, value); assert newExpr != null; args.add(newExpr); } //replace with a new function call, since its argument could be changed. return holder.copy(args); }
@Override public Boolean visitCastExpression(CastExpression e, LogicalExpression valueArg) throws RuntimeException { if (e.getInput() instanceof CastExpression || e.getInput() instanceof SchemaPath) { return e.getInput().accept(this, valueArg); } return false; }