OrFileFilterpublic class OrFileFilter extends AbstractFileFilter implements Serializable, ConditionalFileFilterA {@link java.io.FileFilter} providing conditional OR logic across a list of
file filters. This filter returns true if any filters in the
list return true . Otherwise, it returns false .
Checking of the file filter list stops when the first filter returns
true . |
Fields Summary |
---|
private List | fileFiltersThe list of file filters. |
Constructors Summary |
---|
public OrFileFilter()Constructs a new instance of OrFileFilter .
this.fileFilters = new ArrayList();
| public OrFileFilter(List fileFilters)Constructs a new instance of OrFileFilter
with the specified filters.
if (fileFilters == null) {
this.fileFilters = new ArrayList();
} else {
this.fileFilters = new ArrayList(fileFilters);
}
| public OrFileFilter(IOFileFilter filter1, IOFileFilter filter2)Constructs a new file filter that ORs the result of two other filters.
if (filter1 == null || filter2 == null) {
throw new IllegalArgumentException("The filters must not be null");
}
this.fileFilters = new ArrayList();
addFileFilter(filter1);
addFileFilter(filter2);
|
Methods Summary |
---|
public boolean | accept(java.io.File file){@inheritDoc}
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
IOFileFilter fileFilter = (IOFileFilter) iter.next();
if (fileFilter.accept(file)) {
return true;
}
}
return false;
| public boolean | accept(java.io.File file, java.lang.String name){@inheritDoc}
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
IOFileFilter fileFilter = (IOFileFilter) iter.next();
if (fileFilter.accept(file, name)) {
return true;
}
}
return false;
| public void | addFileFilter(org.apache.commons.io.filefilter.IOFileFilter ioFileFilter){@inheritDoc}
this.fileFilters.add(ioFileFilter);
| public java.util.List | getFileFilters(){@inheritDoc}
return Collections.unmodifiableList(this.fileFilters);
| public boolean | removeFileFilter(org.apache.commons.io.filefilter.IOFileFilter ioFileFilter){@inheritDoc}
return this.fileFilters.remove(ioFileFilter);
| public void | setFileFilters(java.util.List fileFilters){@inheritDoc}
this.fileFilters = fileFilters;
| public java.lang.String | toString()Provide a String representaion of this file filter.
StringBuffer buffer = new StringBuffer();
buffer.append(super.toString());
buffer.append("(");
if (fileFilters != null) {
for (int i = 0; i < fileFilters.size(); i++) {
if (i > 0) {
buffer.append(",");
}
Object filter = fileFilters.get(i);
buffer.append(filter == null ? "null" : filter.toString());
}
}
buffer.append(")");
return buffer.toString();
|
|