KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > ubiquity > tools > checkstyle > tests > InputDeclarationOrder


1 package net.ubiquity.tools.checkstyle.tests;
2
3 public class InputDeclarationOrder
4 {
5     static final int FOO2 = 3;
6
7     // error public before package
8
public static final int FOO = 3;
9     
10     private static final int FOO3 = 3;
11    
12     // eror public before package and private
13
public static final int FOO4 = 3;
14
15     private static final String JavaDoc ERROR = "error";
16
17     // error protected before private
18
protected static final String JavaDoc ERROR1 = "error";
19    
20     // error public before private
21
public static final String JavaDoc WARNING = "warning";
22     
23     private int mMaxInitVars = 3;
24     
25     // error statics should be before instance members
26
// error publics before private
27
public static final int MAX_ITER_VARS = 3;
28
29     private class InnerClass
30     {
31         private static final int INNER_FOO = 2;
32        
33         // error public before private
34
public static final int INNER_FOO2 = 2;
35
36         public InnerClass()
37         {
38             int foo = INNER_FOO;
39             foo += INNER_FOO2;
40             foo += INNER_FOO3;
41         }
42
43         // error member variables should be before methods or ctors
44
// error public before private
45
public static final int INNER_FOO3 = 2;
46     }
47
48     public int getFoo1()
49     {
50         return mFoo;
51     }
52
53     // error ctors before methods
54
public InputDeclarationOrder()
55     {
56         String JavaDoc foo = ERROR;
57         foo += ERROR1;
58         foo += WARNING;
59         int fooInt = mMaxInitVars;
60         fooInt += MAX_ITER_VARS;
61         fooInt += mFoo;
62     }
63
64     public static int getFoo2()
65     {
66         return 13;
67     }
68
69     public int getFoo()
70     {
71         return mFoo;
72     }
73
74     private static int getFoo21()
75     {
76         return 14;
77     }
78
79     // error member variables should be before methods or ctors
80
private int mFoo = 0;
81 }
82
83 enum InputDeclarationOrderEnum
84 {
85     ENUM_VALUE_1,
86     ENUM_VALUE_2,
87     ENUM_VALUE_3
88     {
89         private static final int INNER_FOO = 2;
90
91         // error public before private
92
public static final int INNER_FOO2 = 2;
93
94         public void doIt()
95         {
96         }
97
98         // error member variables should be before methods or ctors
99
// error public before private
100
public static final int INNER_FOO3 = 2;
101     };
102
103     static final int FOO2 = 3;
104
105     // error public before package
106
public static final int FOO = 3;
107
108     private static final int FOO3 = 3;
109
110     // eror public before package and private
111
public static final int FOO4 = 3;
112
113     private static final String JavaDoc ERROR = "error";
114
115     // error protected before private
116
protected static final String JavaDoc ERROR1 = "error";
117
118     // error public before private
119
public static final String JavaDoc WARNING = "warning";
120
121     private int mMaxInitVars = 3;
122
123     // error statics should be before instance members
124
// error publics before private
125
public static final int MAX_ITER_VARS = 3;
126
127     private class InnerClass
128     {
129         private static final int INNER_FOO = 2;
130
131         // error public before private
132
public static final int INNER_FOO2 = 2;
133
134         public InnerClass()
135         {
136             int foo = INNER_FOO;
137             foo += INNER_FOO2;
138             foo += INNER_FOO3;
139         }
140
141         // error member variables should be before methods or ctors
142
// error public before private
143
public static final int INNER_FOO3 = 2;
144     }
145
146     public int getFoo1()
147     {
148         return mFoo;
149     }
150
151     // error ctors before methods
152
InputDeclarationOrderEnum()
153     {
154         String JavaDoc foo = ERROR;
155         foo += ERROR1;
156         foo += WARNING;
157         int fooInt = mMaxInitVars;
158         fooInt += MAX_ITER_VARS;
159         fooInt += mFoo;
160     }
161
162     public static int getFoo2()
163     {
164         return 2;
165     }
166
167     public int getFoo()
168     {
169         return mFoo;
170     }
171
172     private static int getFoo21()
173     {
174         return 1;
175     }
176
177     // error member variables should be before methods or ctors
178
private int mFoo = 0;
179 }
180
Popular Tags