public static TObjectName[] getTableColumns(TTable table) { Table createTable = ModelBindingManager.getCreateTable(table); if (createTable != null) { IList <TableColumn> columnList = createTable.Columns; TObjectName[] columns = new TObjectName[columnList.Count]; for (int i = 0; i < columns.Length; i++) { columns[i] = columnList[i].ColumnObject; } Array.Sort(columns, new ComparatorAnonymousInnerClass()); return(columns); } else { TObjectNameList list = table.ObjectNameReferences; List <TObjectName> columns = new List <TObjectName>(); if (list.size() == 0 && table.Subquery != null) { ResultSet resultSet = (ResultSet)ModelBindingManager.getModel(table.Subquery); if (resultSet != null) { IList <ResultColumn> columnList = resultSet.Columns; for (int i = 0; i < columnList.Count; i++) { ResultColumn resultColumn = columnList[i]; if (resultColumn.ColumnObject is TResultColumn) { TResultColumn columnObject = ((TResultColumn)resultColumn.ColumnObject); TAliasClause alias = columnObject.AliasClause; if (alias != null && alias.AliasName != null) { columns.Add(alias.AliasName); } else { if (columnObject.FieldAttr != null) { columns.Add(columnObject.FieldAttr); } else { continue; } } } else if (resultColumn.ColumnObject is TObjectName) { columns.Add((TObjectName)resultColumn.ColumnObject); } } } } else { for (int i = 0; i < list.size(); i++) { columns.Add(list.getObjectName(i)); } } TObjectName[] columnArray = columns.ToArray(); Array.Sort(columnArray, new ComparatorAnonymousInnerClass()); return(columnArray); } }
public SelectSetResultColumn(ResultSet resultSet, ResultColumn resultColumn) { if (resultColumn == null || resultSet == null) { throw new System.ArgumentException("ResultColumn arguments can't be null."); } id = ++TableColumn.TABLE_COLUMN_ID; this.resultSet = resultSet; resultSet.addColumn(this); if (resultColumn.ColumnObject is TResultColumn) { TResultColumn resultColumnObject = (TResultColumn)resultColumn.ColumnObject; if (resultColumnObject.AliasClause != null) { this.alias = resultColumnObject.AliasClause.ToString(); TSourceToken aliasStartToken = resultColumnObject.AliasClause.startToken; TSourceToken aliasEndToken = resultColumnObject.AliasClause.endToken; this.aliasStartPosition = new Tuple <long, long>(aliasStartToken.lineNo, aliasStartToken.columnNo); this.aliasEndPosition = new Tuple <long, long>(aliasEndToken.lineNo, aliasEndToken.columnNo + aliasEndToken.astext.Length); this.name = this.alias; } else { if (resultColumnObject.Expr.ExpressionType == EExpressionType.simple_constant_t) { if (resultSet is SelectResultSet) { this.name = "DUMMY" + getIndexOf(((SelectResultSet)resultSet).ResultColumnObject, resultColumnObject); } else if (resultSet is SelectSetResultSet) { this.name = "DUMMY" + getIndexOf(((SelectSetResultSet)resultSet).ResultColumnObject, resultColumnObject); } else { this.name = resultColumnObject.ToString(); } } else if (resultColumnObject.Expr.ExpressionType == EExpressionType.function_t) { this.name = resultColumnObject.Expr.FunctionCall.FunctionName.ToString(); } else if (resultColumnObject.ColumnNameOnly != null && !"".Equals(resultColumnObject.ColumnNameOnly)) { this.name = resultColumnObject.ColumnNameOnly; } else { this.name = resultColumnObject.ToString(); } } if (resultColumnObject.Expr.ExpressionType == EExpressionType.function_t) { this.fullName = resultColumnObject.Expr.FunctionCall.FunctionName.ToString(); } else { this.fullName = resultColumnObject.ToString(); } TSourceToken startToken = resultColumnObject.startToken; TSourceToken endToken = resultColumnObject.endToken; this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo); this.endPosition = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length); this.columnObject = resultColumnObject; } else if (resultColumn.ColumnObject is TObjectName) { TObjectName resultColumnObject = (TObjectName)resultColumn.ColumnObject; if (resultColumnObject.ColumnNameOnly != null && !"".Equals(resultColumnObject.ColumnNameOnly)) { this.name = resultColumnObject.ColumnNameOnly; } else { this.name = resultColumnObject.ToString(); } this.fullName = this.name; TSourceToken startToken = resultColumnObject.startToken; TSourceToken endToken = resultColumnObject.endToken; this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo); this.endPosition = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length); this.columnObject = resultColumnObject; } else { this.name = resultColumn.Name; this.fullName = this.name; TSourceToken startToken = resultColumn.ColumnObject.startToken; TSourceToken endToken = resultColumn.ColumnObject.endToken; this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo); this.endPosition = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length); this.columnObject = resultColumn.ColumnObject; } }