KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > filter > BugMatcher


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.filter;
21
22 import edu.umd.cs.findbugs.BugInstance;
23
24 /**
25  * Match bug instances having one of given codes or patterns.
26  *
27  * @author rafal@caltha.pl
28  */

29 public class BugMatcher implements Matcher {
30     private StringSetMatch codes;
31     private StringSetMatch patterns;
32     private StringSetMatch categories;
33     
34     /**
35      * Constructor.
36      *
37      * @param codes comma-separated list of bug codes
38      * @param patterns coma-separated list of bug patterns.
39      * @param categories coma-separated list of bug categories.
40      */

41     public BugMatcher(String JavaDoc codes, String JavaDoc patterns, String JavaDoc categories) {
42         this.codes = new StringSetMatch(codes);
43         this.patterns = new StringSetMatch(patterns);
44         this.categories = new StringSetMatch(categories);
45     }
46     
47     public boolean match(BugInstance bugInstance) {
48         return codes.match(bugInstance.getAbbrev())
49                 || patterns.match(bugInstance.getType())
50                 || categories.match(bugInstance.getBugPattern().getCategory());
51     }
52 }
53
Popular Tags