public String toString() { return getWholeTableName()+((alias!=null)?" AS "+alias:""); } }
/** * @return the name of the column, prefixed with 'tableName' and '.' */ public String getWholeColumnName() { String columnWholeName = null; String tableWholeName = table.getWholeTableName(); if (tableWholeName != null && tableWholeName.length() != 0) { columnWholeName = tableWholeName + "." + columnName; } else { columnWholeName = columnName; } return columnWholeName; }
public void visit(Table tableName) { buffer.append(tableName.getWholeTableName()); String alias = tableName.getAlias(); if (alias != null && !alias.equals("")) { buffer.append(" AS " + alias); } }
public void visit(AllTableColumns allTableColumns) { buffer.append(allTableColumns.getTable().getWholeTableName() + ".*"); }
public void visit(Column tableColumn) { String tableName = tableColumn.getTable().getWholeTableName(); if (tableName != null) { buffer.append(tableName + "."); } buffer.append(tableColumn.getColumnName()); }
public void deParse(Insert insert) { buffer.append("INSERT INTO "); buffer.append(insert.getTable().getWholeTableName()); if (insert.getColumns() != null) { buffer.append("("); for (Iterator iter = insert.getColumns().iterator(); iter.hasNext();) { Column column = (Column) iter.next(); buffer.append(column.getColumnName()); if (iter.hasNext()) { buffer.append(", "); } } buffer.append(")"); } insert.getItemsList().accept(this); }
public void deParse(Delete delete) { buffer.append("DELETE FROM " + delete.getTable().getWholeTableName()); if (delete.getWhere() != null) { buffer.append(" WHERE "); delete.getWhere().accept(expressionVisitor); } } public ExpressionVisitor getExpressionVisitor() {
public void deParse(CreateTable createTable) { buffer.append("CREATE TABLE " + createTable.getTable().getWholeTableName()); if (createTable.getColumnDefinitions() != null) { buffer.append(" { ");
public void deParse(Update update) { buffer.append("UPDATE " + update.getTable().getWholeTableName() + " SET "); for (int i = 0; i < update.getColumns().size(); i++) { Column column = (Column) update.getColumns().get(i); buffer.append(column.getWholeColumnName() + "="); Expression expression = (Expression) update.getExpressions().get(i); expression.accept(expressionVisitor); if (i < update.getColumns().size() - 1) { buffer.append(", "); } } if (update.getWhere() != null) { buffer.append(" WHERE "); update.getWhere().accept(expressionVisitor); } }
public void deParse(Replace replace) { buffer.append("REPLACE " + replace.getTable().getWholeTableName()); if (replace.getItemsList() != null) { if (replace.getColumns() != null) { buffer.append(" ("); for (int i = 0; i < replace.getColumns().size(); i++) { Column column = (Column) replace.getColumns().get(i); buffer.append(column.getWholeColumnName()); if (i < replace.getColumns().size() - 1) { buffer.append(", "); } } buffer.append(") "); } else { buffer.append(" "); } } else { buffer.append(" SET "); for (int i = 0; i < replace.getColumns().size(); i++) { Column column = (Column) replace.getColumns().get(i); buffer.append(column.getWholeColumnName() + "="); Expression expression = (Expression) replace.getExpressions().get(i); expression.accept(expressionVisitor); if (i < replace.getColumns().size() - 1) { buffer.append(", "); } } } }
public String toString() { return getWholeTableName()+((alias!=null)?" AS "+alias:""); } }
public void visit(Table tableName) { buffer.append(tableName.getWholeTableName()); String alias = tableName.getAlias(); if (alias != null && !alias.isEmpty()) { buffer.append(" AS " + alias); } }
public void visit(Column tableColumn) { String tableName = tableColumn.getTable().getWholeTableName(); if (tableName != null) { buffer.append(tableName + "."); } buffer.append(tableColumn.getColumnName()); }
public static Map<String, FromItem> prepareUniqueTables(Map<String, FromItem> tables) { Map<String, FromItem> uniqueTables = new HashMap<>(); tables.values().stream().forEach((fromItem) -> { if (fromItem.getAlias() != null && !fromItem.getAlias().getName().isEmpty()) { uniqueTables.put(fromItem.getAlias().getName().toLowerCase(), fromItem); } else if (fromItem instanceof Table) { uniqueTables.put(((Table) fromItem).getWholeTableName().toLowerCase(), fromItem); } }); return uniqueTables; }
@Override public String toString() { return (getComment() != null ? getComment() + " " : "") + getWholeTableName() + (alias != null ? " " + alias : ""); }
public void visit(Table aTable) { buffer.append(aTable.getComment() != null ? aTable.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(aTable.getWholeTableName()); String alias = aTable.getAlias() != null ? aTable.getAlias().toString() : ""; if (alias != null && !alias.isEmpty()) { buffer.append(" ").append(alias);// it's very strange, but in fact oracle doesn't permit as key word if form clause // buffer.append(" as ").append(alias); } }
public void deParse(Delete delete) { buffer.append("DELETE FROM " + delete.getTable().getWholeTableName()); if (delete.getWhere() != null) { buffer.append(" WHERE "); delete.getWhere().accept(expressionVisitor); } } public ExpressionVisitor getExpressionVisitor() {
public void visit(Column tableColumn) { buffer.append(tableColumn.getComment() != null ? tableColumn.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : ""); if (tableColumn.getTable().getName() != null) { String tableName = tableColumn.getTable().getWholeTableName(); buffer.append(tableName).append("."); } buffer.append(tableColumn.getColumnName()); }
public void deParse(Truncate truncate) { buffer.append(truncate.getComment() != null ? truncate.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append("Truncate") .append(truncate.getCommentTable() != null ? " " + truncate.getCommentTable() + ExpressionDeParser.LINE_SEPARATOR : "").append(" Table ") .append(truncate.getTable().getComment() != null ? truncate.getTable().getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(truncate.getTable().getWholeTableName()); buffer.append(!"".equals(truncate.getEndComment()) ? " " + truncate.getEndComment() : ""); }
public void deParse(Delete aDelete) { buffer .append(aDelete.getComment() != null ? aDelete.getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "") .append("Delete").append(aDelete.getFromComment() != null ? " " + aDelete.getFromComment() + ExpressionDeParser.LINE_SEPARATOR : "").append(" From ") .append(aDelete.getTable().getComment() != null ? aDelete.getTable().getComment() + " " + ExpressionDeParser.LINE_SEPARATOR : "").append(aDelete.getTable().getWholeTableName()); if (aDelete.getWhere() != null) { buffer.append(aDelete.getWhereComment() != null ? " " + aDelete.getWhereComment() : "").append(ExpressionDeParser.LINE_SEPARATOR).append(" Where "); aDelete.getWhere().accept(expressionVisitor); } buffer.append(!"".equals(aDelete.getEndComment()) ? " " + aDelete.getEndComment() : ""); }