}
public Result[] filter(Result[] results) {
List<Result> filteredResults = new ArrayList<Result>(results.length);
for(int i = 0 ; i < results.length ; i++) {
Result result = results[i];
String name = result.getName();
//Results need a name, or they are by default invalid
if(name == null) {
continue;
}
name = name.toLowerCase();
boolean valid = true;
for(int j = 0 ; j < textFilters.length ; j++) {
//If one of the text filters do not match, let's not keep testing the others
// and mark the result as not valid
if(name.indexOf(textFilters[j]) == -1) {
// double check against reg-expr if exists
Pattern p = textFilterPatterns[j];
if ( p == null || !p.matcher( name ).find()){
valid = false;
break;
}
}
}
//if invalid after name check, let's get to the next result
if(!valid) {
continue;
}
for(int j = 0 ; j < excludeTextFilters.length ; j++) {
//If one of the text filters do not match, let's not keep testing the others
// and mark the result as not valid
if(name.indexOf(excludeTextFilters[j]) != -1) {
valid = false;
break;
}else{
Pattern p = excludeTextFilterPatterns[j];
if ( p != null && p.matcher( name ).find()){
valid = false;
break;
}
}
}
//if invalid after name check, let's get to the next result
if(!valid) {
continue;
}
long size = result.getSize();
if(minSize > -1) {
if(minSize > size) {
continue;
}
}
if(maxSize > -1) {
if(maxSize < size) {
continue;
}
}
if(minSeeds > -1) {
if(minSeeds < result.getNbSeeds()) {
continue;
}
}
if(categoryFilter != null) {
String category = result.getCategory();
if(category == null || !category.equalsIgnoreCase(categoryFilter)) {
continue;
}
}