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 TypeMethodDescriptionintIf non-negative the max depth of directories.booleanIf true, continues when a directory-access-error occurs (logging it), otherwise throws an exception.booleanIf true, case is ignored in the pattern matching.booleanIf 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.voidsetAcceptDirectoryErrors(boolean acceptDirectoryErrors) If true, continues when a directory-access-error occurs (logging it), otherwise throws an exception.voidsetFileFilterAndDirectory(Path combinedFileFilter) Sets both the directory and the glob from a string containing both.voidsetIgnoreHidden(boolean ignoreHidden) If true, case is ignored in the pattern matching.voidsetMatcher(FilePathMatcher matcher) voidsetMaxDirectoryDepth(int maxDirectoryDepth) If non-negative the max depth of directories.voidsetRecursive(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, setLocalizedMethods inherited from class org.anchoranalysis.io.input.bean.files.FilesProviderWithDirectory
create, getDirectoryAsPathEnsureAbsolute, rootDirectoryMethods 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:FilesProviderWithDirectoryThe 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:
matchingFilesForDirectoryin classFilesProviderWithDirectory- Parameters:
directory- the directory.parameters- parameters passed to anInputManagerto 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.
-