protected Object evaluateChild(int index, Object o) throws Exception { SimpleNode node = (SimpleNode) jjtGetChild(index); return node != null ? node.evaluate(o) : null; }
@Override public void jjtSetParent(Node n) { // this is a check that we can't handle properly // in the grammar... do it here... // disallow non-aggregated condition parents... if (!(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode)n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid parent - " + label); } super.jjtSetParent(n); }
public void encodeAsString(PrintWriter pw) { if (parent != null) { pw.print("("); } if ((children != null) && (children.length > 0)) { for (int i = 0; i < children.length; ++i) { if (i > 0) { pw.print(' '); pw.print(getExpressionOperator(i)); pw.print(' '); } ((SimpleNode) children[i]).encodeAsString(pw); } } if (parent != null) { pw.print(')'); } }
public Object getOperand(int index) { Node child = jjtGetChild(index); // unwrap ASTScalar nodes - this is likely a temporary thing to keep it compatible // with QualifierTranslator. In the future we might want to keep scalar nodes // for the purpose of expression evaluation. return unwrapChild(child); }
private ASTObjPath findPeerPath(SimpleNode exp, Object child) { if (exp == null) { return null; } if (!(exp instanceof ConditionNode)) { return findPeerPath((SimpleNode) exp.jjtGetParent(), exp); } // terminate walk up at a ConditionNode, start a walk down int len = exp.getOperandCount(); for (int i = 0; i < len; i++) { Object operand = exp.getOperand(i); if (operand == child || !(operand instanceof Expression)) { continue; } ASTObjPath path = findChildPath((Expression) operand); if (path != null) { return path; } } return null; }
@Override public Object evaluate(Object o) { // wrap in try/catch to provide unified exception processing try { return evaluateNode(o); } catch (Throwable th) { String string = this.toString(); throw new ExpressionException("Error evaluating expression '%s'", string, Util.unwindException(th), string); } }
@Override public void jjtAddChild(Node n, int i) { // this is a check that we can't handle properly // in the grammar... do it here... // only allow conditional nodes...no scalars if (!(n instanceof ConditionNode) && !(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode) n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid child - " + label); } super.jjtAddChild(n, i); } }
public void jjtClose() { super.jjtClose(); flattenTree(); } }
Expression parent = (Expression) ((SimpleNode) e).jjtGetParent(); if (parent != null) { return paramsDbType(parent);
/** * @since 4.0 */ @Override public void appendAsString(Appendable out) throws IOException { if (parent != null) { out.append("("); } if ((children != null) && (children.length > 0)) { for (int i = 0; i < children.length; ++i) { if (i > 0) { out.append(' '); out.append(getExpressionOperator(i)); out.append(' '); } if (children[i] == null) { out.append("null"); } else { ((SimpleNode) children[i]).appendAsString(out); } } } if (parent != null) { out.append(')'); } }
public void setOperand(int index, Object value) { Node node = (value == null || value instanceof Node) ? (Node) value : new ASTScalar(value); jjtAddChild(node, index); // set the parent, as jjtAddChild doesn't do it... if (node != null) { node.jjtSetParent(this); } }
/** * Returns operator for EJBQL statements, which can differ for Cayenne expression operator */ protected String getEJBQLExpressionOperator(int index) { return getExpressionOperator(index); }
public Object transform(Object input) { if (input instanceof ASTObjPath) { return new ASTDbPath(((SimpleNode) input).getOperand(0)); } return input; } }
@Override protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) { SimpleNode parent = null; if (pathExp instanceof SimpleNode) { parent = (SimpleNode) ((SimpleNode) pathExp).jjtGetParent(); } // problem in derby : Comparisons between 'CLOB (UCS_BASIC)' and 'CLOB // (UCS_BASIC)' are not supported. // we need do it by casting the Clob to VARCHAR. if (parent != null && (parent instanceof ASTEqual || parent instanceof ASTNotEqual) && dbAttr.getType() == Types.CLOB && parent.getOperandCount() == 2 && parent.getOperand(1) instanceof String) { Integer size = parent.getOperand(1).toString().length() + 1; out.append("CAST("); super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp); out.append(" AS VARCHAR(").append(size).append("))"); } else { super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp); } }
@Override public Object getOperand(int index) { Node child = jjtGetChild(index); // unwrap ASTScalar nodes - this is likely a temporary thing to keep it compatible // with QualifierTranslator. In the future we might want to keep scalar nodes // for the purpose of expression evaluation. return unwrapChild(child); }
public Object evaluate(Object o) { // wrap in try/catch to provide unified exception processing try { return evaluateNode(o); } catch (Throwable th) { String string = this.toString(); throw new ExpressionException( "Error evaluating expression '" + string + "'", string, Util.unwindException(th)); } } }
public void jjtClose() { super.jjtClose(); flattenTree(); } }
Expression parent = (Expression) ((SimpleNode) e).jjtGetParent(); if (parent != null) { return paramsDbType(parent);
@Override public void setOperand(int index, Object value) { Node node = (value == null || value instanceof Node) ? (Node) value : new ASTScalar(value); jjtAddChild(node, index); // set the parent, as jjtAddChild doesn't do it... if (node != null) { node.jjtSetParent(this); } }
@Override protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) { SimpleNode parent = null; if (pathExp instanceof SimpleNode) { parent = (SimpleNode) ((SimpleNode) pathExp).jjtGetParent(); } // problem in db2 : Comparisons between CLOB and CLOB are not supported. // we need do it by casting the Clob to VARCHAR. if (parent != null && (parent instanceof ASTEqual || parent instanceof ASTNotEqual) && dbAttr.getType() == Types.CLOB && parent.getOperandCount() == 2 && parent.getOperand(1) instanceof String) { Integer size = parent.getOperand(1).toString().length() + 1; out.append("CAST("); super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp); out.append(" AS VARCHAR(" + size + "))"); } else { super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp); } }