Class SearchDirectory
Searches a directory for files whose paths match a particular predicate.
By default, the search does not occur recursively, but the bean-property
recursive
enables this.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
If non-negative the max depth of directories.boolean
If true, continues when a directory-access-error occurs (logging it), otherwise throws an exception.boolean
If true, case is ignored in the pattern matching.boolean
If true the search is applied recursively over sub-directories.matchingFilesForDirectory
(Path directory, InputManagerParameters parameters) The matching files for this provider that exist in a particular directory.void
setAcceptDirectoryErrors
(boolean acceptDirectoryErrors) If true, continues when a directory-access-error occurs (logging it), otherwise throws an exception.void
setFileFilterAndDirectory
(Path combinedFileFilter) Sets both the directory and the glob from a string containing both.void
setIgnoreHidden
(boolean ignoreHidden) If true, case is ignored in the pattern matching.void
setMatcher
(FilePathMatcher matcher) void
setMaxDirectoryDepth
(int maxDirectoryDepth) If non-negative the max depth of directories.void
setRecursive
(boolean recursive) If true the search is applied recursively over sub-directories.Methods inherited from class org.anchoranalysis.io.input.bean.files.FilesProviderWithDirectoryString
getDirectory, getDirectoryAsPath, isLocalized, setDirectory, setLocalized
Methods inherited from class org.anchoranalysis.io.input.bean.files.FilesProviderWithDirectory
create, getDirectoryAsPathEnsureAbsolute, rootDirectory
Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
SearchDirectory
Create for a specific directory.- Parameters:
directory
- the directory to search.
-
SearchDirectory
public SearchDirectory()
-
-
Method Details
-
matchingFilesForDirectory
public List<File> matchingFilesForDirectory(Path directory, InputManagerParameters parameters) throws FilesProviderException Description copied from class:FilesProviderWithDirectory
The matching files for this provider that exist in a particular directory.This directory may or may not be searched recursively, depending on implementation.
- Specified by:
matchingFilesForDirectory
in classFilesProviderWithDirectory
- Parameters:
directory
- the directory.parameters
- parameters passed to anInputManager
to generate input-objects.- Returns:
- a newly created list of matching files.
- Throws:
FilesProviderException
- if the operation is unable to complete successfully.
-
setFileFilterAndDirectory
Sets both the directory and the glob from a string containing both.e.g.
somefilepath/*.tif or somefilepath\*.tif
- Parameters:
combinedFileFilter
- a string with both a directory and a glob, as per above.
-
getMatcher
-
setMatcher
-
isRecursive
public boolean isRecursive()If true the search is applied recursively over sub-directories. -
setRecursive
public void setRecursive(boolean recursive) If true the search is applied recursively over sub-directories. -
getMaxDirectoryDepth
public int getMaxDirectoryDepth()If non-negative the max depth of directories. If -1, then there is no maximum depth. -
setMaxDirectoryDepth
public void setMaxDirectoryDepth(int maxDirectoryDepth) If non-negative the max depth of directories. If -1, then there is no maximum depth. -
isIgnoreHidden
public boolean isIgnoreHidden()If true, case is ignored in the pattern matching. Otherwise the system-default is used i.e. Windows ignores case, Linux doesn't. -
setIgnoreHidden
public void setIgnoreHidden(boolean ignoreHidden) If true, case is ignored in the pattern matching. Otherwise the system-default is used i.e. Windows ignores case, Linux doesn't. -
isAcceptDirectoryErrors
public boolean isAcceptDirectoryErrors()If true, continues when a directory-access-error occurs (logging it), otherwise throws an exception. -
setAcceptDirectoryErrors
public void setAcceptDirectoryErrors(boolean acceptDirectoryErrors) If true, continues when a directory-access-error occurs (logging it), otherwise throws an exception.
-