KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > indentation > InputValidMethodIndent


1 /*
2  * InputValidMethodIndent.java
3  *
4  * Created on November 11, 2002, 10:13 PM
5  */

6
7 package com.puppycrawl.tools.checkstyle.indentation;
8
9 import java.util.Arrays JavaDoc;
10
11 /**
12  *
13  * @author jrichard
14  */

15 public class InputValidMethodIndent extends java.awt.event.MouseAdapter JavaDoc implements java.awt.event.MouseListener JavaDoc {
16     
17     // ctor with rcurly on same line
18
public InputValidMethodIndent() {
19     }
20
21     private InputValidMethodIndent(boolean test) {
22         boolean test2 = true;
23         
24         int i = 4 +
25             4;
26     }
27
28     
29     private InputValidMethodIndent(boolean test,
30         boolean test2) {
31         boolean test3 = true;
32         
33         int i = 4 +
34             4;
35     }
36
37     
38     private InputValidMethodIndent(boolean test,
39         boolean test2, boolean test3)
40     {
41         boolean test4 = true;
42         
43         int i = 4 +
44             4;
45     }
46     
47     // ctor with rcurly on next line
48
public InputValidMethodIndent(int dummy)
49     {
50     }
51
52     // method with rcurly on same line
53
public String JavaDoc method1() {
54         return "hi";
55     }
56
57     // method with rcurly on next line
58
public void method2()
59     {
60     }
61     
62     // method with a bunch of params
63
public int method2(int x, int y, int w, int h)
64     {
65         return 1;
66     }
67     
68     // params on multiple lines
69
public void method2(int x, int y, int w, int h,
70         int x1, int y1, int w1, int h1)
71     {
72     }
73
74     // params on multiple lines
75
public void method3(int x, int y, int w, int h,
76         int x1, int y1, int w1, int h1)
77     {
78         System.getProperty("foo");
79     }
80
81     // params on multiple lines
82
public void method4(int x, int y, int w, int h,
83         int x1, int y1, int w1, int h1)
84     {
85         boolean test = true;
86         
87         int i = 4 +
88             4;
89         
90         i += 5;
91         i += 5
92             + 4;
93         if (test)
94         {
95             System.getProperty("foo");
96         } else {
97             System.getProperty("foo");
98         }
99         
100         for (int j=0;j<10; j++) {
101             System.getProperty("foo");
102         }
103
104         
105         myfunc2(10, 10, 10,
106             myfunc3(11, 11,
107                 11, 11),
108             10, 10,
109             10);
110         
111
112         myfunc3(11, 11, Integer.
113                 getInteger("mytest").intValue(),
114             11);
115         
116         myfunc3(
117             1,
118             2,
119                 3,
120                 4);
121     }
122
123     // strange IMHO, but I suppose this should be allowed
124
public
125     void
126     method5() {
127     }
128     
129           
130     private void myfunc2(int a, int b, int c, int d, int e, int f, int g) {
131     }
132     
133     private int myfunc3(int a, int b, int c, int d) {
134         return 1;
135     }
136     
137     
138     void method6() {
139         System.out.println("methods are: " + Arrays.asList(
140             new String JavaDoc[] {"method"}).toString());
141
142         System.out.println("methods are: " + Arrays.asList(
143             new String JavaDoc[] {"method"}
144         ).toString());
145
146         System.out.println("methods are: " + Arrays.asList(
147             new String JavaDoc[] {"method"}).toString()
148         );
149
150             
151         myfunc2(3, 4, 5,
152             6, 7, 8, 9);
153             
154         myfunc2(3, 4, method2(3, 4, 5, 6) + 5,
155             6, 7, 8, 9);
156             
157         System.out.println("methods are: " +
158             Arrays.asList(
159                 new String JavaDoc[] {"method"}).toString());
160         
161         System.out.println("methods are: "
162             + Arrays.asList(
163                 new String JavaDoc[] {"method"}).toString());
164                 
165
166         String JavaDoc blah = (String JavaDoc) System.getProperty(
167             new String JavaDoc("type"));
168         
169         System.out.println(method1() + "mytext"
170             + " at indentation level not at correct indentation, "
171             + method1());
172
173         System.out.println(
174             method1() + "mytext"
175                 + " at indentation level not at correct indentation, "
176                 + method1());
177
178         System.out.toString()
179             .equals("blah");
180
181
182         if (!areOnSameLine((DetailAST)aChild.expr.getFirstChild(),
183             (DetailAST) expr.getFirstChild()))
184         {
185         }
186         
187         if (System.out.write(new byte[0],
188             0, 0)) {
189             System.out.println("blah");
190         }
191         
192         
193     }
194
195     
196     private void myFunc()
197         throws Exception JavaDoc
198     {
199     }
200
201     private void myFunc() throws Exception JavaDoc
202     {
203     }
204         
205 }
206
Popular Tags