KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > RPCDispatch > Data


1 package test.RPCDispatch;
2  
3 /**
4  * Test structure used by the RPCDispatch test
5  *
6  * @author Sam Ruby <rubys@us.ibm.com>
7  */

8 public class Data {
9
10     // items of the structure. Defined as Objects so as to permit nulls
11
private int field1;
12     private String JavaDoc field2;
13     private int field3;
14
15     /**
16      * null constructor
17      */

18     public Data() {}
19
20     /**
21      * convenience constructor that sets all of the fields
22      */

23     public Data(int field1, String JavaDoc field2, int field3) {
24         this.field1=field1;
25         this.field2=field2;
26         this.field3=field3;
27     }
28
29     /**
30      * bean getter for field1
31      */

32     public int getField1() {
33         return field1;
34     }
35
36     /**
37      * bean setter for field1
38      */

39     public void setField1 (int field1) {
40         this.field1=field1;
41     }
42
43     /**
44      * bean getter for field2
45      */

46     public String JavaDoc getField2() {
47         return field2;
48     }
49
50     /**
51      * bean setter for field2
52      */

53     public void setField2 (String JavaDoc field2) {
54         this.field2=field2;
55     }
56
57     /**
58      * bean getter for field3
59      */

60     public int getField3() {
61         return field3;
62     }
63
64     /**
65      * bean setter for field3
66      */

67     public void setField3 (int field3) {
68         this.field3=field3;
69     }
70
71     /**
72      * Equality comparison.
73      */

74     public boolean equals(Object JavaDoc object) {
75         if (!(object instanceof Data)) return false;
76
77         Data that= (Data) object;
78
79         if (this.field1 != that.field1) return false;
80         if (this.field3 != that.field3) return false;
81
82         if (this.field2 == null) {
83             if (that.field2 != null) return false;
84         } else {
85             if (!this.field2.equals(that.field2)) return false;
86         }
87
88         return true;
89     };
90 }
91
Popular Tags