}
public Object fileTest(File f) {
if (f.isDirectory()) {
for(NameValidationPattern nvp: dirTestPatterns) {
RenameDetails det = nvp.checkFile(f);
if (det.status == RenameStatus.NEXT) continue;
return det;
}
return new RenameDetails(RenameStatus.DIRECTORY, null, null);
}
for(NameValidationPattern nvp: testPatterns) {
RenameDetails det = nvp.checkFile(f);
if (det.status == RenameStatus.NEXT) continue;
File newFile = det.getFile();
if (newFile != null) {
if (valPatt.checkFile(newFile).status != RenameStatus.VALID) {
det.status = RenameStatus.NEW_NAME_INVALID;
return det;
}
if (f.equals(newFile)) {
} else if (newFile.exists()) {
det.status = RenameStatus.RENAME_FILE_EXISTS;
return det;
}
if (allowRename) {
return renameFile(f, det);
}
}
return det;
}
return new RenameDetails(RenameStatus.PARSE_ERR, null, "");
}