/** * @since 4.0 */ public void appendAsEJBQL(Appendable out, String rootId) throws IOException { appendAsEJBQL(null, out, rootId); }
/** * @since 4.0 */ @Override public void appendAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException { if ((children != null) && (children.length > 0)) { out.append("-"); SimpleNode child = (SimpleNode) children[0]; // don't call super - we have our own parenthesis policy boolean useParen = parent != null && !((child instanceof ASTScalar) || (child instanceof ASTPath)); if (useParen) { out.append("("); } child.appendAsEJBQL(parameterAccumulator, out, rootId); if (useParen) { out.append(')'); } } }
/** * @since 3.0 * @deprecated since 4.0 use {@link #appendAsEJBQL(Appendable, String)}. */ @Override @Deprecated public void encodeAsEJBQL(PrintWriter pw, String rootId) { try { appendAsEJBQL(pw, rootId); } catch (IOException e) { throw new CayenneRuntimeException("Unexpected IO exception appending to PrintWriter", e); } }
/** * Encodes child of this node with specified index to EJBQL */ protected void appendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException { for (int i = 0; i < children.length; ++i) { if (i > 0) { out.append(' '); out.append(getEJBQLExpressionOperator(i)); out.append(' '); } if (children[i] == null) { out.append("null"); } else { ((SimpleNode) children[i]).appendAsEJBQL(parameterAccumulator, out, rootId); } } } }
@Override protected void appendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException { // with like, first expression is always path, second is a literal, // which must be uppercased out.append("upper("); ((SimpleNode) children[0]).appendAsEJBQL(parameterAccumulator, out, rootId); out.append(") "); out.append(getEJBQLExpressionOperator(0)); out.append(" "); Object literal = ((ASTScalar) children[1]).getValue(); if (!(literal instanceof String)) { throw new ExpressionException("Literal value should be a string"); } SimpleNode.encodeScalarAsEJBQL(parameterAccumulator, out, ((String) literal).toUpperCase()); } }