KickJava   Java API By Example, From Geeks To Geeks.

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


1 ////////////////////////////////////////////////////////////////////////////////
2
// Test case file for checkstyle.
3
// Created: 2002
4
////////////////////////////////////////////////////////////////////////////////
5
package com.puppycrawl.tools.checkstyle;
6
7 import java.awt.event.MouseEvent JavaDoc;
8 import java.awt.event.MouseAdapter JavaDoc;
9 import javax.swing.JButton JavaDoc;
10
11 /**
12  * Tests for length of anonymous inner types
13  * @author Rob Worth
14  * @author Lars Kühne
15  **/

16 public class InputAnonInnerLength
17 {
18     /**
19      * Check that instantiations of normal classes work OK.
20      */

21     private JButton JavaDoc mButton = new JButton JavaDoc();
22
23     private class MyInner
24     {
25         private MyInner(int[] anArray)
26         {
27         }
28     }
29
30     /**
31      * the AnonInnerLengthCheck works with 'new' and RCURLY - check that
32      * it will not confuse constructors calls with array params with
33      * anon inners.
34      */

35     private MyInner myInner = new MyInner(new int[]{
36             // make the array span multiple lines
37
1,
38             2,
39             3,
40             4,
41             5,
42             6,
43             7,
44             }
45     );
46
47     /**
48        anon inner in member variable initialization which is 21 lines long
49     */

50     private Runnable JavaDoc mRunnable1 = new Runnable JavaDoc() {
51         public void run() // should not have to be documented, class is anon.
52
{
53             System.out.println("running");
54             System.out.println("running");
55             System.out.println("running");
56             System.out.println("running");
57             System.out.println("running");
58             System.out.println("running");
59             System.out.println("running");
60             System.out.println("running");
61             System.out.println("running");
62             System.out.println("running");
63             System.out.println("running");
64             System.out.println("running");
65             System.out.println("running");
66             System.out.println("running");
67             System.out.println("running");
68             System.out.println("running");
69         }
70     };
71
72     /**
73        anon inner in member variable initialization which is 20 lines long
74     */

75     private Runnable JavaDoc mRunnable2 = new Runnable JavaDoc() {
76         public void run() // should not have to be documented, class is anon.
77
{
78             System.out.println("running");
79             System.out.println("running");
80             System.out.println("running");
81             System.out.println("running");
82             System.out.println("running");
83             System.out.println("running");
84             System.out.println("running");
85             System.out.println("running");
86             System.out.println("running");
87             System.out.println("running");
88             System.out.println("running");
89             System.out.println("running");
90             System.out.println("running");
91             System.out.println("running");
92             System.out.println("running");
93         }
94     };
95
96     /**
97        anon inner in constructor.
98     */

99     InputAnonInnerLength()
100     {
101         mButton.addMouseListener( new MouseAdapter JavaDoc()
102             {
103                 public void mouseClicked( MouseEvent JavaDoc aEv )
104                 {
105                     System.out.println("click");
106                 }
107             } );
108     }
109
110     /**
111        anon inner in method
112     */

113     public void addInputAnonInner()
114     {
115         mButton.addMouseListener( new MouseAdapter JavaDoc()
116             {
117                 public void mouseClicked( MouseEvent JavaDoc aEv )
118                 {
119                     System.out.println("click");
120                 }
121             } );
122     }
123 }
124
Popular Tags