FileDocCategorySizeDatePackage
DelegateFileFilter.javaAPI DocAndroid 1.5 API3364Wed May 06 22:42:46 BST 2009org.apache.commons.io.filefilter

DelegateFileFilter

public class DelegateFileFilter extends AbstractFileFilter implements Serializable
This class turns a Java FileFilter or FilenameFilter into an IO FileFilter.
since
Commons IO 1.0
version
$Revision: 591058 $ $Date: 2007-11-01 15:47:05 +0000 (Thu, 01 Nov 2007) $
author
Stephen Colebourne

Fields Summary
private final FilenameFilter
filenameFilter
The Filename filter
private final FileFilter
fileFilter
The File filter
Constructors Summary
public DelegateFileFilter(FilenameFilter filter)
Constructs a delegate file filter around an existing FilenameFilter.

param
filter the filter to decorate

        if (filter == null) {
            throw new IllegalArgumentException("The FilenameFilter must not be null");
        }
        this.filenameFilter = filter;
        this.fileFilter = null;
    
public DelegateFileFilter(FileFilter filter)
Constructs a delegate file filter around an existing FileFilter.

param
filter the filter to decorate

        if (filter == null) {
            throw new IllegalArgumentException("The FileFilter must not be null");
        }
        this.fileFilter = filter;
        this.filenameFilter = null;
    
Methods Summary
public booleanaccept(java.io.File file)
Checks the filter.

param
file the file to check
return
true if the filter matches

        if (fileFilter != null) {
            return fileFilter.accept(file);
        } else {
            return super.accept(file);
        }
    
public booleanaccept(java.io.File dir, java.lang.String name)
Checks the filter.

param
dir the directory
param
name the filename in the directory
return
true if the filter matches

        if (filenameFilter != null) {
            return filenameFilter.accept(dir, name);
        } else {
            return super.accept(dir, name);
        }
    
public java.lang.StringtoString()
Provide a String representaion of this file filter.

return
a String representaion

        String delegate = (fileFilter != null ? fileFilter.toString() : filenameFilter.toString()); 
        return super.toString() + "(" + delegate + ")";