KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > usage > InputUnusedField


1 package com.puppycrawl.tools.checkstyle.usage;
2
3 import java.awt.Rectangle JavaDoc;
4
5 /** Test input for unused field check */
6 public class InputUnusedField
7 {
8     private int mReadPrimitive;
9     private int mPrimitive;
10     private int mUnreadPrimitive;
11     private String JavaDoc mReadString;
12     private String JavaDoc mReadString2;
13     private Rectangle JavaDoc mRectangle;
14     private int[] mArray;
15     private int[] mArray2;
16     private int[] mUnreadArray;
17     private int mThisPrimitive;
18     
19     private int mInitializer = 0;
20     private int mUnused2 = mInitializer;
21     
22     private static final int SUNUSED = 0;
23     private static int USED;
24
25     static
26     {
27         USED = 0;
28     }
29     
30     public InputUnusedField()
31     {
32         int i = mReadPrimitive;
33     }
34
35     private void method()
36     {
37         int i = mReadString.length();
38         "".equals(mReadString2);
39         int j = mRectangle.x;
40         i = mArray[0];
41         mArray2[0] = 0;
42         this.mThisPrimitive = 1;
43     }
44     
45     private void shadow()
46     {
47         int mUnreadPrimitive = 0;
48         mUnreadPrimitive++;
49         
50         int[] mUnreadArray = {0};
51         int i = mUnreadArray[0];
52     }
53     
54     {
55         mPrimitive = 0;
56     }
57 }
58
59 class Outer
60 {
61     private int mUsed1;
62     private int mUsed2;
63     private int mUsed3;
64     private int mUnused;
65     
66     private class Inner
67     {
68         public Inner()
69         {
70             int i = mUsed1;
71         }
72         
73         public void method()
74         {
75             mUsed2 = 0;
76         }
77         
78         {
79             mUsed3 = 0;
80         }
81     }
82 }
83
84 class ParenthesizedExpression
85 {
86     private int mUsed1 = 1;
87     private int mUsed2 = 1;
88     private boolean mUsed3 = true;
89     
90     public void testParentheses()
91     {
92         int x = 0;
93         int a = (x++) / mUsed1;
94         int b = (a - 1) << mUsed2;
95         boolean c = (a == b) || mUsed3;
96     }
97 }
98
Popular Tags