KickJava   Java API By Example, From Geeks To Geeks.

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


1 ////////////////////////////////////////////////////////////////////////////////
2
// Test case file for checkstyle.
3
// Created: 2001
4
////////////////////////////////////////////////////////////////////////////////
5
package com.puppycrawl.tools.checkstyle;
6 import java.io.IOException JavaDoc;
7 // Tests for Javadoc tags.
8
class InputTags1
9 {
10     // Invalid - should be Javadoc
11
private int mMissingJavadoc;
12
13     // Invalid - should be Javadoc
14
void method1()
15     {
16     }
17
18     /** @param unused asd **/
19     void method2()
20     {
21     }
22
23     /** missing return **/
24     int method3()
25     {
26         return 3;
27     }
28
29     /**
30      * missing return
31      * @param aOne ignored
32      **/

33     int method4(int aOne)
34     {
35         return aOne;
36     }
37
38     /** missing throws **/
39     void method5()
40         throws Exception JavaDoc
41     {
42     }
43
44     /**
45      * @see missing throws
46      * @see need to see tags to avoid shortcut logic
47      **/

48     void method6()
49         throws Exception JavaDoc
50     {
51     }
52
53     /** @throws WrongException error **/
54     void method7()
55         throws Exception JavaDoc, NullPointerException JavaDoc
56     {
57     }
58
59     /** missing param **/
60     void method8(int aOne)
61     {
62     }
63
64     /**
65      * @see missing param
66      * @see need to see tags to avoid shortcut logic
67      **/

68     void method9(int aOne)
69     {
70     }
71
72     /** @param WrongParam error **/
73     void method10(int aOne, int aTwo)
74     {
75     }
76
77     /**
78      * @param Unneeded parameter
79      * @return also unneeded
80      **/

81     void method11()
82     {
83     }
84
85     /**
86      * @return first one
87      * @return duplicate
88      **/

89     int method12()
90     {
91         return 0;
92     }
93
94     /**
95      * @param aOne
96      * @param aTwo
97      *
98      * This is a multiline piece of javadoc
99      * Unlike the previous one, it actually has content
100      * @param aThree
101      *
102      *
103      * This also has content
104      * @param aFour
105
106      *
107      * @param aFive
108      **/

109     void method13(int aOne, int aTwo, int aThree, int aFour, int aFive)
110     {
111     }
112
113     /** @param aOne Perfectly legal **/
114     void method14(int aOne)
115     {
116     }
117
118     /** @throws java.io.IOException
119      * just to see if this is also legal **/

120     void method14()
121        throws java.io.IOException JavaDoc
122     {
123     }
124
125
126
127     // Test static initialiser
128
static
129     {
130         int x = 1; // should not require any javadoc
131
}
132
133     // test initialiser
134
{
135         int z = 2; // should not require any javadoc
136
}
137
138     /** handle where variable declaration over several lines **/
139     private static final int
140         ON_SECOND_LINE = 2;
141
142
143     /**
144      * Documenting different causes for the same exception
145      * in separate tags is OK (bug 540384).
146      *
147      * @throws java.io.IOException if A happens
148      * @throws java.io.IOException if B happens
149      **/

150     void method15()
151        throws java.io.IOException JavaDoc
152     {
153     }
154
155     /** {@inheritDoc} **/
156     public String JavaDoc toString()
157     {
158         return super.toString();
159     }
160
161     /** getting code coverage up **/
162     static final int serialVersionUID = 666;
163
164     //**********************************************************************/
165
// Method Name: method16
166
/**
167      * handle the case of an elaborate header surrounding javadoc comments
168      *
169      * @param aOne valid parameter content
170      */

171     //**********************************************************************/
172
void method16(int aOne)
173     {
174     }
175
176
177     /**
178      * @throws ThreadDeath although bad practice, should be silently ignored
179      * @throws ArrayStoreException another r/t subclass
180      * @throws IllegalMonitorStateException should be told to remove from throws
181      */

182     void method17()
183         throws IllegalMonitorStateException JavaDoc
184     {
185     }
186
187     /**
188      * declaring the imported version of an Exception and documenting
189      * the full class name is OK (bug 658805).
190      * @throws java.io.IOException if bad things happen.
191      */

192     void method18()
193         throws IOException JavaDoc
194     {
195         throw new IOException JavaDoc("to make compiler happy");
196     }
197
198     /**
199      * reverse of bug 658805.
200      * @throws IOException if bad things happen.
201      */

202     void method19()
203         throws java.io.IOException JavaDoc
204     {
205         throw new IOException JavaDoc("to make compiler happy");
206     }
207     
208     /**
209      * Bug 579190, "expected return tag when one is there".
210      *
211      * Linebreaks after return tag should be legal.
212      *
213      * @return
214      * the bug that states that linebreak should be legal
215      */

216     int method20()
217     {
218         return 579190;
219     }
220
221     /**
222      * Bug XXX, "two tags for the same exception"
223      *
224      * @exception java.io.IOException for some reasons
225      * @exception IOException for another reason
226      */

227     void method21()
228        throws IOException JavaDoc
229     {
230     }
231
232     /**
233      * RFE 540383, "Unused throws tag for exception subclass"
234      *
235      * @exception IOException for some reasons
236      * @exception java.io.FileNotFoundException for another reasons
237      */

238     void method22()
239        throws IOException JavaDoc
240     {
241     }
242
243     /**
244      * @exception WrongException exception w/o class info but matched by name
245      */

246     void method23() throws WrongException
247     {
248     }
249
250     /**
251      * Bug 803577, "allowThrowsTagsForSubclasses/allowMissingThrowsTag interfere"
252      *
253      * no exception tag for IOException, but here is a tag for its subclass.
254      * @exception java.io.FileNotFoundException for another reasons
255      */

256     void method24() throws IOException JavaDoc
257     {
258     }
259
260     /**
261      * Bug 841942, "ArrayIndexOutOfBounds in JavadocStyle".
262      * @param aParam there is no such param in the method.
263      * The problem should be reported with correct line number.
264      */

265
266     void method25()
267     {
268     }
269
270     /** {@inheritDoc} */
271     int method26()
272     { return 0;
273     }
274
275     /**
276      * {@inheritDoc}
277      * @return something very important.
278      */

279     int method27(int aParam)
280     { return 0;
281     }
282
283     /**
284      * @return something very important.
285      * {@inheritDoc}
286      */

287     int method28(int aParam)
288     { return 0;
289     }
290
291     /**
292      * {@inheritDoc}
293      *
294      * @return 1
295      */

296     public int foo(Object JavaDoc _arg) {
297
298         return 1;
299     }
300 }
301
302 enum InputTagsEnum
303 {
304     CONSTANT_A,
305
306     /**
307      *
308      */

309     CONSTANT_B,
310
311     CONSTANT_C
312     {
313         /**
314          *
315          */

316         public void someMethod()
317         {
318         }
319
320         public void someOtherMethod()
321         {
322
323         }
324     }
325 }
326
327 @interface InputTagsAnnotation
328 {
329     String JavaDoc someField();
330     int A_CONSTANT = 0;
331     /** Some javadoc. */
332     int B_CONSTANT = 1;
333     /** @return This tag is not valid here */
334     String JavaDoc someField2();
335 }
336
337 /**
338  * Some javadoc.
339  */

340 public class InputTags {
341
342     /**
343      * Constructor.
344      */

345     public InputTags() {
346     }
347
348    /**
349     * Sample method.
350     * @param arg1 first argument
351     * @param arg2 second argument
352     * @return java.lang.String the result string
353     * @throws java.lang.Exception in case of problem
354     */

355     public final String JavaDoc myMethod(final String JavaDoc arg1,
356                                  final Object JavaDoc arg2)
357       throws Exception JavaDoc
358     {
359         return null;
360     }
361 }
362
363 /**
364  * Added to make this file compilable.
365  */

366 class WrongException extends RuntimeException JavaDoc
367 {
368 }
369
Popular Tags