Class MatchRegularExpression
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanDetermines if it possible to match a file in a subdirectory.voidcheckMisconfigured(BeanInstanceMap defaultInstances) Checks that a bean's properties conform to expectations.protected CheckedPredicate<Path, IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) Create a predicate to be used for matching against path.The regular-expression, Java-style as described inPattern.booleanIf true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)voidsetApplyToPath(boolean applyToPath) If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)voidsetExpression(String expression) The regular-expression, Java-style as described inPattern.Methods inherited from class org.anchoranalysis.io.input.bean.path.matcher.FilePathMatcher
matchingFiles, matchingFilesMethods inherited from class org.anchoranalysis.bean.AnchorBean
describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
MatchRegularExpression
public MatchRegularExpression()
-
-
Method Details
-
checkMisconfigured
Description copied from class:AnchorBeanChecks that a bean's properties conform to expectations.- Overrides:
checkMisconfiguredin classAnchorBean<FilePathMatcher>- Parameters:
defaultInstances- all available default instances if theDefaultInstanceannotation is used- Throws:
BeanMisconfiguredException- if the bean has not been configured properly as XML
-
createMatcherFile
protected CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) 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.
-
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.
-
isApplyToPath
public boolean isApplyToPath()If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)By path, we refer to the relative-path to the file being considered, relative to the directory in which the search started.
e.g. if a file
/a/b/c/d.txtis encountered, then the regular-expression will match againstc/d.txtwhenapplyToPath==true, andd.txtotherwise. -
setApplyToPath
public void setApplyToPath(boolean applyToPath) If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)By path, we refer to the relative-path to the file being considered, relative to the directory in which the search started.
e.g. if a file
/a/b/c/d.txtis encountered, then the regular-expression will match againstc/d.txtwhenapplyToPath==true, andd.txtotherwise. -
getExpression
The regular-expression, Java-style as described inPattern.Regular expressions should be written to expect a forward-slash as the directory-separator, irrespective of operating system. This guarantees consistent behavior across operating systems.
Backslashes are not permitted as directory-seperators, only as escape characters.
-
setExpression
The regular-expression, Java-style as described inPattern.Regular expressions should be written to expect a forward-slash as the directory-separator, irrespective of operating system. This guarantees consistent behavior across operating systems.
Backslashes are not permitted as directory-seperators, only as escape characters.
-