Class MatchGlob
Object
org.anchoranalysis.bean.AnchorBean<FilePathMatcher>
org.anchoranalysis.io.input.bean.path.matcher.FilePathMatcher
org.anchoranalysis.io.input.bean.path.matcher.MatchGlob
public class MatchGlob extends FilePathMatcher
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
-
Method Summary
Modifier and Type Method Description protected booleancanMatchSubdirectories()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.StringgetGlob()The string describing a glob e.g.voidsetGlob(String glob)The string describing a glob e.g.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
-
Method Details
-
createMatcherFile
protected CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) throws InputReadFailedExceptionDescription 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.
-