forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#5879: Suppression xpath single filter
- Loading branch information
1 parent
e2f7bb6
commit c0b85b5
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.puppycrawl.tools.checkstyle.filters; | ||
|
||
import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent; | ||
import com.puppycrawl.tools.checkstyle.TreeWalkerFilter; | ||
import com.puppycrawl.tools.checkstyle.api.AutomaticBean; | ||
import com.puppycrawl.tools.checkstyle.api.CheckstyleException; | ||
|
||
/** | ||
* | ||
*/ | ||
public class SuppressionXpathSingleFilter extends AutomaticBean implements | ||
TreeWalkerFilter { | ||
private XpathFilter xpathFilter; | ||
|
||
/** The pattern for file names. */ | ||
private String filePattern; | ||
|
||
/** The pattern for check class names. */ | ||
private String checkPattern; | ||
|
||
/** The pattern for message names. */ | ||
private String messagePattern; | ||
|
||
/** Module id filter. */ | ||
private String moduleId; | ||
|
||
/** Xpath query. */ | ||
private String xpathQuery; | ||
|
||
public void setFilePattern(String filePattern) { | ||
this.filePattern = filePattern; | ||
} | ||
|
||
public void setCheckPattern(String checkPattern) { | ||
this.checkPattern = checkPattern; | ||
} | ||
|
||
public void setMessagePattern(String messagePattern) { | ||
this.messagePattern = messagePattern; | ||
} | ||
|
||
public void setModuleId(String moduleId) { | ||
this.moduleId = moduleId; | ||
} | ||
|
||
public void setXpathQuery(String xpathQuery) { | ||
this.xpathQuery = xpathQuery; | ||
} | ||
|
||
public SuppressionXpathSingleFilter() { | ||
xpathFilter = new XpathFilter(filePattern, checkPattern, messagePattern, moduleId, xpathQuery); | ||
} | ||
|
||
@Override | ||
public boolean accept(TreeWalkerAuditEvent treeWalkerAuditEvent) { | ||
return xpathFilter.accept(treeWalkerAuditEvent); | ||
} | ||
|
||
@Override | ||
protected void finishLocalSetup() throws CheckstyleException { | ||
// No code by default | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters