/** * Indents a string with 4 spaces. * * @param s the string * @return the indented string */ public static String indent(String s) { return indent(s, 4, true); }
/** * Create an XML node with optional attributes and content. The data is * indented with 4 spaces if it contains a newline character and the indent * parameter is set to true. * * @param name the element name * @param attributes the attributes (may be null) * @param content the content (may be null) * @param indent whether to indent the content if it contains a newline * @return the node */ public static String xmlNode(String name, String attributes, String content, boolean indent) { String start = attributes == null ? name : name + attributes; if (content == null) { return "<" + start + "/>\n"; } if (indent && content.indexOf('\n') >= 0) { content = "\n" + indent(content); } return "<" + start + ">" + content + "</" + name + ">\n"; }
@Override public String getSQL(boolean isDistributed) { return "EXISTS(\n" + StringUtils.indent(query.getPlanSQL(), 4, false) + ")"; }
/** * Escapes a comment. * If the data contains '--', it is converted to '- -'. * The data is indented with 4 spaces if it contains a newline character. * * @param data the comment text * @return <!-- data --> */ public static String xmlComment(String data) { int idx = 0; while (true) { idx = data.indexOf("--", idx); if (idx < 0) { break; } data = data.substring(0, idx + 1) + " " + data.substring(idx + 1); } // must have a space at the beginning and at the end, // otherwise the data must not contain '-' as the first/last character if (data.indexOf('\n') >= 0) { return "<!--\n" + indent(data) + "-->\n"; } return "<!-- " + data + " -->\n"; }
@Override public String getSQL(boolean isDistributed) { StringBuilder buff = new StringBuilder(); buff.append('(').append(left.getSQL(isDistributed)).append(' '); if (all) { buff.append(Comparison.getCompareOperator(compareType)).append(" ALL"); } else { if (compareType != Comparison.EQUAL) buff.append(Comparison.getCompareOperator(compareType)).append(" SOME"); else buff.append("IN"); } buff.append("(\n").append(StringUtils.indent(query.getPlanSQL(), 4, false)).append("))"); return buff.toString(); }
@Override public String getSQL() { if (isTemporary()) { return "(\n" + StringUtils.indent(querySQL) + ")"; } return super.getSQL(); }
buff.append("(\n"); buff.append(StringUtils.indent(nested, 4, false)); if (enclose) { buff.append(')'); plan += "\n"; buff.append(StringUtils.indent("/* " + plan + " */", 4, false)); String condition = StringUtils.unEnclose(filterCondition.getSQL()); condition = "/* WHERE " + StringUtils.quoteRemarkSQL(condition) + "\n*/"; buff.append(StringUtils.indent(condition, 4, false));
buff.appendExceptFirst(","); buff.append('\n'); buff.append(StringUtils.indent(exprList[i].getSQL(isDistributed), 4, false));