KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.puppycrawl.tools.checkstyle.usage;
2
3 /** Test input for unread method check */
4 public class InputUnusedMethod
5 {
6
7     private void methodUnused0()
8     {
9     }
10
11     private void methodUsed0()
12     {
13     }
14     
15     private void methodUsed1(int aParam)
16     {
17     }
18     
19     private void methodUsed1(double aParam)
20     {
21     }
22     
23     private void methodUsed1(String JavaDoc aParam)
24     {
25     }
26     
27     public static void main(String JavaDoc[] args)
28     {
29         InputUnusedMethod method = new InputUnusedMethod();
30         method.methodUsed0();
31         method.methodUsed1(0 + 4);
32         method.methodUsed1(Math.sqrt(2.0));
33         method.methodUsed1("" + "a");
34     }
35 }
36
37 interface InterfaceMethod
38 {
39     public void method(int aParam);
40 }
41
42 abstract class AbstractClassMethod
43 {
44     public abstract void method(int aParam);
45 }
46
47 /** Test for bug 880954: false positive when parentheses around second term
48  * of ternary operator.
49  */

50 class Ternary
51 {
52     private int m()
53     {
54         return 1;
55     }
56     
57     public void m1()
58     {
59         int i = 0;
60         int j = (i == 0) ? (i) : m();
61     }
62 }
63
64 class SerializableTest implements java.io.Serializable JavaDoc
65 {
66     private void writeObject(java.io.ObjectOutputStream JavaDoc out) throws java.io.IOException JavaDoc
67     {
68         // it's ok to have this method in serializable class
69
}
70
71     private void readObject(java.io.ObjectInputStream JavaDoc in) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc
72     {
73         // it's ok to have this method in serializable class
74
}
75
76     private Object JavaDoc writeReplace() throws java.io.ObjectStreamException JavaDoc
77     {
78         // it's ok to have this method in serializable class
79
return new SerializableTest();
80     }
81
82     private Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc
83     {
84         // it's ok to have this method in serializable class
85
return new SerializableTest();
86     }
87 }
88
89 class BadSerializableTest1 implements java.io.Serializable JavaDoc
90 {
91     private void writeObject(Object JavaDoc out) throws java.io.IOException JavaDoc
92     {
93     }
94
95     private void writeObject(java.io.ObjectOutputStream JavaDoc out, int i) throws java.io.IOException JavaDoc
96     {
97     }
98
99     private void writeObject(java.io.ObjectOutputStream JavaDoc out)
100     {
101     }
102
103     private void readObject(java.io.ObjectInputStream JavaDoc in) throws java.io.IOException JavaDoc
104     {
105     }
106
107     private void readObject(Object JavaDoc in) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc
108     {
109     }
110
111     private int writeReplace() throws java.io.ObjectStreamException JavaDoc
112     {
113         return 1;
114     }
115
116     private Object JavaDoc writeReplace(int i) throws java.io.ObjectStreamException JavaDoc
117     {
118         return new SerializableTest();
119     }
120
121     private int readResolve() throws java.io.ObjectStreamException JavaDoc
122     {
123         return 1;
124     }
125
126     private Object JavaDoc readResolve(int i) throws java.io.ObjectStreamException JavaDoc
127     {
128         return new SerializableTest();
129     }
130 }
131
132 class BadSerializableTest2 implements java.io.Serializable JavaDoc
133 {
134     private int writeObject(java.io.ObjectOutputStream JavaDoc out) throws java.io.IOException JavaDoc
135     {
136         return 1;
137     }
138
139     private void readObject(java.io.ObjectInputStream JavaDoc in) throws ClassNotFoundException JavaDoc
140     {
141     }
142
143     private Object JavaDoc readResolve()
144     {
145         return new SerializableTest();
146     }
147 }
148
149 class BadSerializableTest3 implements java.io.Serializable JavaDoc
150 {
151     private int readObject(java.io.ObjectInputStream JavaDoc in) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc
152     {
153         return 1;
154     }
155 }
156
Popular Tags