org.apache.commons.io.filefilter
Class FileFilterUtils

java.lang.Object
  extended by org.apache.commons.io.filefilter.FileFilterUtils

public class FileFilterUtils
extends Object

Useful utilities for working with file filters. It provides access to all file filter implementations in this package so you don't have to import every class you use.

Since:
Commons IO 1.0
Version:
$Id: FileFilterUtils.java 201606 2005-06-24 12:35:32Z jeremias $

Constructor Summary
FileFilterUtils()
          FileFilterUtils is not normally instantiated.
 
Method Summary
static IOFileFilter andFileFilter(IOFileFilter filter1, IOFileFilter filter2)
          Returns a filter that ANDs the two specified filters.
static IOFileFilter asFileFilter(FileFilter filter)
          Returns an IOFileFilter that wraps the FileFilter instance.
static IOFileFilter asFileFilter(FilenameFilter filter)
          Returns an IOFileFilter that wraps the FilenameFilter instance.
static IOFileFilter directoryFileFilter()
          Returns a filter that checks if the file is a directory.
static IOFileFilter falseFileFilter()
          Returns a filter that always returns false.
static IOFileFilter makeCVSAware(IOFileFilter filter)
          Returns an IOFileFilter that ignores CVS directories.
static IOFileFilter makeSVNAware(IOFileFilter filter)
          Returns an IOFileFilter that ignores SVN directories.
static IOFileFilter nameFileFilter(String name)
          Returns a filter that returns true if the filename matches the specified text.
static IOFileFilter notFileFilter(IOFileFilter filter)
          Returns a filter that NOTs the specified filter.
static IOFileFilter orFileFilter(IOFileFilter filter1, IOFileFilter filter2)
          Returns a filter that ORs the two specified filters.
static IOFileFilter prefixFileFilter(String prefix)
          Returns a filter that returns true if the filename starts with the specified text.
static IOFileFilter suffixFileFilter(String suffix)
          Returns a filter that returns true if the filename ends with the specified text.
static IOFileFilter trueFileFilter()
          Returns a filter that always returns true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileFilterUtils

public FileFilterUtils()
FileFilterUtils is not normally instantiated.

Method Detail

prefixFileFilter

public static IOFileFilter prefixFileFilter(String prefix)
Returns a filter that returns true if the filename starts with the specified text.

Parameters:
prefix - the filename prefix
Returns:
a prefix checking filter

suffixFileFilter

public static IOFileFilter suffixFileFilter(String suffix)
Returns a filter that returns true if the filename ends with the specified text.

Parameters:
suffix - the filename suffix
Returns:
a suffix checking filter

nameFileFilter

public static IOFileFilter nameFileFilter(String name)
Returns a filter that returns true if the filename matches the specified text.

Parameters:
name - the filename
Returns:
a name checking filter

directoryFileFilter

public static IOFileFilter directoryFileFilter()
Returns a filter that checks if the file is a directory.

Returns:
directory file filter

andFileFilter

public static IOFileFilter andFileFilter(IOFileFilter filter1,
                                         IOFileFilter filter2)
Returns a filter that ANDs the two specified filters.

Parameters:
filter1 - the first filter
filter2 - the second filter
Returns:
a filter that ANDs the two specified filters

orFileFilter

public static IOFileFilter orFileFilter(IOFileFilter filter1,
                                        IOFileFilter filter2)
Returns a filter that ORs the two specified filters.

Parameters:
filter1 - the first filter
filter2 - the second filter
Returns:
a filter that ORs the two specified filters

notFileFilter

public static IOFileFilter notFileFilter(IOFileFilter filter)
Returns a filter that NOTs the specified filter.

Parameters:
filter - the filter to invert
Returns:
a filter that NOTs the specified filter

trueFileFilter

public static IOFileFilter trueFileFilter()
Returns a filter that always returns true.

Returns:
a true filter

falseFileFilter

public static IOFileFilter falseFileFilter()
Returns a filter that always returns false.

Returns:
a false filter

asFileFilter

public static IOFileFilter asFileFilter(FileFilter filter)
Returns an IOFileFilter that wraps the FileFilter instance.

Parameters:
filter - the filter to be wrapped
Returns:
a new filter that implements IOFileFilter

asFileFilter

public static IOFileFilter asFileFilter(FilenameFilter filter)
Returns an IOFileFilter that wraps the FilenameFilter instance.

Parameters:
filter - the filter to be wrapped
Returns:
a new filter that implements IOFileFilter

makeCVSAware

public static IOFileFilter makeCVSAware(IOFileFilter filter)
Returns an IOFileFilter that ignores CVS directories. You may optionally pass in an existing IOFileFilter in which case it is extended to exclude CVS directories.

Parameters:
filter - IOFileFilter to wrap, null if a new IOFileFilter should be created
Returns:
the requested (combined) filter
Since:
1.1 (method existed but had bug in 1.0)

makeSVNAware

public static IOFileFilter makeSVNAware(IOFileFilter filter)
Returns an IOFileFilter that ignores SVN directories. You may optionally pass in an existing IOFileFilter in which case it is extended to exclude SVN directories.

Parameters:
filter - IOFileFilter to wrap, null if a new IOFileFilter should be created
Returns:
the requested (combined) filter
Since:
1.1


Copyright © 2002-2005 The Apache Software Foundation. All Rights Reserved.