org.apache.commons.io.filefilter
Class OrFileFilter

java.lang.Object
  |
  +--org.apache.commons.io.filefilter.AbstractFileFilter
        |
        +--org.apache.commons.io.filefilter.OrFileFilter
All Implemented Interfaces:
ConditionalFileFilter, FileFilter, FilenameFilter, IOFileFilter

public class OrFileFilter
extends AbstractFileFilter
implements ConditionalFileFilter

A 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.

Since:
Commons IO 1.0
Version:
$Revision: 490425 $ $Date: 2006-12-26 17:25:43 -0800 (Tue, 26 Dec 2006) $
Author:
Steven Caswell

Field Summary
private  List fileFilters
          The list of file filters.
 
Constructor Summary
OrFileFilter()
          Constructs a new instance of OrFileFilter.
OrFileFilter(IOFileFilter filter1, IOFileFilter filter2)
          Constructs a new file filter that ORs the result of two other filters.
OrFileFilter(List fileFilters)
          Constructs a new instance of OrFileFilter with the specified filters.
 
Method Summary
 boolean accept(File file)
          {@inheritDoc}
 boolean accept(File file, String name)
          {@inheritDoc}
 void addFileFilter(IOFileFilter ioFileFilter)
          {@inheritDoc}
 List getFileFilters()
          {@inheritDoc}
 boolean removeFileFilter(IOFileFilter ioFileFilter)
          {@inheritDoc}
 void setFileFilters(List fileFilters)
          {@inheritDoc}
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

fileFilters

private List fileFilters
The list of file filters.
Constructor Detail

OrFileFilter

public OrFileFilter()
Constructs a new instance of OrFileFilter.
Since:
Commons IO 1.1

OrFileFilter

public OrFileFilter(List fileFilters)
Constructs a new instance of OrFileFilter with the specified filters.
Parameters:
fileFilters - the file filters for this filter, copied, null ignored
Since:
Commons IO 1.1

OrFileFilter

public OrFileFilter(IOFileFilter filter1,
                    IOFileFilter filter2)
Constructs a new file filter that ORs the result of two other filters.
Parameters:
filter1 - the first filter, must not be null
filter2 - the second filter, must not be null
Throws:
IllegalArgumentException - if either filter is null
Method Detail

addFileFilter

public void addFileFilter(IOFileFilter ioFileFilter)
{@inheritDoc}
Specified by:
addFileFilter in interface ConditionalFileFilter
Following copied from interface: org.apache.commons.io.filefilter.ConditionalFileFilter
Parameters:
ioFileFilter - the filter to be added

getFileFilters

public List getFileFilters()
{@inheritDoc}
Specified by:
getFileFilters in interface ConditionalFileFilter
Following copied from interface: org.apache.commons.io.filefilter.ConditionalFileFilter
Returns:
the file filter list

removeFileFilter

public boolean removeFileFilter(IOFileFilter ioFileFilter)
{@inheritDoc}
Specified by:
removeFileFilter in interface ConditionalFileFilter
Following copied from interface: org.apache.commons.io.filefilter.ConditionalFileFilter
Parameters:
ioFileFilter - filter to be removed
Returns:
true if the filter was found in the list, false otherwise

setFileFilters

public void setFileFilters(List fileFilters)
{@inheritDoc}
Specified by:
setFileFilters in interface ConditionalFileFilter
Following copied from interface: org.apache.commons.io.filefilter.ConditionalFileFilter
Parameters:
fileFilters - the list of filters

accept

public boolean accept(File file)
{@inheritDoc}
Overrides:
accept in class AbstractFileFilter
Following copied from class: org.apache.commons.io.filefilter.AbstractFileFilter
Parameters:
file - the File to check
Returns:
true if this file matches the test

accept

public boolean accept(File file,
                      String name)
{@inheritDoc}
Overrides:
accept in class AbstractFileFilter
Following copied from class: org.apache.commons.io.filefilter.AbstractFileFilter
Parameters:
dir - the directory File to check
name - the filename within the directory to check
Returns:
true if this file matches the test