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 booleanDetermines 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".voidThe string describing a glob e.g. "*.jpg".Methods inherited from class org.anchoranalysis.io.input.bean.path.matcher.FilePathMatcher
matchingFiles, matchingFilesMethods 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 newMatchGlobinstance.- Parameters:
glob- The string describing a glob e.g. "*.jpg".If empty, then it is populated from the
InputContextParameterswhere they exist.
-
-
Method Details
-
createMatcherFile
protected CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) throws InputReadFailedException Description copied from class:FilePathMatcherCreate a predicate to be used for matching against path.- Specified by:
createMatcherFilein 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:FilePathMatcherDetermines 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:
canMatchSubdirectoriesin classFilePathMatcher- Returns:
- true if its possible for the predicate returned by
createMatcherFileto 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
InputContextParameterswhere they exist. -
setGlob
The string describing a glob e.g. "*.jpg".If empty, then it is populated from the
InputContextParameterswhere they exist.
-