Enumeration columnNamesEnum = columnNames.elements();
boolean valueFound = false;
while (columnNamesEnum.hasMoreElements()) {
String columnName = (String)columnNamesEnum.nextElement();
DatabaseField field = null;
Enumeration fieldEnum = eligableFields.elements();
while (fieldEnum.hasMoreElements()) {
field = (DatabaseField)fieldEnum.nextElement();
if(field != null){
if (DatabasePlatform.shouldIgnoreCaseOnFieldComparisons()) {
if (field.getName().equalsIgnoreCase(columnName)) {
valueFound = true;
sortedFields.addElement(field);
break;
}
} else {
if (field.getName().equals(columnName)) {
valueFound = true;
sortedFields.addElement(field);
break;
}
}
}
}
if (valueFound) {
// The eligable fields must be maintained as two field can have the same name, but different tables.
eligableFields.removeElement(field);
} else {
// Need to add a place holder in case the column is not in the fiels vector
sortedFields.addElement(new DatabaseField());
}
valueFound = false;
}
return sortedFields;