@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(); }
public static LogicalExpression createExpression(String functionName, ExpressionPosition ep, List<LogicalExpression> args){ String name = replaceOpWithFuncName(functionName); if (isBooleanOperator(name)) { return new BooleanOperator(name, args, ep); } else { return new FunctionCall(name, args, ep); } }
@Override public NameSegment cloneWithNewChild(PathSegment newChild) { NameSegment s = new NameSegment(this.path); if (getChild() != null) { s.setChild(getChild().cloneWithNewChild(newChild)); } else { s.setChild(newChild); } return s; } }
@Override public NameSegment clone() { NameSegment s = new NameSegment(this.path); if (getChild() != null) { s.setChild(getChild().clone()); } return s; }
@Override public ArraySegment cloneWithNewChild(PathSegment newChild) { ArraySegment seg = index < 0 ? new ArraySegment((PathSegment) null) : new ArraySegment(index); if (getChild() != null) { seg.setChild(getChild().cloneWithNewChild(newChild)); } else { seg.setChild(newChild); } return seg; } }
public SchemaPath getChild(int index) { NameSegment newRoot = rootSegment.cloneWithNewChild(new ArraySegment(index)); return new SchemaPath(newRoot); }
@Override public PathSegment clone() { PathSegment seg = index < 0 ? new ArraySegment((PathSegment) null) : new ArraySegment(index); if (getChild() != null) { seg.setChild(getChild().clone()); } return seg; }
private static PathSegment getPathSegment(NamePart n) { PathSegment child = n.hasChild() ? getPathSegment(n.getChild()) : null; if (n.getType() == Type.ARRAY) { return new ArraySegment(child); } else { return new NameSegment(n.getName(), child); } }
public static SchemaPath getCompoundPath(String... strings) { NameSegment s = null; // loop through strings in reverse order for (int i = strings.length - 1; i >= 0; i--) { s = new NameSegment(strings[i], s); } return new SchemaPath(s); }
public FieldReference(CharSequence value, ExpressionPosition pos, boolean check) { super(new NameSegment(value), pos); if (check) { checkData(); } }
@Override public int getCumulativeCost() { // return the average cost of operands for a boolean "and" | "or" int cost = this.getSelfCost(); int i = 0; for (LogicalExpression e : this) { cost += e.getCumulativeCost(); i++; } return cost / i; }
@Override public int getCumulativeCost() { // return the average cost of operands for a boolean "and" | "or" int cost = this.getSelfCost(); int i = 0; for (LogicalExpression e : this) { cost += e.getCumulativeCost(); i++; } return cost / i; }
/** * Create a {@link FieldReference} given an unquoted name. (Note: the * name here is a misnomer: the name may have been quoted in SQL, but * must be unquoted when passed in here.) * * @param safeString the unquoted field reference * @return the field reference expression */ public static FieldReference getWithQuotedRef(CharSequence safeString) { return new FieldReference(safeString, ExpressionPosition.UNKNOWN, false); }