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.
ageFileFilter
public static IOFileFilter ageFileFilter(Date cutoffDate)
Returns a filter that returns true if the file was last modified after
the specified cutoff date.
cutoffDate
- the time threshold
- an appropriately configured age file filter
ageFileFilter
public static IOFileFilter ageFileFilter(Date cutoffDate,
boolean acceptOlder)
Returns a filter that filters files based on a cutoff date.
cutoffDate
- the time thresholdacceptOlder
- if true, older files get accepted, if false, newer
- an appropriately configured age file filter
ageFileFilter
public static IOFileFilter ageFileFilter(File cutoffReference)
Returns a filter that returns true if the file was last modified after
the specified reference file.
cutoffReference
- the file whose last modification
time is usesd as the threshold age of the files
- an appropriately configured age file filter
ageFileFilter
public static IOFileFilter ageFileFilter(File cutoffReference,
boolean acceptOlder)
Returns a filter that filters files based on a cutoff reference file.
cutoffReference
- the file whose last modification
time is usesd as the threshold age of the filesacceptOlder
- if true, older files get accepted, if false, newer
- an appropriately configured age file filter
ageFileFilter
public static IOFileFilter ageFileFilter(long cutoff)
Returns a filter that returns true if the file was last modified after
the specified cutoff time.
cutoff
- the time threshold
- an appropriately configured age file filter
ageFileFilter
public static IOFileFilter ageFileFilter(long cutoff,
boolean acceptOlder)
Returns a filter that filters files based on a cutoff time.
cutoff
- the time thresholdacceptOlder
- if true, older files get accepted, if false, newer
- an appropriately configured age file filter
andFileFilter
public static IOFileFilter andFileFilter(IOFileFilter filter1,
IOFileFilter filter2)
Returns a filter that ANDs the two specified filters.
filter1
- the first filterfilter2
- the second filter
- a filter that ANDs the two specified filters
asFileFilter
public static IOFileFilter asFileFilter(FileFilter filter)
Returns an IOFileFilter
that wraps the
FileFilter
instance.
filter
- the filter to be wrapped
- a new filter that implements IOFileFilter
asFileFilter
public static IOFileFilter asFileFilter(FilenameFilter filter)
Returns an IOFileFilter
that wraps the
FilenameFilter
instance.
filter
- the filter to be wrapped
- a new filter that implements IOFileFilter
directoryFileFilter
public static IOFileFilter directoryFileFilter()
Returns a filter that checks if the file is a directory.
falseFileFilter
public static IOFileFilter falseFileFilter()
Returns a filter that always returns false.
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.
filter
- IOFileFilter to wrap, null if a new IOFileFilter
should be created
- the requested (combined) filter
- 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.
filter
- IOFileFilter to wrap, null if a new IOFileFilter
should be created
- the requested (combined) filter
nameFileFilter
public static IOFileFilter nameFileFilter(String name)
Returns a filter that returns true if the filename matches the specified text.
notFileFilter
public static IOFileFilter notFileFilter(IOFileFilter filter)
Returns a filter that NOTs the specified filter.
filter
- the filter to invert
- a filter that NOTs the specified filter
orFileFilter
public static IOFileFilter orFileFilter(IOFileFilter filter1,
IOFileFilter filter2)
Returns a filter that ORs the two specified filters.
filter1
- the first filterfilter2
- the second filter
- a filter that ORs the two specified filters
prefixFileFilter
public static IOFileFilter prefixFileFilter(String prefix)
Returns a filter that returns true if the filename starts with the specified text.
prefix
- the filename prefix
sizeFileFilter
public static IOFileFilter sizeFileFilter(long threshold)
Returns a filter that returns true if the file is bigger than a certain size.
threshold
- the file size threshold
- an appropriately configured SizeFileFilter
sizeFileFilter
public static IOFileFilter sizeFileFilter(long threshold,
boolean acceptLarger)
Returns a filter that filters based on file size.
threshold
- the file size thresholdacceptLarger
- if true, larger files get accepted, if false, smaller
- an appropriately configured SizeFileFilter
suffixFileFilter
public static IOFileFilter suffixFileFilter(String suffix)
Returns a filter that returns true if the filename ends with the specified text.
suffix
- the filename suffix
trueFileFilter
public static IOFileFilter trueFileFilter()
Returns a filter that always returns true.