Class MatchRegularExpression
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Determines if it possible to match a file in a subdirectory.void
checkMisconfigured
(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
.boolean
If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)void
setApplyToPath
(boolean applyToPath) If true, the filter is applied to the path, not just the filename (using forward slashes as directory separators)void
setExpression
(String expression) The regular-expression, Java-style as described inPattern
.Methods inherited from class org.anchoranalysis.io.input.bean.path.matcher.FilePathMatcher
matchingFiles, matchingFiles
Methods 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:AnchorBean
Checks that a bean's properties conform to expectations.- Overrides:
checkMisconfigured
in classAnchorBean<FilePathMatcher>
- Parameters:
defaultInstances
- all available default instances if theDefaultInstance
annotation 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: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
.
-
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.
-
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.txt
is encountered, then the regular-expression will match againstc/d.txt
whenapplyToPath==true
, andd.txt
otherwise. -
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.txt
is encountered, then the regular-expression will match againstc/d.txt
whenapplyToPath==true
, andd.txt
otherwise. -
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.
-