KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > samples > voipservice > to > AddressTO


1 /*
2  * $Id: AddressTO.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.samples.voipservice.to;
12
13 import java.io.Serializable JavaDoc;
14 import java.util.ArrayList JavaDoc;
15 import java.util.List JavaDoc;
16
17 /**
18  * @author Binildas Christudas
19  */

20 public class AddressTO implements Serializable JavaDoc, Cloneable JavaDoc
21 {
22     /**
23      * Serial version
24      */

25     private static final long serialVersionUID = 6721555269589989794L;
26
27     private String JavaDoc houseNumber;
28     private String JavaDoc street;
29     private String JavaDoc city;
30
31     private static final List JavaDoc ADDRESSES;
32
33     static
34     {
35         ADDRESSES = new ArrayList JavaDoc();
36
37         ADDRESSES.add(new AddressTO("123", "Koudiar Palace", "Trivandrum"));
38         ADDRESSES.add(new AddressTO("222", "Lake View", "Cochin"));
39         ADDRESSES.add(new AddressTO("345", "Spencer Town", "Chennai"));
40         ADDRESSES.add(new AddressTO("898", "Electronics City", "Bangalore"));
41         ADDRESSES.add(new AddressTO("554", "Kovalam Beach", "Trivandrum"));
42         ADDRESSES.add(new AddressTO("101", "Anzyl Grove", "Pune"));
43         ADDRESSES.add(new AddressTO("369", "Victoria Terminus", "Mumbai"));
44         ADDRESSES.add(new AddressTO("876", "Ponmudi Hills", "Trivandrum"));
45         ADDRESSES.add(new AddressTO("777", "White Field", "Bangalore"));
46         ADDRESSES.add(new AddressTO("908", "Varkala Palms", "Trivandrum"));
47
48     }
49
50     public AddressTO()
51     {
52         super();
53     }
54
55     public AddressTO(String JavaDoc houseNumber, String JavaDoc street, String JavaDoc city)
56     {
57
58         this.houseNumber = houseNumber;
59         this.street = street;
60         this.city = city;
61     }
62
63     public void setHouseNumber(String JavaDoc houseNumber)
64     {
65         this.houseNumber = houseNumber;
66     }
67
68     public String JavaDoc getHouseNumber()
69     {
70         return houseNumber;
71     }
72
73     public void setStreet(String JavaDoc street)
74     {
75         this.street = street;
76     }
77
78     public String JavaDoc getStreet()
79     {
80         return street;
81     }
82
83     public void setCity(String JavaDoc city)
84     {
85         this.city = city;
86     }
87
88     public String JavaDoc getCity()
89     {
90         return city;
91     }
92
93     public Object JavaDoc clone()
94     {
95         Object JavaDoc clone = null;
96         try
97         {
98             clone = super.clone();
99         }
100         catch (CloneNotSupportedException JavaDoc cloneNotSupportedException)
101         {
102             // too bad
103
}
104         return clone;
105     }
106
107     public String JavaDoc toString()
108     {
109         StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
110         if (this.houseNumber != null)
111         {
112             stringBuffer.append("[HouseNumber : " + houseNumber + "; ");
113         }
114         if (this.street != null)
115         {
116             stringBuffer.append("Street : " + street + "; ");
117         }
118         if (this.houseNumber != null)
119         {
120             stringBuffer.append("City : " + city + "]");
121         }
122         return stringBuffer.toString();
123     }
124
125     public static AddressTO getRandomAddress()
126     {
127
128         int index = new Double JavaDoc(Math.random() * 10).intValue();
129         // AddressTO addressTO = (AddressTO) ADDRESSES.get(index);
130
return (AddressTO)((AddressTO)ADDRESSES.get(index)).clone();
131     }
132
133 }
134
Popular Tags