Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
20   276   21   1
2   113   1.05   20
20     1.05  
1    
 
  Check       Line # 33 97.6% 0.97619045
21.01 20 21 21 1.05
 
  ( 10 of 438)
 
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    import java.util.HashSet;
22    import java.util.Set;
23   
24   
25    /**
26    * The base class for checks.
27    *
28    * @author Oliver Burn
29    * @version 1.0
30    * @see <a href="./{@docRoot}/../writingchecks.html" target="_top">Writing
31    * your own checks</a>
32    */
 
33    public abstract class Check extends AbstractViolationReporter
34    {
35    /** default tab width for column reporting */
36    private static final int DEFAULT_TAB_WIDTH = 8;
37   
38    /** the current file contents */
39    private FileContents mFileContents;
40   
41    /** the tokens the check is interested in */
42    private final Set mTokens = new HashSet();
43   
44    /** the object for collecting messages. */
45    private LocalizedMessages mMessages;
46   
47    /** the tab width for column reporting */
48    private int mTabWidth = DEFAULT_TAB_WIDTH; // meaningful default
49   
50    /**
51    * The class loader to load external classes. Not initialised as this must
52    * be set by my creator.
53    */
54    private ClassLoader mLoader;
55   
56    /**
57    * Returns the default token a check is interested in. Only used if the
58    * configuration for a check does not define the tokens.
59    * @return the default tokens
60    * @see TokenTypes
61    */
62    public abstract int[] getDefaultTokens();
63   
64    /**
65    * The configurable token set.
66    * Used to protect Checks against malicious users who specify an
67    * unacceptable token set in the configuration file.
68    * The default implementation returns the check's default tokens.
69    * @return the token set this check is designed for.
70    * @see TokenTypes
71    */
 
72  8 toggle public int[] getAcceptableTokens()
73    {
74  8 final int[] defaultTokens = getDefaultTokens();
75  8 final int[] copy = new int[defaultTokens.length];
76  8 System.arraycopy(defaultTokens, 0, copy, 0, defaultTokens.length);
77  8 return copy;
78    }
79   
80    /**
81    * The tokens that this check must be registered for.
82    * @return the token set this must be registered for.
83    * @see TokenTypes
84    */
 
85  28 toggle public int[] getRequiredTokens()
86    {
87  28 return new int[] {};
88    }
89   
90    /**
91    * Adds a set of tokens the check is interested in.
92    * @param aStrRep the string representation of the tokens interested in
93    */
 
94  35 toggle public final void setTokens(String[] aStrRep)
95    {
96  77 for (int i = 0; i < aStrRep.length; i++) {
97  42 final String s = aStrRep[i];
98  42 mTokens.add(s);
99    }
100    }
101   
102    /**
103    * Returns the tokens registered for the check.
104    * @return the set of token names
105    */
 
106  474 toggle public final Set getTokenNames()
107    {
108  474 return mTokens;
109    }
110   
111    /**
112    * Set the global object used to collect messages.
113    * @param aMessages the messages to log with
114    */
 
115  467 toggle public final void setMessages(