Clover Coverage Report - Checkstyle
Coverage timestamp: Fri May 9 2008 10:48:13 EST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
18   112   8   2.25
0   54   0.44   8
8     1  
1    
 
  Comment       Line # 26 92.3% 0.9230769
8.03 18 8 8 0.44
 
  ( 10 of 365)
 
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    * Representation of the comment block.
23    *
24    * @author o_sukhodolsky
25    */
 
26    class Comment implements TextBlock
27    {
28    /** text of the comment. */
29    private final String[] mText;
30   
31    /** number of first line of the comment. */
32    private final int mFirstLine;
33   
34    /** number of last line of the comment. */
35    private final int mLastLine;
36   
37    /** number of first column of the comment. */
38    private final int mFirstCol;
39   
40    /** number of last column of the comment. */
41    private final int mLastCol;
42   
43    /**
44    * Creates new instance.
45    * @param aText the lines that make up the comment.
46    * @param aFirstCol number of the first column of the comment.
47    * @param aLastLine number of the last line of the comment.
48    * @param aLastCol number of the last column of the comment.
49    */
 
50  9076 toggle public Comment(final String[] aText, final int aFirstCol,
51    final int aLastLine, final int aLastCol)
52    {
53  9076 mText = new String[aText.length];
54  9076 System.arraycopy(aText, 0, mText, 0, mText.length);
55  9076 mFirstLine = aLastLine - mText.length + 1;
56  9076 mLastLine = aLastLine;
57  9076 mFirstCol = aFirstCol;
58  9076 mLastCol = aLastCol;
59    }
60   
61    /** {@inheritDoc} */
 
62  808 toggle public final String[] getText()
63    {
64  808 return (String[]) mText.clone();
65    }
66   
67    /** {@inheritDoc} */
 
68  559 toggle public final int getStartLineNo()
69    {
70  559 return mFirstLine;
71    }
72   
73    /** {@inheritDoc} */
 
74  6 toggle public final int getEndLineNo()
75    {
76  6 return mLastLine;
77    }
78   
79    /** {@inheritDoc} */
 
80  205 toggle public int getStartColNo()
81    {
82  205 return mFirstCol;
83    }
84   
85    /** {@inheritDoc} */
 
86  14 toggle public int getEndColNo()
87    {
88  14 return mLastCol;
89    }
90   
91    /** {@inheritDoc} */
 
92  1185 toggle public boolean intersects(int aStartLineNo, int aStartColNo,
93    int aEndLineNo, int aEndColNo)
94    {
95    // compute a single number for start and end
96    // to simpify conditional logic
97  1185 final long multiplier = Integer.MAX_VALUE;
98  1185 final long thisStart = mFirstLine * multiplier + mFirstCol;
99  1185 final long thisEnd = mLastLine * multiplier + mLastCol;
100  1185 final long inStart = aStartLineNo * multiplier + aStartColNo;
101  1185 final long inEnd = aEndLineNo * multiplier + aEndColNo;
102   
103  1185 return !((thisEnd < inStart) || (inEnd < thisStart));
104    }
105   
106    /** {@inheritDoc} */
 
107  0 toggle public String toString()
108    {
109  0 return "Comment[" + mFirstLine + ":" + mFirstCol + "-"
110    + mLastLine + ":" + mLastCol + "]";
111    }
112    }