KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > marshall > data > Address


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.marshall.data;
8
9 import java.io.Serializable JavaDoc;
10
11
12 /**
13  */

14 public class Address implements Serializable JavaDoc
15 {
16    String JavaDoc street = null;
17    String JavaDoc city = "San Jose";
18    int zip = 0;
19
20    public Address()
21    {
22
23    }
24
25    public String JavaDoc getStreet()
26    {
27       return street;
28    }
29
30    public void setStreet(String JavaDoc street)
31    {
32       this.street = street;
33    }
34
35    public String JavaDoc getCity()
36    {
37 // System.out.println("********* getting city of " +city);
38
return city;
39    }
40
41    public void setCity(String JavaDoc city)
42    {
43 // System.out.println("********* setting city of " +city);
44
this.city = city;
45    }
46
47    public int getZip()
48    {
49       return zip;
50    }
51
52    public void setZip(int zip)
53    {
54       this.zip = zip;
55    }
56
57    public String JavaDoc toString()
58    {
59       return "street=" + getStreet() + ", city=" + getCity() + ", zip=" + getZip();
60    }
61
62 // public Object writeReplace() {
63
// return this;
64
// }
65

66    public boolean equals(Object JavaDoc o)
67    {
68       if (this == o) return true;
69       if (o == null || getClass() != o.getClass()) return false;
70
71       final Address address = (Address) o;
72
73       if (zip != address.zip) return false;
74       if (city != null ? !city.equals(address.city) : address.city != null) return false;
75       if (street != null ? !street.equals(address.street) : address.street != null) return false;
76
77       return true;
78    }
79
80    public int hashCode()
81    {
82       int result;
83       result = (street != null ? street.hashCode() : 0);
84       result = 29 * result + (city != null ? city.hashCode() : 0);
85       result = 29 * result + zip;
86       return result;
87    }
88 }
89
Popular Tags