| 1 package sellwin.domain; 2 3 import java.util.*; 4 import java.io.*; 5 6 10 16 public class Address implements Serializable { 17 public final static String [] STATES = { 18 "AL", "AK", "AZ", "AR", 19 "CA", "CO", "CT", "DE", 20 "DC", "FL", "GA", "HI", 21 "ID", "IL", "IN", "IA", 22 "KS", "KY", "LA", "ME", 23 "MD", "MA", "MI", "MN", 24 "MS", "MO", "MT", "NE", 25 "NV", "NH", "NJ", "NM", 26 "NY", "NC", "ND", "OH", 27 "OK", "OR", "PA", "RI", 28 "SC", "SD", "TN", "TX", 29 "UT", "VT", "VA", "WA", 30 "WV", "WI", "WY" 31 }; 32 33 private long pk; 34 private String firstName; 35 private String lastName; 36 private String middleInitial; 37 private String addressLine1; 38 private String addressLine2; 39 private String title; 40 private String phone; 41 private String fax; 42 private String pager; 43 private String cell; 44 private String email; 45 private String city; 46 private String state; 47 private String country; 48 private String zip; 49 private String zip4; 50 private String modifiedBy; 51 private Date modifiedDate; 52 private boolean modified=false; 53 54 public Address() { 55 pk=0; 56 firstName=""; 57 lastName=""; 58 middleInitial=" "; 59 addressLine1=" "; 60 addressLine2=" "; 61 title=" "; 62 phone=" "; 63 fax=" "; 64 pager=" "; 65 cell=" "; 66 email=" "; 67 city=" "; 68 state=" "; 69 country="USA"; 70 zip=" "; 71 zip4=" "; 72 modifiedBy=""; 73 modifiedDate = new Date(); 74 } 75 76 public final void setPK(long p) { pk = p; } 77 public final void setCity(String s) { city = s; } 78 public final void setState(String s) { state = s; } 79 public final void setCountry(String s) { country = s; } 80 public final void setZip(String s) { zip = s; } 81 public final void setZip4(String s) { zip4 = s; } 82 public final void setAddressLine1(String s) { addressLine1 = s; } 83 public final void setAddressLine2(String s) { addressLine2 = s; } 84 public final void setFirstName(String s) { firstName = s; } 85 public final void setLastName(String s) { lastName = s; } 86 public final void setMiddleInitial(String s) { middleInitial = s; } 87 public final void setTitle(String s) { title = s; } 88 public final void setPhone(String s) { phone = s; } 89 public final void setFax(String s) { fax = s; } 90 public final void setPager(String s) { pager = s; } 91 public final void setCell(String s) { cell = s; } 92 public final void setEmail(String s) { email = s; } 93 public final void setModifiedBy(String s) { modifiedBy = s; } 94 public final void setModifiedDate(Date s) { modifiedDate = s; } 95 public final void setModified(boolean b) { modified = b; } 96 97 public final long getPK() { return pk; } 98 public final String getAddressLine1() { return addressLine1; } 99 public final String getAddressLine2() { return addressLine2; } 100 public final String getCity() { return city; } 101 public final String getState() { return state; } 102 public final String getCountry() { return country; } 103 public final String getZip() { return zip; } 104 public final String getZip4() { return zip4; } 105 public final String getFirstName() { return firstName; } 106 public final String getLastName() { return lastName ; } 107 public final String getMiddleInitial() { return middleInitial; } 108 public final String getTitle() { return title;} 109 public final String getPhone() { return phone; } 110 public final String getFax() { return fax; } 111 public final String getPager() { return pager;} 112 public final String getCell() { return cell; } 113 public final String getEmail() { return email; } 114 public final String getModifiedBy() { return modifiedBy; } 115 public final Date getModifiedDate() { return modifiedDate; } 116 public final boolean isModified() { return modified; } 117 118 public final String getFormattedName() { 119 StringBuffer str = new StringBuffer (); 120 121 if (getLastName() == null) { 122 ; 123 } else { 124 str.append(getLastName()).append(", "); 125 } 126 127 if (getFirstName() == null) { 128 ; 129 } else { 130 str.append(getFirstName()).append(" "); 131 } 132 133 if (getMiddleInitial() == null) { 134 ; 135 } else { 136 str.append(getMiddleInitial()); 137 } 138 139 return str.toString(); 140 } 142 143 public final void print() { 144 System.out.println(" ADDRESS--->"); 145 System.out.println(" pk=" + pk); 146 System.out.println(" fname=["+ firstName + "]"); 147 System.out.println(" lname=["+ lastName + "]"); 148 System.out.println(" mi=["+ middleInitial + "]"); 149 System.out.println(" line1=["+ addressLine1 + "]"); 150 System.out.println(" line2=["+ addressLine2 + "]"); 151 System.out.println(" title=["+ title + "]"); 152 System.out.println(" phone=["+ phone + "]"); 153 System.out.println(" fax=["+ fax + "]"); 154 System.out.println(" pager=["+ pager + "]"); 155 System.out.println(" cell=["+ cell + "]"); 156 System.out.println(" email=["+ email + "]"); 157 System.out.println(" city=["+ city + "]"); 158 System.out.println(" state=["+ state + "]"); 159 System.out.println(" country=["+ country + "]"); 160 System.out.println(" zip=[" + zip + "]"); 161 System.out.println(" zip4=["+ zip4 + "]"); 162 } 163 164 public final Address copy() { 165 Address copy = new Address(); 166 copy.pk = pk; 167 if (firstName != null) 168 copy.firstName = new String (firstName); 169 if (lastName != null) 170 copy.lastName = new String (lastName); 171 if (middleInitial != null) 172 copy.middleInitial = new String (middleInitial); 173 if (addressLine1 != null) 174 copy.addressLine1 = new String (addressLine1); 175 if (addressLine2 != null) 176 copy.addressLine2 = new String (addressLine2); 177 if (title != null) 178 copy.title = new String (title); 179 if (phone != null) 180 copy.phone = new String (phone); 181 if (fax != null) 182 copy.fax = new String (fax); 183 if (pager != null) 184 copy.pager = new String (pager); 185 if (cell != null) 186 copy.cell = new String (cell); 187 if (email != null) 188 copy.email = new String (email); 189 if (city != null) 190 copy.city = new String (city); 191 if (state != null) 192 copy.state = new String (state); 193 if (country != null) 194 copy.country = new String (country); 195 if (zip != null) 196 copy.zip = new String (zip); 197 if (zip4 != null) 198 copy.zip4 = new String (zip4); 199 copy.modifiedDate = new Date(modifiedDate.getTime()); 200 copy.modified = modified; 201 if (modifiedBy != null) 202 copy.modifiedBy = new String (modifiedBy); 203 204 return copy; 205 } 206 207 public static void copyFields(Address to, Address from) { 208 to.setAddressLine1(from.getAddressLine1()); 209 to.setAddressLine2(from.getAddressLine2()); 210 to.setCity(from.getCity()); 211 to.setState(from.getState()); 212 to.setCountry(from.getCountry()); 213 to.setZip(from.getZip()); 214 to.setZip4(from.getZip4()); 215 to.setFirstName(from.getFirstName()); 216 to.setLastName(from.getLastName()); 217 to.setMiddleInitial(from.getMiddleInitial()); 218 to.setTitle(from.getTitle()); 219 to.setPhone(from.getPhone()); 220 to.setFax(from.getFax()); 221 to.setPager(from.getPager()); 222 to.setCell(from.getCell()); 223 to.setEmail(from.getEmail()); 224 to.setModified(from.isModified()); 225 } 226 227 public final boolean diff(Address from) { 228 if (!getAddressLine1().equals(from.getAddressLine1())) 229 return true; 230 if (!getAddressLine2().equals(from.getAddressLine2())) 231 return true; 232 if (!getCity().equals(from.getCity())) 233 return true; 234 if (!getState().equals(from.getState())) 235 return true; 236 if (!getCountry().equals(from.getCountry())) 237 return true; 238 if (!getZip().equals(from.getZip())) 239 return true; 240 if (!getZip4().equals(from.getZip4())) 241 return true; 242 if (!getFirstName().equals(from.getFirstName())) 243 return true; 244 if (!getLastName().equals(from.getLastName())) 245 return true; 246 if (!getMiddleInitial().equals(from.getMiddleInitial())) 247 return true; 248 if (!getTitle().equals(from.getTitle())) 249 return true; 250 if (!getPhone().equals(from.getPhone())) 251 return true; 252 if (!getFax().equals(from.getFax())) 253 return true; 254 if (!getPager().equals(from.getPager())) 255 return true; 256 if (!getCell().equals(from.getCell())) 257 return true; 258 if (!getEmail().equals(from.getEmail())) 259 return true; 260 261 return false; 262 } 263 } 264 | Popular Tags |