public Column getColumn(String tableName, String columnName) {
   for (Column column : this.columns) {
     if (StringUtils.equalsIgnoreCase(tableName, column.getTable())
         && StringUtils.equalsIgnoreCase(columnName, column.getName())) {
       return column;
     }
   }
   return null;
 }
    public void addOrderByColumn(String table, String columnName, SQLObject expr) {
      Column column = new Column(table, columnName);

      SQLObject parent = expr.getParent();
      if (parent instanceof SQLSelectOrderByItem) {
        SQLOrderingSpecification type = ((SQLSelectOrderByItem) parent).getType();
        column.getAttributes().put("orderBy.type", type);
      }

      orderByColumns.add(column);
    }
  private void setColumn(SQLExpr x, Column column) {
    SQLObject current = x;
    for (; ; ) {
      SQLObject parent = current.getParent();

      if (parent == null) {
        break;
      }

      if (parent instanceof SQLSelectQueryBlock) {
        SQLSelectQueryBlock query = (SQLSelectQueryBlock) parent;
        if (query.getWhere() == current) {
          column.setWhere(true);
        }
        break;
      }

      if (parent instanceof SQLSelectGroupByClause) {
        SQLSelectGroupByClause groupBy = (SQLSelectGroupByClause) parent;
        if (current == groupBy.getHaving()) {
          column.setHaving(true);
        } else if (groupBy.getItems().contains(current)) {
          column.setGroupBy(true);
        }
        break;
      }

      if (parent instanceof SQLSelectItem) {
        column.setSelec(true);
        break;
      }

      if (parent instanceof SQLJoinTableSource) {
        SQLJoinTableSource join = (SQLJoinTableSource) parent;
        if (join.getCondition() == current) {
          column.setJoin(true);
        }
        break;
      }

      current = parent;
    }
  }