Class XpathFilterElement
java.lang.Object
com.puppycrawl.tools.checkstyle.filters.XpathFilterElement
- All Implemented Interfaces:
TreeWalkerFilter
This filter element is immutable and processes
TreeWalkerAuditEvent
objects based on the criteria of file, check, module id, xpathQuery.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
The pattern for check class names.private final Pattern
The regexp to match check names against.private final String
The pattern for file names.private final Pattern
The regexp to match file names against.private final String
The pattern for message names.private final Pattern
The regexp to match message names against.private final String
Module id filter.private final net.sf.saxon.sxpath.XPathExpression
Xpath expression.private final String
Xpath query. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
accept
(TreeWalkerAuditEvent event) Determines whether or not a filteredTreeWalkerAuditEvent
is accepted.boolean
private List
<net.sf.saxon.om.Item> getItems
(TreeWalkerAuditEvent event) Returns list of nodes matching xpath expression given event.int
hashCode()
private boolean
Is matching by file name, module id and Check name.private boolean
Is matching by message.private boolean
Is matching by xpath query.
-
Field Details
-
fileRegexp
The regexp to match file names against. -
filePattern
The pattern for file names. -
checkRegexp
The regexp to match check names against. -
checkPattern
The pattern for check class names. -
messageRegexp
The regexp to match message names against. -
messagePattern
The pattern for message names. -
moduleId
Module id filter. -
xpathExpression
private final net.sf.saxon.sxpath.XPathExpression xpathExpressionXpath expression. -
xpathQuery
Xpath query.
-
-
Constructor Details
-
XpathFilterElement
public XpathFilterElement(String files, String checks, String message, String moduleId, String query) Creates aXpathElement
instance.- Parameters:
files
- regular expression for names of filtered fileschecks
- regular expression for filtered check classesmessage
- regular expression for messages.moduleId
- the module idquery
- the xpath query- Throws:
IllegalArgumentException
- if the xpath query is not expected.
-
XpathFilterElement
public XpathFilterElement(Pattern files, Pattern checks, Pattern message, String moduleId, String query) Creates aXpathElement
instance.- Parameters:
files
- regular expression for names of filtered fileschecks
- regular expression for filtered check classesmessage
- regular expression for messages.moduleId
- the module idquery
- the xpath query- Throws:
IllegalArgumentException
- if the xpath query is not correct.
-
-
Method Details
-
accept
Description copied from interface:TreeWalkerFilter
Determines whether or not a filteredTreeWalkerAuditEvent
is accepted.- Specified by:
accept
in interfaceTreeWalkerFilter
- Parameters:
event
- the TreeWalkerAuditEvent to filter.- Returns:
- true if the event is accepted.
-
isFileNameAndModuleAndModuleNameMatching
Is matching by file name, module id and Check name.- Parameters:
event
- event- Returns:
- true if it is matching
-
isMessageNameMatching
Is matching by message.- Parameters:
event
- event- Returns:
- true if it is matching or not set.
-
isXpathQueryMatching
Is matching by xpath query.- Parameters:
event
- event- Returns:
- true if it is matching or not set.
-
getItems
Returns list of nodes matching xpath expression given event.- Parameters:
event
-TreeWalkerAuditEvent
object- Returns:
- list of nodes matching xpath expression given event
- Throws:
IllegalStateException
- if the xpath query could not be evaluated.
-
hashCode
public int hashCode() -
equals
-