|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.armatiek.infofuze.stream.filesystem.filefilter.FileFilterUtils
public class FileFilterUtils
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.
Based on code from Apache Commons IO version 2.01.
The main difference is that this class filters objects that
implement FileIf
,
not File
.
Original authors Stephen Colebourne, Jeremias Maerki, Masato Tezuka,
Rahul Akolkar
Constructor Summary | |
---|---|
FileFilterUtils()
FileFilterUtils is not normally instantiated. |
Method Summary | |
---|---|
static IOFileFilter |
ageFileFilter(java.util.Date cutoffDate)
Returns a filter that returns true if the file was last modified after the specified cutoff date. |
static IOFileFilter |
ageFileFilter(java.util.Date cutoffDate,
boolean acceptOlder)
Returns a filter that filters files based on a cutoff date. |
static IOFileFilter |
ageFileFilter(FileIf cutoffReference)
Returns a filter that returns true if the file was last modified after the specified reference file. |
static IOFileFilter |
ageFileFilter(FileIf cutoffReference,
boolean acceptOlder)
Returns a filter that filters files based on a cutoff reference file. |
static IOFileFilter |
ageFileFilter(long cutoff)
Returns a filter that returns true if the file was last modified after the specified cutoff time. |
static IOFileFilter |
ageFileFilter(long cutoff,
boolean acceptOlder)
Returns a filter that filters files based on a cutoff time. |
static IOFileFilter |
and(IOFileFilter... filters)
Returns a filter that ANDs the specified filters. |
static IOFileFilter |
andFileFilter(IOFileFilter filter1,
IOFileFilter filter2)
Deprecated. use and(IOFileFilter...) |
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 |
fileFileFilter()
Returns a filter that checks if the file is a file (and not a directory). |
static FileIf[] |
filter(IOFileFilter filter,
FileIf... files)
Applies an IOFileFilter to the provided FileIf
objects. |
static FileIf[] |
filter(IOFileFilter filter,
java.lang.Iterable<FileIf> files)
Applies an IOFileFilter to the provided File
objects. |
static java.util.List<FileIf> |
filterList(IOFileFilter filter,
FileIf... files)
Applies an IOFileFilter to the provided File
objects. |
static java.util.List<FileIf> |
filterList(IOFileFilter filter,
java.lang.Iterable<FileIf> files)
Applies an IOFileFilter to the provided File
objects. |
static java.util.Set<FileIf> |
filterSet(IOFileFilter filter,
FileIf... files)
Applies an IOFileFilter to the provided File
objects. |
static java.util.Set<FileIf> |
filterSet(IOFileFilter filter,
java.lang.Iterable<FileIf> files)
Applies an IOFileFilter to the provided File
objects. |
static IOFileFilter |
makeCVSAware(IOFileFilter filter)
Decorates a filter to make it ignore CVS directories. |
static IOFileFilter |
makeDirectoryOnly(IOFileFilter filter)
Decorates a filter so that it only applies to directories and not to files. |
static IOFileFilter |
makeFileOnly(IOFileFilter filter)
Decorates a filter so that it only applies to files and not to directories. |
static IOFileFilter |
makeSVNAware(IOFileFilter filter)
Decorates a filter to make it ignore SVN directories. |
static IOFileFilter |
nameFileFilter(java.lang.String name)
Returns a filter that returns true if the filename matches the specified text. |
static IOFileFilter |
nameFileFilter(java.lang.String name,
org.apache.commons.io.IOCase caseSensitivity)
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 |
or(IOFileFilter... filters)
Returns a filter that ORs the specified filters. |
static IOFileFilter |
orFileFilter(IOFileFilter filter1,
IOFileFilter filter2)
Deprecated. use or(IOFileFilter...) |
static IOFileFilter |
prefixFileFilter(java.lang.String prefix)
Returns a filter that returns true if the filename starts with the specified text. |
static IOFileFilter |
prefixFileFilter(java.lang.String prefix,
org.apache.commons.io.IOCase caseSensitivity)
Returns a filter that returns true if the filename starts with the specified text. |
static IOFileFilter |
sizeFileFilter(long threshold)
Returns a filter that returns true if the file is bigger than a certain size. |
static IOFileFilter |
sizeFileFilter(long threshold,
boolean acceptLarger)
Returns a filter that filters based on file size. |
static IOFileFilter |
sizeRangeFileFilter(long minSizeInclusive,
long maxSizeInclusive)
Returns a filter that accepts files whose size is >= minimum size and <= maximum size. |
static IOFileFilter |
suffixFileFilter(java.lang.String suffix)
Returns a filter that returns true if the filename ends with the specified text. |
static IOFileFilter |
suffixFileFilter(java.lang.String suffix,
org.apache.commons.io.IOCase caseSensitivity)
Returns a filter that returns true if the filename ends with the specified text. |
static java.util.List<IOFileFilter> |
toList(IOFileFilter... filters)
Create a List of file filters. |
static IOFileFilter |
trueFileFilter()
Returns a filter that always returns true. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileFilterUtils()
Method Detail |
---|
public static FileIf[] filter(IOFileFilter filter, FileIf... files)
Applies an IOFileFilter
to the provided FileIf
objects. The resulting array is a subset of the original file list that
matches the provided filter.
The Set
returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ... Set<File> javaFiles = FileFilterUtils.filterSet(allFiles, FileFilterUtils.suffixFileFilter(".java"));
filter
- the filter to apply to the set of files.files
- the array of files to apply the filter to.
files
that is accepted by the
file filter.
java.lang.IllegalArgumentException
- if the filter is null
or files
contains a null
value.public static FileIf[] filter(IOFileFilter filter, java.lang.Iterable<FileIf> files)
Applies an IOFileFilter
to the provided File
objects. The resulting array is a subset of the original file list that
matches the provided filter.
The Set
returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ... Set<File> javaFiles = FileFilterUtils.filterSet(allFiles, FileFilterUtils.suffixFileFilter(".java"));
filter
- the filter to apply to the set of files.files
- the array of files to apply the filter to.
files
that is accepted by the
file filter.
java.lang.IllegalArgumentException
- if the filter is null
or files
contains a null
value.public static java.util.List<FileIf> filterList(IOFileFilter filter, java.lang.Iterable<FileIf> files)
Applies an IOFileFilter
to the provided File
objects. The resulting list is a subset of the original files that
matches the provided filter.
The List
returned by this method is not guaranteed to be thread safe.
List<File> filesAndDirectories = ... List<File> directories = FileFilterUtils.filterList(filesAndDirectories, FileFilterUtils.directoryFileFilter());
filter
- the filter to apply to each files in the list.files
- the collection of files to apply the filter to.
files
that is accepted by the
file filter.
java.lang.IllegalArgumentException
- if the filter is null
or files
contains a null
value.public static java.util.List<FileIf> filterList(IOFileFilter filter, FileIf... files)
Applies an IOFileFilter
to the provided File
objects. The resulting list is a subset of the original files that
matches the provided filter.
The List
returned by this method is not guaranteed to be thread safe.
List<File> filesAndDirectories = ... List<File> directories = FileFilterUtils.filterList(filesAndDirectories, FileFilterUtils.directoryFileFilter());
filter
- the filter to apply to each files in the list.files
- the collection of files to apply the filter to.
files
that is accepted by the
file filter.
java.lang.IllegalArgumentException
- if the filter is null
or files
contains a null
value.public static java.util.Set<FileIf> filterSet(IOFileFilter filter, FileIf... files)
Applies an IOFileFilter
to the provided File
objects. The resulting set is a subset of the original file list that
matches the provided filter.
The Set
returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ... Set<File> javaFiles = FileFilterUtils.filterSet(allFiles, FileFilterUtils.suffixFileFilter(".java"));
filter
- the filter to apply to the set of files.files
- the collection of files to apply the filter to.
files
that is accepted by the
file filter.
java.lang.IllegalArgumentException
- if the filter is null
or files
contains a null
value.public static java.util.Set<FileIf> filterSet(IOFileFilter filter, java.lang.Iterable<FileIf> files)
Applies an IOFileFilter
to the provided File
objects. The resulting set is a subset of the original file list that
matches the provided filter.
The Set
returned by this method is not guaranteed to be thread safe.
Set<File> allFiles = ... Set<File> javaFiles = FileFilterUtils.filterSet(allFiles, FileFilterUtils.suffixFileFilter(".java"));
filter
- the filter to apply to the set of files.files
- the collection of files to apply the filter to.
files
that is accepted by the
file filter.
java.lang.IllegalArgumentException
- if the filter is null
or files
contains a null
value.public static IOFileFilter prefixFileFilter(java.lang.String prefix)
prefix
- the filename prefix
PrefixFileFilter
public static IOFileFilter prefixFileFilter(java.lang.String prefix, org.apache.commons.io.IOCase caseSensitivity)
prefix
- the filename prefixcaseSensitivity
- how to handle case sensitivity, null means case-sensitive
PrefixFileFilter
public static IOFileFilter suffixFileFilter(java.lang.String suffix)
suffix
- the filename suffix
SuffixFileFilter
public static IOFileFilter suffixFileFilter(java.lang.String suffix, org.apache.commons.io.IOCase caseSensitivity)
suffix
- the filename suffixcaseSensitivity
- how to handle case sensitivity, null means case-sensitive
SuffixFileFilter
public static IOFileFilter nameFileFilter(java.lang.String name)
name
- the filename
NameFileFilter
public static IOFileFilter nameFileFilter(java.lang.String name, org.apache.commons.io.IOCase caseSensitivity)
name
- the filenamecaseSensitivity
- how to handle case sensitivity, null means case-sensitive
NameFileFilter
public static IOFileFilter directoryFileFilter()
DirectoryFileFilter.DIRECTORY
public static IOFileFilter fileFileFilter()
FileFileFilter.FILE
@Deprecated public static IOFileFilter andFileFilter(IOFileFilter filter1, IOFileFilter filter2)
and(IOFileFilter...)
filter1
- the first filterfilter2
- the second filter
and(IOFileFilter...)
,
AndFileFilter
@Deprecated public static IOFileFilter orFileFilter(IOFileFilter filter1, IOFileFilter filter2)
or(IOFileFilter...)
filter1
- the first filterfilter2
- the second filter
or(IOFileFilter...)
,
OrFileFilter
public static IOFileFilter and(IOFileFilter... filters)
filters
- the IOFileFilters that will be ANDed together.
java.lang.IllegalArgumentException
- if the filters are null or contain a
null value.AndFileFilter
public static IOFileFilter or(IOFileFilter... filters)
filters
- the IOFileFilters that will be ORed together.
java.lang.IllegalArgumentException
- if the filters are null or contain a
null value.OrFileFilter
public static java.util.List<IOFileFilter> toList(IOFileFilter... filters)
filters
- The file filters
java.lang.IllegalArgumentException
- if the filters are null or contain a
null value.public static IOFileFilter notFileFilter(IOFileFilter filter)
filter
- the filter to invert
NotFileFilter
public static IOFileFilter trueFileFilter()
TrueFileFilter.TRUE
public static IOFileFilter falseFileFilter()
FalseFileFilter.FALSE
public static IOFileFilter ageFileFilter(long cutoff)
cutoff
- the time threshold
AgeFileFilter
public static IOFileFilter ageFileFilter(long cutoff, boolean acceptOlder)
cutoff
- the time thresholdacceptOlder
- if true, older files get accepted, if false, newer
AgeFileFilter
public static IOFileFilter ageFileFilter(java.util.Date cutoffDate)
cutoffDate
- the time threshold
AgeFileFilter
public static IOFileFilter ageFileFilter(java.util.Date cutoffDate, boolean acceptOlder)
cutoffDate
- the time thresholdacceptOlder
- if true, older files get accepted, if false, newer
AgeFileFilter
public static IOFileFilter ageFileFilter(FileIf cutoffReference)
cutoffReference
- the file whose last modification
time is usesd as the threshold age of the files
AgeFileFilter
public static IOFileFilter ageFileFilter(FileIf cutoffReference, boolean acceptOlder)
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
AgeFileFilter
public static IOFileFilter sizeFileFilter(long threshold)
threshold
- the file size threshold
SizeFileFilter
public static IOFileFilter sizeFileFilter(long threshold, boolean acceptLarger)
threshold
- the file size thresholdacceptLarger
- if true, larger files get accepted, if false, smaller
SizeFileFilter
public static IOFileFilter sizeRangeFileFilter(long minSizeInclusive, long maxSizeInclusive)
minSizeInclusive
- the minimum file size (inclusive)maxSizeInclusive
- the maximum file size (inclusive)
SizeFileFilter
public static IOFileFilter makeCVSAware(IOFileFilter filter)
null
will return a filter that accepts everything
except CVS directories.
filter
- the filter to decorate, null means an unrestricted filter
public static IOFileFilter makeSVNAware(IOFileFilter filter)
null
will return a filter that accepts everything
except SVN directories.
filter
- the filter to decorate, null means an unrestricted filter
public static IOFileFilter makeDirectoryOnly(IOFileFilter filter)
filter
- the filter to decorate, null means an unrestricted filter
DirectoryFileFilter.DIRECTORY
public static IOFileFilter makeFileOnly(IOFileFilter filter)
filter
- the filter to decorate, null means an unrestricted filter
FileFileFilter.FILE
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |