public final class AndFilenameFilter
extends java.lang.Object
implements java.io.FilenameFilter
An AndFilenameFilter logically ANDs other
java.io.FilenameFilter objects. When its
accept()
method is called, the AndFilenameFilter
object passes the file through the contained filters. The file is only
accepted if it is accepted by all contained filters. This class
conceptually provides a logical "AND" operator for file filters.
The contained filters are applied in the order they were added to the
AndFilenameFilter object. This class's accept()
method stops looping over the contained filters as soon as it encounters
one whose accept() method returns false (implementing
a "short-circuited AND" operation.)
FilenameFilter
,
OrFilenameFilter
,
NotFilenameFilter
,
RegexFilenameFilter
,
AndFileFilter
Constructor and Description |
---|
AndFilenameFilter()
Construct a new AndFilenameFilter with no contained filters.
|
AndFilenameFilter(java.io.FilenameFilter... filters)
Construct a new AndFilenameFilter with a set of contained
filters.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File dir,
java.lang.String name)
Determine whether a file is to be accepted or not, based on the
contained filters.
|
AndFilenameFilter |
addFilter(java.io.FilenameFilter filter)
Add a filter to the set of contained filters.
|
void |
removeFilter(java.io.FilenameFilter filter)
Remove a filter from the set of contained filters.
|
public AndFilenameFilter()
public AndFilenameFilter(java.io.FilenameFilter... filters)
addFilter()
method.filters
- filters to usepublic AndFilenameFilter addFilter(java.io.FilenameFilter filter)
filter
- the FilenameFilter to add.removeFilter(java.io.FilenameFilter)
public void removeFilter(java.io.FilenameFilter filter)
filter
- the FilenameFilter to remove.addFilter(java.io.FilenameFilter)
public boolean accept(java.io.File dir, java.lang.String name)
Determine whether a file is to be accepted or not, based on the contained filters. The file is accepted if any one of the contained filters accepts it. This method stops looping over the contained filters as soon as it encounters one whose accept() method returns false (implementing a "short-circuited AND" operation.)
If the set of contained filters is empty, then this method returns true.
accept
in interface java.io.FilenameFilter
dir
- The directory containing the file.name
- the file name