/** * Return the field sorted in the correct order coresponding to the result set. * This is used for cursored selects where custom sql was provided. * If the fields passed in are null, this means that the field are not known and should be * built from the column names. This case occurs for DataReadQuery's. */ public Vector buildSortedFields(Vector fields, ResultSet resultSet, AbstractSession session) throws DatabaseException { Vector sortedFields; try { Vector columnNames = getColumnNames(resultSet, session); if (fields == null) {// Means fields not known. sortedFields = new Vector(columnNames.size()); for (Enumeration columnNamesEnum = columnNames.elements(); columnNamesEnum.hasMoreElements();) { sortedFields.addElement(new DatabaseField((String)columnNamesEnum.nextElement())); } } else { sortedFields = sortFields(fields, columnNames); } } catch (SQLException exception) { throw DatabaseException.sqlException(exception, this, session); } return sortedFields; }