1 16 17 package org.apache.taglibs.standard.examples.beans; 18 19 import java.util.Date ; 20 import java.text.*; 21 22 28 29 public class Customer { 30 31 34 35 int key; 36 37 38 private String lastName; 39 40 41 private String firstName; 42 43 44 private Date birthDate; 45 46 47 private Address address; 48 49 50 private String phoneHome; 51 52 53 private String phoneCell; 54 55 static DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); 56 57 60 public Customer() {} 61 62 public Customer(int key, 63 String lastName, 64 String firstName, 65 Date birthDate, 66 Address address, 67 String phoneHome, 68 String phoneCell) { 69 init(key, lastName, firstName, birthDate, address, phoneHome, phoneCell); 70 } 71 72 public void init(int key, 73 String lastName, 74 String firstName, 75 Date birthDate, 76 Address address, 77 String phoneHome, 78 String phoneCell) { 79 setKey(key); 80 setLastName(lastName); 81 setFirstName(firstName); 82 setBirthDate(birthDate); 83 setAddress(address); 84 setPhoneHome(phoneHome); 85 setPhoneCell(phoneCell); 86 } 87 88 91 95 public int getKey() { 96 return key; 97 } 98 99 103 public void setKey(int key) { 104 this.key = key; 105 } 106 107 111 public String getLastName() { 112 return lastName; 113 } 114 115 119 public void setLastName(String lastName) { 120 this.lastName = lastName; 121 } 122 123 127 public String getFirstName() { 128 return firstName; 129 } 130 131 135 public void setFirstName(String firstName) { 136 this.firstName = firstName; 137 } 138 139 143 public Date getBirthDate() { 144 return birthDate; 145 } 146 147 151 public void setBirthDate(Date birthDate) { 152 this.birthDate = birthDate; 153 } 154 155 159 public Address getAddress() { 160 return address; 161 } 162 163 167 public void setAddress(Address address) { 168 this.address = address; 169 } 170 171 175 public String getPhoneHome() { 176 return phoneHome; 177 } 178 179 183 public void setPhoneHome(String phoneHome) { 184 this.phoneHome = phoneHome; 185 } 186 187 191 public String getPhoneCell() { 192 return phoneCell; 193 } 194 195 199 public void setPhoneCell(String phoneCell) { 200 this.phoneCell = phoneCell; 201 } 202 203 206 209 public String toString() { 210 StringBuffer sb = new StringBuffer (); 211 sb.append("[").append(key).append("] "); 212 sb.append(getLastName()).append(", "); 213 sb.append(getFirstName()).append(" "); 214 sb.append(df.format(getBirthDate())).append(" "); 215 sb.append(getAddress()).append(" "); 216 if(getPhoneHome() != null) sb.append(getPhoneHome()).append(" "); 217 if(getPhoneCell() != null) sb.append(getPhoneCell()); 218 return (sb.toString()); 219 } 220 } 221 222 | Popular Tags |