org.clapper.util.io
Class OrFilenameFilter
- java.lang.Object
-
- org.clapper.util.io.OrFilenameFilter
-
- All Implemented Interfaces:
- java.io.FilenameFilter
public final class OrFilenameFilter extends java.lang.Object implements java.io.FilenameFilterAn OrFilenameFilter logically ORs other java.io.FilenameFilter objects. When its
accept()method is called, the OrFilenameFilter object passes the file through the contained filters. The file is accepted if it is accepted by any of the contained filters. This class conceptually provides a logical "OR" operator for file filters.The contained filters are applied in the order they were added to the OrFilenameFilter object. This class's
accept()method stops looping over the contained filters as soon as it encounters one whose accept() method returns true (implementing a "short-circuited OR" operation.)- See Also:
FilenameFilter,AndFilenameFilter,NotFilenameFilter,OrFilenameFilter,RegexFilenameFilter
-
-
Constructor Summary
Constructors Constructor and Description OrFilenameFilter()Construct a new OrFilenameFilter with no contained filters.OrFilenameFilter(java.io.FilenameFilter... filters)Construct a new OrFilenameFilter with two contained filters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanaccept(java.io.File dir, java.lang.String name)Determine whether a file is to be accepted or not, based on the contained filters.OrFilenameFilteraddFilter(java.io.FilenameFilter filter)Add a filter to the set of contained filters.voidremoveFilter(java.io.FilenameFilter filter)Remove a filter from the set of contained filters.
-
-
-
Constructor Detail
-
OrFilenameFilter
public OrFilenameFilter()
Construct a new OrFilenameFilter with no contained filters.
-
OrFilenameFilter
public OrFilenameFilter(java.io.FilenameFilter... filters)
Construct a new OrFilenameFilter with two contained filters. Additional filters may be added later, via calls to theaddFilter()method.- Parameters:
filters- filters to add
-
-
Method Detail
-
addFilter
public OrFilenameFilter addFilter(java.io.FilenameFilter filter)
Add a filter to the set of contained filters.- Parameters:
filter- the FilenameFilter to add.- Returns:
- this object, to permit chained calls.
- See Also:
removeFilter(java.io.FilenameFilter)
-
removeFilter
public void removeFilter(java.io.FilenameFilter filter)
Remove a filter from the set of contained filters.- Parameters:
filter- the FilenameFilter to remove.- See Also:
addFilter(java.io.FilenameFilter)
-
accept
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 true (implementing a "short-circuited OR" operation.)If the set of contained filters is empty, then this method returns true.
- Specified by:
acceptin interfacejava.io.FilenameFilter- Parameters:
dir- The directory containing the file.name- the file name- Returns:
- true if the file matches, false if it doesn't
-
-
DMelt 3.0 © DataMelt by jWork.ORG