Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
7   106   7   1.17
2   38   1   6
6     1.17  
1    
 
  AbstractHeaderCheck       Line # 32 100% 1.0
7 7 7 7 1
 
  ( 10 of 14)
 
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.header;
21   
22    import org.apache.commons.beanutils.ConversionException;
23   
24    import com.puppycrawl.tools.checkstyle.api.Check;
25    import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
26   
27    /**
28    * Abstract super class for header checks.
29    * Provides support for headerFile property.
30    * @author o_sukhosolsky
31    */
 
32    public abstract class AbstractHeaderCheck extends Check
33    {
34    /** information about the expected header file. */
35    private HeaderInfo mHeaderInfo = createHeaderInfo();
36   
37    /**
38    * Return the header lines to check against.
39    * @return the header lines to check against.
40    */
 
41  1 toggle protected String[] getHeaderLines()
42    {
43  1 return mHeaderInfo.getHeaderLines();
44    }
45   
46    /**
47    * Abstract factory method to create an unconfigured
48    * header info bean. Note that the actual type of the
49    * return value can be subclass specific.
50    *
51    * @return a header info bean for this check.
52    */
53    protected abstract HeaderInfo createHeaderInfo();
54   
55    /**
56    * Return the header info to check against.
57    * @return the header info to check against.
58    */
 
59  15 toggle protected HeaderInfo getHeaderInfo()
60    {
61  15 return mHeaderInfo;
62    }
63   
64    /**
65    * Set the header file to check against.
66    * @param aFileName the file that contains the header to check against.
67    * @throws ConversionException if the file cannot be loaded
68    */
 
69  11 toggle public void setHeaderFile(String aFileName)
70    throws ConversionException
71    {
72  11 mHeaderInfo.setHeaderFile(aFileName);
73    }
74   
75    /**
76    * Set the header to check against. Individual lines in the header
77    * must be separated by '\n' characters.
78    * @param aHeader header content to check against.
79    * @throws ConversionException if the header cannot be interpreted
80    */
 
81  2 toggle public void setHeader(String aHeader)
82    {
83  2 mHeaderInfo.setHeader(aHeader);
84    }
85   
86    /**
87    * Checks that required args were specified.
88    * @throws CheckstyleException {@inheritDoc}
89    * @see com.puppycrawl.tools.checkstyle.api.AutomaticBean#finishLocalSetup
90    */
 
91  12 toggle protected final void finishLocalSetup() throws CheckstyleException
92    {
93  12 if (mHeaderInfo.getHeaderLines() == null) {
94  2 throw new CheckstyleException(
95    "property 'headerFile' is missing or invalid in module "
96    + getConfiguration().getName());
97    }
98    }
99   
100    /** {@inheritDoc} */
 
101  10 toggle public final int[] getDefaultTokens()
102    {
103  10 return new int[0];
104    }
105   
106    }