Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
22   273   17   1.38
2   88   0.77   16
16     1.06  
1    
 
  AbstractViolationReporter       Line # 28 95% 0.95
17.04 22 17 17 0.77
 
  ( 10 of 454)
 
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.api;
20   
21    /**
22    * Serves as an abstract base class for all modules that report inspection
23    * findings. Such modules have a Severity level which is used for the
24    * {@link LocalizedMessage localized messages} that are created by the module.
25    *
26    * @author lkuehne
27    */
 
28    public abstract class AbstractViolationReporter
29    extends AutomaticBean
30    {
31    /** resuable constant for message formating */
32    private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
33   
34    /** the severity level of any violations found */
35    private SeverityLevel mSeverityLevel = SeverityLevel.ERROR;
36   
37    /** the identifier of the reporter */
38    private String mId;
39   
40    /**
41    * Returns the severity level of the messages generated by this module.
42    * @return the severity level
43    * @see SeverityLevel
44    * @see LocalizedMessage#getSeverityLevel
45    */
 
46  2345 toggle public final SeverityLevel getSeverityLevel()
47    {
48  2345 return mSeverityLevel;
49    }
50   
51    /**
52    * Sets the severity level. The string should be one of the names
53    * defined in the <code>SeverityLevel</code> class.
54    *
55    * @param aSeverity The new severity level
56    * @see SeverityLevel
57    */
 
58  943 toggle public final void setSeverity(String aSeverity)
59    {
60  943 mSeverityLevel = SeverityLevel.getInstance(aSeverity);
61    }
62   
63    /**
64    * Get the severity level's name.
65    *
66    * @return the check's severity level name.
67    */
 
68  451 toggle public final String getSeverity()
69    {
70  451 return mSeverityLevel.getName();
71    }
72   
73    /**
74    * Returns the identifier of the reporter. Can be null.
75    * @return the id
76    */
 
77  2346 toggle public final String getId()
78    {
79  2346 return mId;
80    }
81   
82    /**
83    * Sets the identifer of the reporter. Can be null.
84    * @param aId the id
85    */
 
86  0 toggle public final void setId(final String aId)
87    {
88  0 mId = aId;
89    }
90   
91    /**
92    * Log a message.
93    *
94    * @param aLine the line number where the error was found
95    * @param aKey the message that describes the error
96    */
 
97  120 toggle protected final void log(int aLine, String aKey)
98    {
99  120 log(aLine, aKey, EMPTY_OBJECT_ARRAY);
100    }
101   
102    /**
103    * Helper method to log a LocalizedMessage. Column defaults to 0.
104    *
105    * @param aLineNo line number to associate with the message
106    * @param aKey key to locale message format
107    * @param aArg0 first argument
108    */
 
109  89 toggle protected final void log(int aLineNo, String aKey, Object aArg0)
110    {
111  89 log(aLineNo, aKey, new Object[] {aArg0});
112    }
113   
114    /**
115    * Helper method to log a LocalizedMessage. Column defaults to 0.
116    *
117    * @param aLineNo line number to associate with the message
118    * @param aKey key to locale message format
119    * @param aArg0 first argument
120    * @param aArg1 second argument
121    */
 
122