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 ca74cbc
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
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,82 @@ | ||
package com.puppycrawl.tools.checkstyle.filters; | ||
|
||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
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; | ||
import com.puppycrawl.tools.checkstyle.api.ExternalResourceHolder; | ||
import net.sf.saxon.sxpath.XPathExpression; | ||
|
||
public class SuppressionXpathSingleFilter extends AutomaticBean implements | ||
TreeWalkerFilter, ExternalResourceHolder { | ||
private XpathFilter xpathFilter; | ||
|
||
/** The regexp to match file names against. */ | ||
private Pattern fileRegexp; | ||
|
||
/** The pattern for file names. */ | ||
private String filePattern; | ||
|
||
/** The regexp to match check names against. */ | ||
private Pattern checkRegexp; | ||
|
||
/** The pattern for check class names. */ | ||
private String checkPattern; | ||
|
||
/** The regexp to match message names against. */ | ||
private Pattern messageRegexp; | ||
|
||
/** The pattern for message names. */ | ||
private String messagePattern; | ||
|
||
/** Module id filter. */ | ||
private String moduleId; | ||
|
||
/** Xpath expression. */ | ||
private XPathExpression xpathExpression; | ||
|
||
/** 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 { | ||
|
||
} | ||
|
||
@Override | ||
public Set<String> getExternalResourceLocations() { | ||
return null; | ||
} | ||
} |