@Override public String toString() { StringBuilder retval = new StringBuilder(); if (withItemsList != null && !withItemsList.isEmpty()) { retval.append(getCommentWith() != null ? getCommentWith() + " " : ""); retval.append("WITH "); String tmp = PlainSelect.getStringListWithCommaComment(withItemsList, commentsComma, true, false, null); retval.append(tmp).append(" "); } retval.append(selectBody); retval.append(!"".equals(getEndComment()) ? " " + getEndComment() : ""); return retval.toString(); }
public void visit(Select select) { SelectDeParser selectDeParser = new SelectDeParser(); selectDeParser.setBuffer(buffer); ExpressionDeParser expressionDeParser = new ExpressionDeParser(selectDeParser, buffer); selectDeParser.setExpressionVisitor(expressionDeParser); if (select.getWithItemsList() != null && !select.getWithItemsList().isEmpty()) { buffer.append(select.getCommentWith() != null ? select.getCommentWith()+" " : "").append(ExpressionDeParser.LINE_SEPARATOR).append("With "); for (int i = 0; i < select.getWithItemsList().size(); i++) { WithItem withItem = (WithItem) select.getWithItemsList().get(i); buffer.append(withItem); buffer.append((i < select.getWithItemsList().size() - 1) ? (!"".equals(select.getCommentsComma().get(i)) ? " " + select.getCommentsComma().get(i)+ExpressionDeParser.LINE_SEPARATOR:"")+ "," : "") .append(ExpressionDeParser.LINE_SEPARATOR).append(" "); } } select.getSelectBody().accept(selectDeParser); buffer.append(!"".equals(select.getEndComment()) ? " "+select.getEndComment() : ""); }