KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > filters > SuppressionFilter


1 ////////////////////////////////////////////////////////////////////////////////
2
// checkstyle: Checks Java source code for adherence to a set of rules.
3
// Copyright (C) 2001-2005 Oliver Burn
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
package com.puppycrawl.tools.checkstyle.filters;
20
21 import com.puppycrawl.tools.checkstyle.api.AuditEvent;
22 import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
23 import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
24 import com.puppycrawl.tools.checkstyle.api.Filter;
25 import com.puppycrawl.tools.checkstyle.api.FilterSet;
26
27 /**
28  * <p>
29  * This filter accepts AuditEvents according to file, check, line, and
30  * column, as specified in a suppression file.
31  * </p>
32  * @author Rick Giles
33  */

34 public class SuppressionFilter
35     extends AutomaticBean
36     implements Filter
37 {
38     /** set of individual suppresses */
39     private FilterSet mFilters = new FilterSet();
40
41     /**
42      * Loads the suppressions for a file.
43      * @param aFileName name of the suppressions file.
44      * @throws CheckstyleException if there is an error.
45      */

46     public void setFile(String JavaDoc aFileName)
47         throws CheckstyleException
48     {
49         mFilters = SuppressionsLoader.loadSuppressions(aFileName);
50     }
51
52     /** {@inheritDoc} */
53     public boolean accept(AuditEvent aEvent)
54     {
55         return mFilters.accept(aEvent);
56     }
57
58     /** {@inheritDoc} */
59     public String JavaDoc toString()
60     {
61         return mFilters.toString();
62     }
63
64     /** {@inheritDoc} */
65     public int hashCode()
66     {
67         return mFilters.hashCode();
68     }
69
70     /** {@inheritDoc} */
71     public boolean equals(Object JavaDoc aObject)
72     {
73         if (aObject instanceof SuppressionFilter) {
74             final SuppressionFilter other = (SuppressionFilter) aObject;
75             return this.mFilters.equals(other.mFilters);
76         }
77         return false;
78     }
79 }
80
Popular Tags