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 SummaryFieldsModifier and TypeFieldDescriptionprivate final PatternThe regexp to match check names against.private final PatternThe regexp to match file names against.private final booleanIndicates if all properties are set to null.private final PatternThe regexp to match message names against.private final StringModule id filter.private final net.sf.saxon.sxpath.XPathExpressionXpath expression.private final StringXpath query.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaccept(TreeWalkerAuditEvent event) Determines whether or not a filteredTreeWalkerAuditEventis accepted.booleanprivate List<net.sf.saxon.om.Item>getItems(TreeWalkerAuditEvent event) Returns list of nodes matching xpath expression given event.private static StringgetPatternSafely(Pattern pattern) Util method to get pattern String value from Pattern object safely, return null if pattern object is null.inthashCode()private booleanIs matching by file name, module id and Check name.private booleanIs matching by message.private booleanIs matching by xpath query.
- 
Field Details- 
fileRegexpThe regexp to match file names against.
- 
checkRegexpThe regexp to match check names against.
- 
messageRegexpThe regexp to match message names against.
- 
moduleIdModule id filter.
- 
xpathExpressionXpath expression.
- 
xpathQueryXpath query.
- 
isEmptyConfigIndicates if all properties are set to null.
 
- 
- 
Constructor Details- 
XpathFilterElementpublic XpathFilterElement(String files, String checks, String message, String moduleId, String query) Creates aXpathElementinstance.- Parameters:
- files- regular expression for names of filtered files
- checks- regular expression for filtered check classes
- message- regular expression for messages.
- moduleId- the module id
- query- the xpath query
- Throws:
- IllegalArgumentException- if the xpath query is not expected.
 
- 
XpathFilterElementpublic XpathFilterElement(Pattern files, Pattern checks, Pattern message, String moduleId, String query) Creates aXpathElementinstance.- Parameters:
- files- regular expression for names of filtered files
- checks- regular expression for filtered check classes
- message- regular expression for messages.
- moduleId- the module id
- query- the xpath query
- Throws:
- IllegalArgumentException- if the xpath query is not correct.
 
 
- 
- 
Method Details- 
acceptDescription copied from interface:TreeWalkerFilterDetermines whether or not a filteredTreeWalkerAuditEventis accepted.- Specified by:
- acceptin interface- TreeWalkerFilter
- Parameters:
- event- the TreeWalkerAuditEvent to filter.
- Returns:
- true if the event is accepted.
 
- 
isFileNameAndModuleAndModuleNameMatchingIs matching by file name, module id and Check name.- Parameters:
- event- event
- Returns:
- true if it is matching
 
- 
isMessageNameMatchingIs matching by message.- Parameters:
- event- event
- Returns:
- true if it is matching or not set.
 
- 
isXpathQueryMatchingIs matching by xpath query.- Parameters:
- event- event
- Returns:
- true if it is matching or not set.
 
- 
getItemsReturns list of nodes matching xpath expression given event.- Parameters:
- event-- TreeWalkerAuditEventobject
- Returns:
- list of nodes matching xpath expression given event
- Throws:
- IllegalStateException- if the xpath query could not be evaluated.
 
- 
hashCode
- 
equals
- 
getPatternSafelyUtil method to get pattern String value from Pattern object safely, return null if pattern object is null.- Parameters:
- pattern- pattern object
- Returns:
- value of pattern or null
 
 
-