KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * InputValidSwitchIndent.java
3  *
4  * Created on November 27, 2002, 11:40 PM
5  */

6
7 package com.puppycrawl.tools.checkstyle.indentation;
8
9 /**
10  *
11  * @author jrichard
12  */

13 public class InputValidSwitchIndent {
14     
15     private static final int CONST = 5;
16     private static final int CONST2 = 2;
17     private static final int CONST3 = 3;
18     
19     /** Creates a new instance of InputValidSwitchIndent */
20     public InputValidSwitchIndent() {
21     }
22     
23     private void method1() {
24         int s = 3;
25         
26         switch (s) {
27             
28             case 4:
29                 System.out.println("");
30                 break;
31
32             case CONST:
33                 break;
34
35             case CONST2:
36             case CONST3:
37                 break;
38
39             default:
40                 System.out.println("");
41                 break;
42         }
43         
44
45         // some people like to add curlys to their cases:
46
switch (s) {
47             
48             case 4: {
49                 System.out.println("");
50                 break;
51             }
52
53             case CONST:
54                 break;
55
56             case CONST2:
57             case CONST3:
58             {
59                 System.out.println("");
60                 break;
61             }
62
63             default:
64                 break;
65         }
66          
67         // check broken 'case' lines
68
switch (s) {
69             
70             case
71                 4: {
72                 System.out.println("");
73                 break;
74             }
75
76             case
77                 CONST:
78                 break;
79
80             case CONST2:
81             case
82                 CONST3:
83             {
84                 System.out.println("");
85                 break;
86             }
87
88             default:
89                 break;
90         }
91
92         switch (s) {
93         }
94
95         
96         switch (s) {
97             default:
98                 System.out.println("");
99                 break;
100         }
101         
102     }
103     
104 }
105
Popular Tags