AndFileFilterpublic class AndFileFilter extends AbstractFileFilter implements Serializable, ConditionalFileFilterA {@link java.io.FileFilter} providing conditional AND logic across a list of
file filters. This filter returns true if all filters in the
list return true . Otherwise, it returns false .
Checking of the file filter list stops when the first filter returns
false . |
Fields Summary |
---|
private List | fileFiltersThe list of file filters. |
Constructors Summary |
---|
public AndFileFilter()Constructs a new instance of AndFileFilter .
this.fileFilters = new ArrayList();
| public AndFileFilter(List fileFilters)Constructs a new instance of AndFileFilter
with the specified list of filters.
if (fileFilters == null) {
this.fileFilters = new ArrayList();
} else {
this.fileFilters = new ArrayList(fileFilters);
}
| public AndFileFilter(IOFileFilter filter1, IOFileFilter filter2)Constructs a new file filter that ANDs 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}
if (this.fileFilters.size() == 0) {
return false;
}
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
IOFileFilter fileFilter = (IOFileFilter) iter.next();
if (!fileFilter.accept(file)) {
return false;
}
}
return true;
| public boolean | accept(java.io.File file, java.lang.String name){@inheritDoc}
if (this.fileFilters.size() == 0) {
return false;
}
for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) {
IOFileFilter fileFilter = (IOFileFilter) iter.next();
if (!fileFilter.accept(file, name)) {
return false;
}
}
return true;
| 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 = new ArrayList(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();
|
|