Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../../img/srcFileCovDistChart8.png 75% of files have more coverage
10   77   6   3.33
8   32   0.6   3
3     2  
1    
 
  AbstractIllegalCheck       Line # 29 81% 0.8095238
6.25 10 6 6 0.6
 
  ( 10 of 12)
 
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.checks.coding;
20   
21    import com.puppycrawl.tools.checkstyle.api.Check;
22    import java.util.HashSet;
23    import java.util.Set;
24   
25    /**
26    * Support for checks that look for usage of illegal types.
27    * @author Oliver Burn
28    */
 
29    public abstract class AbstractIllegalCheck extends Check
30    {
31    /** Illegal class names */
32    private final Set mIllegalClassNames = new HashSet();
33   
34    /**
35    * Constructs an object.
36    * @param aInitialNames the initial class names to treat as illegal
37    */
 
38  12 toggle protected AbstractIllegalCheck(final String[] aInitialNames)
39    {
40  0 assert aInitialNames != null;
41  12 setIllegalClassNames(aInitialNames);
42    }
43   
44    /**
45    * Checks if given class is illegal.
46    *
47    * @param aIdent
48    * ident to check.
49    * @return true if given ident is illegal.
50    */
 
51  36 toggle protected final boolean isIllegalClassName(final String aIdent)
52    {
53  36 return mIllegalClassNames.contains(aIdent);
54    }
55   
56    /**
57    * Set the list of illegal classes.
58    *
59    * @param aClassNames
60    * array of illegal exception classes
61    */
 
62  14 toggle public final void setIllegalClassNames(final String[] aClassNames)
63    {
64  0 assert aClassNames != null;
65  14 mIllegalClassNames.clear();
66  112 for (int i = 0; i < aClassNames.length; i++) {
67  98 final String name = aClassNames[i];
68  98 mIllegalClassNames.add(name);
69  98 final int lastDot = name.lastIndexOf(".");
70  98 if ((lastDot > 0) && (lastDot < (name.length() - 1))) {
71  51 final String shortName = name
72    .substring(name.lastIndexOf(".") + 1);
73  51 mIllegalClassNames.add(shortName);
74    }
75    }
76    }
77    }