*@param sortBy Description of the Parameter
*@return result of compareToIgnoreCase
*/
private static int compareFiles(Object o1, Object o2, String sortBy,boolean prio, Vector prioList) {
int ret;
FtpFile f1 = (FtpFile) o1;
FtpFile f2 = (FtpFile) o2;
if (prio) {
int m1 = matches(prioList, f1.getName()), m2 = matches(prioList, f2.getName());
if (m1 != -1 || m2 != -1) {
if (m1 > m2) {
return -1;
}
else if (m2 > m1) {
return 1;
}
}
}
if (f1.isDirectory() && !f2.isDirectory()) {
return -1;
}
if (!f1.isDirectory() && f2.isDirectory()) {
return 1;
}
if (sortBy.equals("Name")) {
return f1.getName().compareToIgnoreCase(f2.getName());
} else if (sortBy.equals("IName")) {
return -f1.getName().compareToIgnoreCase(f2.getName());
} else if (sortBy.equals("Size")) {
ret = (int) (f1.getSize() - f2.getSize());
} else if (sortBy.equals("ISize")) {
ret = (int) (f2.getSize() - f1.getSize());
} else if (sortBy.equals("Date")) {
if (f1.getDate().indexOf("/") == 2 && f2.getDate().indexOf("/") > 2) {
return 1;
} else if (f1.getDate().indexOf("/") > 2 && f2.getDate().indexOf("/") == 2) {
return -1;
}
ret = f1.getDate().compareToIgnoreCase(f2.getDate());
} else if (sortBy.equals("IDate")) {
if (f1.getDate().indexOf("/") == 2 && f2.getDate().indexOf("/") > 2) {
return -1;
} else if (f1.getDate().indexOf("/") > 2 && f2.getDate().indexOf("/") == 2) {
return 1;
}
ret = -f1.getDate().compareToIgnoreCase(f2.getDate());
} else {
return f1.getName().compareToIgnoreCase(f2.getName());
}
if (ret == 0) {
ret = f1.getName().compareToIgnoreCase(f2.getName());
}
return ret;
}