public abstract class FilePathMatcher extends AnchorBean<FilePathMatcher>
Search operations can be executed against this pattern, to find all files in a directory that match.
Constructor and Description |
---|
FilePathMatcher() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
canMatchSubdirectories()
Determines if it possible to match a file in a subdirectory.
|
protected abstract CheckedPredicate<Path,IOException> |
createMatcherFile(Path directory,
Optional<InputContextParameters> inputContext)
Create a predicate to be used for matching against path.
|
List<File> |
matchingFiles(Path directory,
boolean recursive)
Like
matchingFiles(Path, boolean, boolean, boolean, Optional, Optional) but uses
sensible defaults. |
List<File> |
matchingFiles(Path directory,
boolean recursive,
boolean ignoreHidden,
boolean acceptDirectoryErrors,
Optional<Integer> maxDirectoryDepth,
Optional<InputManagerParameters> parameters)
Finds a collection of files that match particular conditions on their paths.
|
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
public List<File> matchingFiles(Path directory, boolean recursive) throws InputReadFailedException
matchingFiles(Path, boolean, boolean, boolean, Optional, Optional)
but uses
sensible defaults.
Hidden files are ignored.
Continues even when a directory-access-error occurs, without throwing an exception.
No maximum directory depth is imposed.
No parameters are applied.
directory
- root directory to search.recursive
- whether to recursively search.InputReadFailedException
- if an error occurrs reading/writing or interacting with the
filesystem.public List<File> matchingFiles(Path directory, boolean recursive, boolean ignoreHidden, boolean acceptDirectoryErrors, Optional<Integer> maxDirectoryDepth, Optional<InputManagerParameters> parameters) throws InputReadFailedException
directory
- root directory to search.recursive
- whether to recursively search.ignoreHidden
- whether to ignore hidden files/directories or not.acceptDirectoryErrors
- if true, continues when a directory-access-error occurs (logging
it), otherwise throws an exception.maxDirectoryDepth
- a maximum depth in directories to search.parameters
- parameters providing input-contextInputReadFailedException
- if an error occurs reading/writing or interacting with the
filesystem.protected abstract CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) throws InputReadFailedException
directory
- the directory being searched. Only paths in this directory (or its
subdirectories) will ever be passed to the predicate.inputContext
- the input-context.directory
.InputReadFailedException
- if the testing of the predicate fails.protected abstract boolean canMatchSubdirectories()
If it impossible to match a subdirectory, this allows us to disable any recursive search, as it is pointless effort.
createMatcherFile
to match
a file in a subdirectory, false otherwise.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.