View Javadoc

1   /*
2    * $Id: AddressTO.java 7976 2007-08-21 14:26:13Z dirk.olmes $
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 CPAL v1.0
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 org.mule.samples.voipservice.LocaleMessage;
14  
15  import java.io.Serializable;
16  import java.util.ArrayList;
17  import java.util.List;
18  
19  /**
20   * @author Binildas Christudas
21   */
22  public class AddressTO implements Serializable, Cloneable
23  {
24      /**
25       * Serial version
26       */
27      private static final long serialVersionUID = 6721555269589989794L;
28  
29      private String houseNumber;
30      private String street;
31      private String city;
32  
33      private static final List ADDRESSES;
34  
35      static
36      {
37          ADDRESSES = new ArrayList();
38  
39          ADDRESSES.add(new AddressTO("123", "Koudiar Palace", "Trivandrum"));
40          ADDRESSES.add(new AddressTO("222", "Lake View", "Cochin"));
41          ADDRESSES.add(new AddressTO("345", "Spencer Town", "Chennai"));
42          ADDRESSES.add(new AddressTO("898", "Electronics City", "Bangalore"));
43          ADDRESSES.add(new AddressTO("554", "Kovalam Beach", "Trivandrum"));
44          ADDRESSES.add(new AddressTO("101", "Anzyl Grove", "Pune"));
45          ADDRESSES.add(new AddressTO("369", "Victoria Terminus", "Mumbai"));
46          ADDRESSES.add(new AddressTO("876", "Ponmudi Hills", "Trivandrum"));
47          ADDRESSES.add(new AddressTO("777", "White Field", "Bangalore"));
48          ADDRESSES.add(new AddressTO("908", "Varkala Palms", "Trivandrum"));
49  
50      }
51  
52      public AddressTO()
53      {
54          super();
55      }
56  
57      public AddressTO(String houseNumber, String street, String city)
58      {
59  
60          this.houseNumber = houseNumber;
61          this.street = street;
62          this.city = city;
63      }
64  
65      public void setHouseNumber(String houseNumber)
66      {
67          this.houseNumber = houseNumber;
68      }
69  
70      public String getHouseNumber()
71      {
72          return houseNumber;
73      }
74  
75      public void setStreet(String street)
76      {
77          this.street = street;
78      }
79  
80      public String getStreet()
81      {
82          return street;
83      }
84  
85      public void setCity(String city)
86      {
87          this.city = city;
88      }
89  
90      public String getCity()
91      {
92          return city;
93      }
94  
95      public Object clone()
96      {
97          Object clone = null;
98          try
99          {
100             clone = super.clone();
101         }
102         catch (CloneNotSupportedException cloneNotSupportedException)
103         {
104             // too bad
105         }
106         return clone;
107     }
108 
109     public String toString()
110     {
111         StringBuffer stringBuffer = new StringBuffer();
112         if (this.houseNumber != null)
113         {
114             stringBuffer.append(LocaleMessage.getHouseCaption(houseNumber));
115         }
116         if (this.street != null)
117         {
118             stringBuffer.append(LocaleMessage.getStreetCaption(street));
119         }
120         if (this.city != null)
121         {
122             stringBuffer.append(LocaleMessage.getCityCaption(city));
123         }
124         return stringBuffer.toString();
125     }
126 
127     public static AddressTO getRandomAddress()
128     {
129 
130         int index = new Double(Math.random() * 10).intValue();
131         // AddressTO addressTO = (AddressTO) ADDRESSES.get(index);
132         return (AddressTO)((AddressTO)ADDRESSES.get(index)).clone();
133     }
134 
135 }