Top Description Fields Constructors Methods
org.apache.commons.io.filefilter

public Class AndFileFilter

extends AbstractFileFilter
implements ConditionalFileFilter
Class Inheritance
All Implemented Interfaces
org.apache.commons.io.filefilter.ConditionalFileFilter
Imports
java.io.File, java.util.ArrayList, .Collections, .Iterator, .List

A 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.
Author
Steven Caswell
Since
Commons IO 1.0
Version
$Revision: 490425 $ $Date: 2006-12-27 02:25:43 +0100 (Mi, 27 Dez 2006) $

Field Summary

Modifier and TypeField and Description
private List<E>
fileFilters

The list of file filters.

Constructor Summary

AccessConstructor and Description
public
AndFileFilter()

Constructs a new instance of AndFileFilter.

public
AndFileFilter(final List<E>
a List of IOFileFilter instances, copied, null ignored
fileFilters
)

Constructs a new instance of AndFileFilter with the specified list of filters.

public
AndFileFilter(IOFileFilter
the first filter, must not be null
filter1
,
IOFileFilter
the second filter, must not be null
filter2
)

Constructs a new file filter that ANDs the result of two other filters.

Method Summary

Modifier and TypeMethod and Description
public boolean
accept(final File
the File to check
file
)

Overrides org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Implements org.apache.commons.io.filefilter.IOFileFilter.accept.

Checks to see if the File should be accepted by this filter.
public boolean
accept(final File
the directory File to check
file
,
final String
the filename within the directory to check
name
)

Overrides org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Implements org.apache.commons.io.filefilter.IOFileFilter.accept.

Checks to see if the File should be accepted by this filter.
public void
addFileFilter(final IOFileFilter
the filter to be added
ioFileFilter
)

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.addFileFilter.

Adds the specified file filter to the list of file filters at the end of the list.
public List<E>
getFileFilters()

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.getFileFilters.

Returns this conditional file filter's list of file filters.
public boolean
removeFileFilter(final IOFileFilter
filter to be removed
ioFileFilter
)

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.removeFileFilter.

Removes the specified file filter.
public void
setFileFilters(final List<E>
the list of filters
fileFilters
)

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.setFileFilters.

Sets the list of file filters, replacing any previously configured file filters on this filter.

Field Detail

fileFiltersback to summary
private List<E> fileFilters

The list of file filters.

Constructor Detail

AndFileFilterback to summary
public AndFileFilter()

Constructs a new instance of AndFileFilter.

Since
Commons IO 1.1
AndFileFilterback to summary
public AndFileFilter(final List<E> fileFilters)

Constructs a new instance of AndFileFilter with the specified list of filters.

Parameters
fileFilters:List<E>

a List of IOFileFilter instances, copied, null ignored

Since
Commons IO 1.1
AndFileFilterback to summary
public AndFileFilter(IOFileFilter filter1, IOFileFilter filter2)

Constructs a new file filter that ANDs the result of two other filters.

Parameters
filter1:IOFileFilter

the first filter, must not be null

filter2:IOFileFilter

the second filter, must not be null

Exceptions
IllegalArgumentException:
if either filter is null

Method Detail

acceptback to summary
public boolean accept(final File file)

Overrides org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Implements org.apache.commons.io.filefilter.IOFileFilter.accept.

Doc from org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Checks to see if the File should be accepted by this filter.

Parameters
file:File

the File to check

Returns:boolean

true if this file matches the test

acceptback to summary
public boolean accept(final File file, final String name)

Overrides org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Implements org.apache.commons.io.filefilter.IOFileFilter.accept.

Doc from org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Checks to see if the File should be accepted by this filter.

Parameters
file:File

the directory File to check

name:String

the filename within the directory to check

Returns:boolean

true if this file matches the test

addFileFilterback to summary
public void addFileFilter(final IOFileFilter ioFileFilter)

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.addFileFilter.

Doc from org.apache.commons.io.filefilter.ConditionalFileFilter.addFileFilter.

Adds the specified file filter to the list of file filters at the end of the list.

Parameters
ioFileFilter:IOFileFilter

the filter to be added

getFileFiltersback to summary
public List<E> getFileFilters()

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.getFileFilters.

Doc from org.apache.commons.io.filefilter.ConditionalFileFilter.getFileFilters.

Returns this conditional file filter's list of file filters.

Returns:List<E>

the file filter list

removeFileFilterback to summary
public boolean removeFileFilter(final IOFileFilter ioFileFilter)

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.removeFileFilter.

Doc from org.apache.commons.io.filefilter.ConditionalFileFilter.removeFileFilter.

Removes the specified file filter.

Parameters
ioFileFilter:IOFileFilter

filter to be removed

Returns:boolean

true if the filter was found in the list, false otherwise

setFileFiltersback to summary
public void setFileFilters(final List<E> fileFilters)

Implements org.apache.commons.io.filefilter.ConditionalFileFilter.setFileFilters.

Doc from org.apache.commons.io.filefilter.ConditionalFileFilter.setFileFilters.

Sets the list of file filters, replacing any previously configured file filters on this filter.

Parameters
fileFilters:List<E>

the list of filters