@Test public void testAddExpr() throws JSQLParserException { Select select = (Select) CCJSqlParserUtil.parse("select a from mytable"); SelectUtils.addExpression(select, new Column("b")); assertEquals("SELECT a, b FROM mytable", select.toString()); Addition add = new Addition(); add.setLeftExpression(new LongValue(5)); add.setRightExpression(new LongValue(6)); SelectUtils.addExpression(select, add); assertEquals("SELECT a, b, 5 + 6 FROM mytable", select.toString()); }
public static void addExpression(Select select, final Expression expr) { select.getSelectBody().accept(new SelectVisitor() { @Override public void visit(PlainSelect plainSelect) { plainSelect.getSelectItems().add(new SelectExpressionItem(expr)); } @Override public void visit(SetOperationList setOpList) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } @Override public void visit(WithItem withItem) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } }); }
SelectUtils { public static void addExpression(Select select, final Expression expr) { select.getSelectBody().accept(new SelectVisitor() { @Override public void visit(PlainSelect plainSelect) { plainSelect.getSelectItems().add(new SelectExpressionItem(expr)); } @Override public void visit(SetOperationList setOpList) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } @Override public void visit(WithItem withItem) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } }); } }
SelectUtils { public static void addExpression(Select select, final Expression expr) { select.getSelectBody().accept(new SelectVisitor() { @Override public void visit(PlainSelect plainSelect) { plainSelect.getSelectItems().add(new SelectExpressionItem(expr)); } @Override public void visit(SetOperationList setOpList) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } @Override public void visit(WithItem withItem) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } }); } private  SelectUtils(); }
SelectUtils { public static void addExpression(Select select, final Expression expr) { select.getSelectBody().accept(new SelectVisitor() { @Override public void visit(PlainSelect plainSelect) { plainSelect.getSelectItems().add(new SelectExpressionItem(expr)); } @Override public void visit(SetOperationList setOpList) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } @Override public void visit(WithItem withItem) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } }); } private  SelectUtils(); static Select buildSelectFromTableAndExpressions(Table table, Expression ... expr); static Select buildSelectFromTableAndExpressions(Table table, String ... expr); static Select buildSelectFromTableAndSelectItems(Table table, SelectItem ... selectItems); static Select buildSelectFromTable(Table table); static void addExpression(Select select, final Expression expr); static Join addJoin(Select select, final Table table, final Expression onExpression); static void addGroupBy(Select select, final Expression expr); }
SelectUtils { public static void addExpression(Select select, final Expression expr) { select.getSelectBody().accept(new SelectVisitor() { @Override public void visit(PlainSelect plainSelect) { plainSelect.getSelectItems().add(new SelectExpressionItem(expr)); } @Override public void visit(SetOperationList setOpList) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } @Override public void visit(WithItem withItem) { throw new UnsupportedOperationException(NOT_SUPPORTED_YET); } }); } private  SelectUtils(); static Select buildSelectFromTableAndExpressions(Table table, Expression ... expr); static Select buildSelectFromTableAndExpressions(Table table, String ... expr); static Select buildSelectFromTableAndSelectItems(Table table, SelectItem ... selectItems); static Select buildSelectFromTable(Table table); static void addExpression(Select select, final Expression expr); static Join addJoin(Select select, final Table table, final Expression onExpression); static void addGroupBy(Select select, final Expression expr);  }