KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > InputJavadocStyleCheck


1 ////////////////////////////////////////////////////////////////////////////////
2
// Test case file for checkstyle.
3
// Created: 2003
4
////////////////////////////////////////////////////////////////////////////////
5

6 package com.puppycrawl.tools.checkstyle;
7
8 /**
9  * Test input for the JavadocStyleCheck. This check is used to perform
10  * some additional Javadoc validations.
11  *
12  * @author Chris Stillwell
13  * @version 1.0
14  */

15 public class InputJavadocStyleCheck
16 {
17    // This is OK. We don't flag missing javadoc. That's left for other checks.
18
private String JavaDoc first;
19    
20    /** This Javadoc is missing an ending period */
21    private String JavaDoc second;
22    
23    /**
24     * We don't want {@link com.puppycrawl.tools.checkstyle.checks.JavadocStyleCheck}
25     * tags to stop the scan for the end of sentence.
26     * @see Somthing
27     */

28    public InputJavadocStyleCheck()
29    {
30    }
31    
32    /**
33     * This is ok!
34     */

35    private void method1()
36    {
37    }
38    
39    /**
40     * This is ok?
41     */

42    private void method2()
43    {
44    }
45    
46    /**
47     * And This is ok.<br>
48     */

49    private void method3()
50    {
51    }
52    
53    /**
54     * This should fail even.though.there are embedded periods
55     */

56    private void method4()
57    {
58    }
59    
60    /**
61     * Test HTML in Javadoc comment
62     * <dl>
63     * <dt><b>This guy is missing end of bold tag
64     * <dd>The dt and dd don't require end tags.
65     * </dl>
66     * </td>Extra tag shouldn't be here
67     *
68     * @param arg1 <code>dummy.
69     */

70    private void method5(int arg1)
71    {
72    }
73    
74    /**
75     * Protected check <b>should fail
76     */

77    protected void method6()
78    {
79    }
80    
81    /**
82     * Package protected check <b>should fail
83     */

84    void method7()
85    {
86    }
87    
88    /**
89     * Public check should fail</code>
90     * should fail <
91     */

92    public void method8()
93    {
94    }
95    
96    /** {@inheritDoc} **/
97    public void method9()
98    {
99    }
100
101     
102     // Testcases to excercize the Tag parser (bug 843887)
103

104     /**
105      * Real men don't use XHTML.
106      * <br />
107      * <hr/>
108      * < br/>
109      * <img SRC="schattenparker.jpg"/></img>
110      */

111     private void method10()
112     { // </img> should be the only error
113
}
114
115     /**
116      * Tag content can be really mean.
117      * <p>
118      * Sometimes a p tag is closed.
119      * </p>
120      * <p>
121      * Sometimes it's not.
122      *
123      * <span style="font-family:'Times New Roman',Times,serif;font-size:200%">
124      * Attributes can contain spaces and nested quotes.
125      * </span>
126      * <img SRC="slashesCanOccurWithin/attributes.jpg"/>
127      * <img SRC="slashesCanOccurWithin/attributes.jpg">
128      * <!-- comments <div> should not be checked. -->
129      */

130     private void method11()
131     { // JavadocStyle should not report any error for this method
132
}
133
134     /**
135      * Tags for two lines.
136      * <a HREF="some_link"
137      * >Link Text</a>
138      */

139     private void method12()
140     {// JavadocStyle should not report any error for this method
141
}
142
143     /**
144      * First sentence.
145      * <pre>
146      * +--LITERAL_DO (do)
147      * |
148      * +--SLIST ({)
149      * |
150      * +--EXPR
151      * |
152      * +--ASSIGN (=)
153      * |
154      * +--IDENT (x)
155      * +--METHOD_CALL (()
156      * |
157      * +--DOT (.)
158      * |
159      * +--IDENT (rand)
160      * +--IDENT (nextInt)
161      * +--ELIST
162      * |
163      * +--EXPR
164      * |
165      * +--NUM_INT (10)
166      * +--RPAREN ())
167      * +--SEMI (;)
168      * +--RCURLY (})
169      * +--LPAREN (()
170      * +--EXPR
171      * |
172      * +--LT (<)
173      * |
174      * +--IDENT (x)
175      * +--NUM_INT (5)
176      * +--RPAREN ())
177      * +--SEMI (;)
178      * </pre>
179      */

180     private void method13()
181     {// JavadocStyle should not report any error for this method
182
}
183
184     /**
185      * Some problematic javadoc. Sample usage:
186      * <blockquote>
187      */

188
189     private void method14()
190     { // empty line between javadoc and method is critical (bug 841942)
191
}
192
193     /**
194      * Empty line between javadoc and method declaration cause wrong
195      * line number for reporting error (bug 841942)
196      */

197
198     private void method15()
199     { // should report unended first sentance (check line number of the error)
200
}
201
202     /** Description of field: {@value}. */
203     public static final int dummy = 4911;
204
205     /**
206      */

207     public void method16()
208     { // should report empty javadoc
209
}
210
211     /**
212      * @param a A parameter
213      */

214     protected void method17(String JavaDoc a)
215     { // should report empty javadoc (no text before parameter)
216
}
217
218     /**
219      * @exception RuntimeException shoul be thrown
220      */

221     void method18(String JavaDoc a)
222     { // should report empty javadoc (no text before exception)
223
}
224
225     /**
226      */

227     private static int ASDF = 0;
228     // should report empty javdoc
229

230     /** @see java.lang.Object */
231     public void method19()
232     { // should report empty javadoc (no text before see tag)
233
}
234
235     public enum Test
236         //Should complain about no javadoc
237
{
238         /**
239          * Value 1 without a period
240          */

241         value1,
242
243         /**
244          * Value 2 with a period.
245          */

246         value2,
247     }
248
249     /**
250     * A test class.
251     * @param <T1> this is NOT an unclosed T1 tag
252     * @author <a HREF="mailto:foo@nomail.com">Foo Bar</a>
253     */

254     public class TestClass<T1>
255     {
256         /**
257         * Retrieves X.
258         * @return a value
259         */

260         public T1 getX()
261         {
262             return null;
263         }
264
265         /**
266         * Retrieves Y.
267         * @param <V> this is not an unclosed V tag
268         * @return a value
269         */

270         public <V> V getY()
271         {
272             return null;
273         }
274     }
275
276     /**
277      * Checks if the specified IClass needs to be
278      * annotated with the @Type annotation.
279      */

280     public void foo_1291847_1() {
281     }
282
283     /**
284      * Returns the string containing the properties of
285      * <code>@Type</code> annotation.
286      */

287     public void foo_1291847_2() {
288     }
289
290 }
291
Popular Tags