KickJava   Java API By Example, From Geeks To Geeks.

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


1 ////////////////////////////////////////////////////////////////////////////////
2
// Test case file for checkstyle.
3
// Created: 2001
4
////////////////////////////////////////////////////////////////////////////////
5
package com.puppycrawl.tools.checkstyle;
6
7 /**
8  * Test case for correct use of braces.
9  * @author Oliver Burn
10  **/

11 class InputLeftCurlyOther
12 {
13     /** @see test method **/
14     int foo() throws InterruptedException JavaDoc
15     {
16         int x = 1;
17         int a = 2;
18         while (true)
19         {
20             try
21             {
22                 if (x > 0)
23                 {
24                     break;
25                 }
26                 else if (x < 0) {
27                     ;
28                 }
29                 else
30                 {
31                     break;
32                 }
33                 switch (a)
34                 {
35                 case 0:
36                     break;
37                 default:
38                     break;
39                 }
40             }
41             catch (Exception JavaDoc e)
42             {
43                 break;
44             }
45             finally
46             {
47                 break;
48             }
49         }
50
51         synchronized (this)
52         {
53             do
54             {
55                 x = 2;
56             } while (x == 2);
57         }
58
59         this.wait(666
60                  ); // Bizarre, but legal
61

62         for (int k = 0; k < 1; k++)
63         {
64             String JavaDoc innerBlockVariable = "";
65         }
66
67         // test input for bug reported by Joe Comuzzi
68
if (System.currentTimeMillis() > 1000)
69             return 1;
70         else
71             return 2;
72     }
73
74     // Test static initialiser
75
static
76     {
77         int x = 1; // should not require any javadoc
78
}
79
80
81
82     public enum GreetingsEnum
83     {
84         HELLO,
85         GOODBYE
86     };
87
88     void method2()
89     {
90         boolean flag = true;
91         if (flag) {
92             System.out.println("heh");
93             flag = !flag; } System.err.
94               println("Xe-xe");
95         // it is ok to have rcurly on the same line as previous
96
// statement if lcurly on the same line.
97
if (flag) { System.err.println("it is ok."); }
98     }
99 }
100
Popular Tags