Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
6   70   5   2
4   29   0.83   3
3     1.67  
1    
 
  AbstractNameCheck       Line # 32 100% 1.0
5 6 5 5 0.83
 
  ( 10 of 40)
 
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   
20    package com.puppycrawl.tools.checkstyle.checks.naming;
21   
22    import com.puppycrawl.tools.checkstyle.api.DetailAST;
23    import com.puppycrawl.tools.checkstyle.api.TokenTypes;
24    import com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck;
25   
26    /**
27    * Abstract class for checking that names conform to a specified format.
28    *
29    * @author Rick Giles
30    * @version 1.0
31    */
 
32    public abstract class AbstractNameCheck
33    extends AbstractFormatCheck
34    {
35    /**
36    * Creates a new <code>AbstractNameCheck</code> instance.
37    * @param aFormat format to check with
38    */
 
39  48 toggle public AbstractNameCheck(String aFormat)
40    {
41  48 super(aFormat);
42    }
43   
44    /**
45    * Decides whether the name of an AST should be checked against
46    * the format regexp.
47    * @param aAST the AST to check.
48    * @return true if the IDENT subnode of aAST should be checked against
49    * the format regexp.
50    */
 
51  10 toggle protected boolean mustCheckName(DetailAST aAST)
52    {
53  10 return true;
54    }
55   
56    /** {@inheritDoc} */
 
57  578 toggle public void visitToken(DetailAST aAST)
58    {
59  578 if (mustCheckName(aAST)) {
60  213 final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT);
61  213 if (!getRegexp().matcher(nameAST.getText()).find()) {
62  131 log(nameAST.getLineNo(),
63    nameAST.getColumnNo(),
64    "name.invalidPattern",
65    nameAST.getText(),
66    getFormat());
67    }
68    }
69    }
70    }