001 package com.bea.medrec.beans;
002
003 import com.bea.medrec.utils.MedRecWebAppUtils;
004 import com.bea.medrec.value.Address;
005
006 /**
007 * <p>Form bean for addresses.
008 * This form has the following fields,
009 * with default values in square brackets:
010 * <ul>
011 * <li><b>streetName1</b> - Entered street name 1 value
012 * <li><b>streetName2</b> - Entered street name 2 value
013 * <li><b>city</b> - Entered city value
014 * <li><b>state</b> - Entered state value
015 * <li><b>zipCode</b> - Entered zip code value
016 * <li><b>country</b> - Entered country value
017 * </ul>
018 * </p>
019 *
020 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
021 */
022 public final class AddressBean extends BaseBean {
023
024 // Instance Variables
025 private String streetName1 = null;
026 private String streetName2 = null;
027 private String city = null;
028 private String state = null;
029 private String zipCode = null;
030 private String country = null;
031
032 // Constructors
033 public AddressBean() {
034 }
035
036 public AddressBean(Address address) {
037 super.setId(address.getId());
038 this.streetName1 = address.getStreetName1();
039 this.streetName2 = address.getStreetName2();
040 this.city = address.getCity();
041 this.state = address.getState();
042 this.zipCode = address.getZipCode();
043 this.country = address.getCountry();
044 }
045
046 public AddressBean(String id,
047 String streetName1,
048 String streetName2,
049 String city,
050 String state,
051 String zipCode,
052 String country) {
053 super.setId(id);
054 this.streetName1 = streetName1;
055 this.streetName2 = streetName2;
056 this.city = city;
057 this.state = state;
058 this.zipCode = zipCode;
059 this.country = country;
060 }
061
062 public AddressBean(Integer id,
063 String streetName1,
064 String streetName2,
065 String city,
066 String state,
067 String zipCode,
068 String country) {
069 super.setId(id);
070 this.streetName1 = streetName1;
071 this.streetName2 = streetName2;
072 this.city = city;
073 this.state = state;
074 this.zipCode = zipCode;
075 this.country = country;
076 }
077
078 public String getStreetName1() {
079 return this.streetName1;
080 }
081
082 public String getStreetName2() {
083 return this.streetName2;
084 }
085
086 public String getCity() {
087 return this.city;
088 }
089
090 public String getState() {
091 return this.state;
092 }
093
094 public String getZipCode() {
095 return this.zipCode;
096 }
097
098 public String getCountry() {
099 return this.country;
100 }
101
102 public void setStreetName1(String streetName1) {
103 this.streetName1 = MedRecWebAppUtils.cleanParam(streetName1);
104 }
105
106 public void setStreetName2(String streetName2) {
107 this.streetName2 = MedRecWebAppUtils.cleanParam(streetName2);
108 }
109
110 public void setCity(String city) {
111 this.city = MedRecWebAppUtils.cleanParam(city);
112 }
113
114 public void setState(String state) {
115 this.state = MedRecWebAppUtils.cleanParam(state);
116 }
117
118 public void setZipCode(String zipCode) {
119 this.zipCode = MedRecWebAppUtils.cleanParam(zipCode);
120 }
121
122 public void setCountry(String country) {
123 this.country = MedRecWebAppUtils.cleanParam(country);
124 }
125
126 // Public Methods
127 public void reset() {
128 this.streetName1 = "";
129 this.streetName2 = "";
130 this.city = "";
131 this.state = "";
132 this.zipCode = "";
133 this.country = "";
134 }
135
136 /**
137 * <p>Converts address presentation bean to address value object.</p>
138 *
139 * @return Address
140 */
141 public Address toAddress() {
142 return new Address(this.getId(),
143 this.getStreetName1(),
144 this.getStreetName2(),
145 this.getCity(),
146 this.getState(),
147 this.getZipCode(),
148 this.getCountry());
149 }
150
151
152 public String toString() {
153 StringBuffer str = new StringBuffer();
154 str.append("Address[Id: " + super.getId());
155 str.append(" | StreetName1: " + streetName1);
156 str.append(" | StreetName2: " + streetName2);
157 str.append(" | City: " + city);
158 str.append(" | State: " + state);
159 str.append(" | ZipCode: " + zipCode);
160 str.append(" | Country: " + country);
161 str.append("]");
162
163 return str.toString();
164 }
165 }
|