Class MatchGlob
Matches paths using a Java-style glob.
Please see FileSystem.getPathMatcher(java.lang.String)
for the syntax of the glob.
In summary, a single wildcard like *.jpg
will match only files in the top-level
directory, whereas a double wildcard like **.jpg
will match files in all subdirectories
recursively.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Determines if it possible to match a file in a subdirectory.protected CheckedPredicate
<Path, IOException> createMatcherFile
(Path directory, Optional<InputContextParameters> inputContext) Create a predicate to be used for matching against path.getGlob()
The string describing a glob e.g. "*.jpg".void
The string describing a glob e.g. "*.jpg".Methods inherited from class org.anchoranalysis.io.input.bean.path.matcher.FilePathMatcher
matchingFiles, matchingFiles
Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
MatchGlob
public MatchGlob() -
MatchGlob
Creates a newMatchGlob
instance.- Parameters:
glob
- The string describing a glob e.g. "*.jpg".If empty, then it is populated from the
InputContextParameters
where they exist.
-
-
Method Details
-
createMatcherFile
protected CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) throws InputReadFailedException Description copied from class:FilePathMatcher
Create a predicate to be used for matching against path.- Specified by:
createMatcherFile
in classFilePathMatcher
- Parameters:
directory
- the directory being searched. Only paths in this directory (or its subdirectories) will ever be passed to the predicate.inputContext
- the input-context.- Returns:
- a predicate that can be used to accept or reject a path (contained in
directory
. - Throws:
InputReadFailedException
- if the testing of the predicate fails.
-
canMatchSubdirectories
protected boolean canMatchSubdirectories()Description copied from class:FilePathMatcher
Determines if it possible to match a file in a subdirectory.If it impossible to match a subdirectory, this allows us to disable any recursive search, as it is pointless effort.
- Specified by:
canMatchSubdirectories
in classFilePathMatcher
- Returns:
- true if its possible for the predicate returned by
createMatcherFile
to match a file in a subdirectory, false otherwise.
-
getGlob
The string describing a glob e.g. "*.jpg".If empty, then it is populated from the
InputContextParameters
where they exist. -
setGlob
The string describing a glob e.g. "*.jpg".If empty, then it is populated from the
InputContextParameters
where they exist.
-