Package ptolemy.util
Class RecursiveFileFilter
- java.lang.Object
-
- ptolemy.util.RecursiveFileFilter
-
- All Implemented Interfaces:
java.io.FilenameFilter
public class RecursiveFileFilter extends java.lang.Object implements java.io.FilenameFilter
A file name filter that can recursively list files in a directory, including those in subdirectories. When a file name referring to a directory is found, this filter lists the files within that directory again with a new filter in this class.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Thomas Huining Feng, Christopher Brooks
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Constructor Summary
Constructors Constructor Description RecursiveFileFilter(boolean recursive, boolean includeFiles, boolean includeDirectories)
Construct a recursive file filter.RecursiveFileFilter(boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter)
Construct a recursive file filter.RecursiveFileFilter(boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter, boolean escape)
Construct a recursive file filter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(java.io.File dir, java.lang.String name)
Return whether the file or directory name in the given directory is accepted.java.util.List<java.io.File>
getFiles()
Return the list of all files and directories after the filtering.static java.io.File[]
listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter)
List all the files and directories within the given directory.static java.io.File[]
listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter, boolean escape)
List all the files and directories within the given directory.static java.io.File[]
listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, java.lang.String fileFilter)
List all the files and directories within the given directory.static java.io.File[]
listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, java.lang.String fileFilter, boolean escape)
List all the files and directories within the given directory.
-
-
-
Constructor Detail
-
RecursiveFileFilter
public RecursiveFileFilter(boolean recursive, boolean includeFiles, boolean includeDirectories)
Construct a recursive file filter.- Parameters:
recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.
-
RecursiveFileFilter
public RecursiveFileFilter(boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter)
Construct a recursive file filter. This method has four parameters to control whether files and directories are included. Not all combinations make sense, but are required because this code was refactored from two classes that had similar functionality.- Parameters:
recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.filesOnly
- Whether only files should be includeddirectoriesOnly
- Whether only directories should be included.fileFilter
- The filter (with ? and * as wildcards) to filter the accepted file names.
-
RecursiveFileFilter
public RecursiveFileFilter(boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter, boolean escape)
Construct a recursive file filter. This method has four parameters to control whether files and directories are included. Not all combinations make sense, but are required because this code was refactored from two classes that had similar functionality.- Parameters:
recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.filesOnly
- Whether only files should be includeddirectoriesOnly
- Whether only directories should be included.fileFilter
- The filter (with ? and * as wildcards) to filter the accepted file names.escape
- True if a string with ? and * as wildcards is to be converted into a Java regular expression. The DirectoryListing actor calls this with a false value.
-
-
Method Detail
-
accept
public boolean accept(java.io.File dir, java.lang.String name)
Return whether the file or directory name in the given directory is accepted.- Specified by:
accept
in interfacejava.io.FilenameFilter
- Parameters:
dir
- The directory. If directory is null, then it is likely that this method is being called to accept a URL and no File object is instantiated. If directory is not null, then a File object is instantiated.name
- The file or directory name within the given directory.- Returns:
- Whether the name is accepted.
-
getFiles
public java.util.List<java.io.File> getFiles()
Return the list of all files and directories after the filtering. This must be called after all the directories are traversed.- Returns:
- The list of files and directories.
-
listFiles
public static java.io.File[] listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, java.lang.String fileFilter)
List all the files and directories within the given directory. This method has four parameters to control whether files and directories are included. Not all combinations make sense.- Parameters:
directory
- The directory.recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.fileFilter
- The filter (with ? and * as wildcards) to filter the accepted file names.- Returns:
- The array of all the files and directories found.
-
listFiles
public static java.io.File[] listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, java.lang.String fileFilter, boolean escape)
List all the files and directories within the given directory. This method has four parameters to control whether files and directories are included. Not all combinations make sense.- Parameters:
directory
- The directory.recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.fileFilter
- The filter (with ? and * as wildcards) to filter the accepted file names.escape
- True if a string with ? and * as wildcards is to be converted into a Java regular expression. The DirectoryListing actor calls this with a false value.- Returns:
- The array of all the files and directories found.
-
listFiles
public static java.io.File[] listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter)
List all the files and directories within the given directory. This method has four parameters to control whether files and directories are included. Not all combinations make sense.- Parameters:
directory
- The directory.recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.filesOnly
- Whether only files should be includeddirectoriesOnly
- Whether only directories should be included.fileFilter
- The filter (with ? and * as wildcards) to filter the accepted file names.- Returns:
- The array of all the files and directories found.
-
listFiles
public static java.io.File[] listFiles(java.io.File directory, boolean recursive, boolean includeFiles, boolean includeDirectories, boolean filesOnly, boolean directoriesOnly, java.lang.String fileFilter, boolean escape)
List all the files and directories within the given directory. This method has four parameters to control whether files and directories are included. Not all combinations make sense.- Parameters:
directory
- The directory.recursive
- Whether the filter should recursively list subdirectories.includeFiles
- Whether files should be included.includeDirectories
- Whether directories should be included.filesOnly
- Whether only files should be includeddirectoriesOnly
- Whether only directories should be included.fileFilter
- The filter (with ? and * as wildcards) to filter the accepted file names.escape
- True if a string with ? and * as wildcards is to be converted into a Java regular expression. The DirectoryListing actor calls this with a false value.- Returns:
- The array of all the files and directories found.
-
-