01: package com.mycompany.filters;
02:
03: import org.apache.regexp.RE;
04: import org.apache.regexp.RESyntaxException;
05:
06: import com.puppycrawl.tools.checkstyle.api.AuditEvent;
07: import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
08: import com.puppycrawl.tools.checkstyle.api.Filter;
09: import com.puppycrawl.tools.checkstyle.api.Utils;
10:
11: public class FilesFilter extends AutomaticBean implements Filter {
12: private RE mFileRegexp;
13:
14: public FilesFilter() throws RESyntaxException {
15: setFiles("^$");
16: }
17:
18: public boolean accept(AuditEvent aEvent) {
19: final String fileName = aEvent.getFileName();
20: return ((fileName == null) || !mFileRegexp.match(fileName));
21: }
22:
23: public void setFiles(String aFilesPattern) throws RESyntaxException {
24: mFileRegexp = Utils.getRE(aFilesPattern);
25: }
26: }
|