KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > consumerwebsite > CustomerBean


1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any
21 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
22 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
24 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
25 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
27 * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
28 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
29 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
30 * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
31 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that Software is not designed, licensed or intended
34 * for use in the design, construction, operation or maintenance of
35 * any nuclear facility.
36 */

37
38 package com.sun.j2ee.blueprints.consumerwebsite;
39
40 import java.io.Serializable JavaDoc;
41
42 // customer component imports
43
import com.sun.j2ee.blueprints.customer.Address;
44 import com.sun.j2ee.blueprints.customer.ContactInformation;
45 import com.sun.j2ee.blueprints.customer.Account;
46
47 /**
48  * A JavaBeans component representing an account.
49  */

50 public class CustomerBean implements Serializable JavaDoc {
51
52
53     private String JavaDoc userId = null;
54     private String JavaDoc streetName1;
55     private String JavaDoc streetName2;
56     private String JavaDoc city;
57     private String JavaDoc state;
58     private String JavaDoc zipCode;
59     private String JavaDoc country;
60     private String JavaDoc telephone;
61     private String JavaDoc email;
62     private Address address;
63     private String JavaDoc familyName;
64     private String JavaDoc givenName;
65
66
67     public CustomerBean(Account acct) {
68       this.userId = acct.getUserId();
69
70       this.streetName1 = acct.getContactInformation().getAddress().getStreetName1();
71       this.streetName2 = acct.getContactInformation().getAddress().getStreetName2();
72       this.city = acct.getContactInformation().getAddress().getCity();
73       this.state = acct.getContactInformation().getAddress().getState();
74       this.zipCode = acct.getContactInformation().getAddress().getZipCode();
75       this.country = acct.getContactInformation().getAddress().getCountry();
76
77       this.givenName = acct.getContactInformation().getGivenName();
78       this.familyName = acct.getContactInformation().getFamilyName();
79       this.email = acct.getContactInformation().getEMail();
80       this.telephone = acct.getContactInformation().getTelephone();
81     }
82
83     public CustomerBean(String JavaDoc userId, String JavaDoc streetName1, String JavaDoc streetName2,
84       String JavaDoc city, String JavaDoc state, String JavaDoc zipCode,
85       String JavaDoc country, String JavaDoc familyName, String JavaDoc givenName,
86       String JavaDoc telephone, String JavaDoc email) {
87       this.userId = userId;
88       this.streetName1 = streetName1;
89       this.streetName2 = streetName2;
90       this.city = city;
91       this.state = state;
92       this.zipCode = zipCode;
93       this.country = country;
94       this.givenName = givenName;
95       this.familyName = familyName;
96       this.email = email;
97       this.telephone = telephone;
98     }
99
100        //getter methods
101

102    public String JavaDoc getUserId() {
103         return userId;
104     }
105     
106     public String JavaDoc getStreetName1() {
107   return streetName1;
108     }
109
110     public String JavaDoc getStreetName2() {
111   return streetName2;
112     }
113
114     public String JavaDoc getCity() {
115   return city;
116     }
117
118     public String JavaDoc getState() {
119   return state;
120     }
121
122     public String JavaDoc getCountry() {
123   return country;
124     }
125
126     public String JavaDoc getZipCode() {
127   return zipCode;
128     }
129
130     public String JavaDoc getGivenName(){
131         return givenName;
132     }
133
134     public String JavaDoc getFamilyName(){
135         return familyName;
136     }
137
138     public String JavaDoc getEmail(){
139         return email;
140     }
141
142     public String JavaDoc getTelephone(){
143         return telephone;
144     }
145
146
147     //setter methods
148

149    public void setUserId(String JavaDoc userId) {
150         this.userId = userId;
151     }
152     
153     public void setStreetName1(String JavaDoc streetName1) {
154   this.streetName1 = streetName1;
155     }
156
157     public void setStreetName2(String JavaDoc streetName2) {
158       this.streetName2 = streetName2;
159     }
160
161     public void setCity(String JavaDoc city) {
162   this.city = city;
163     }
164
165     public void setState(String JavaDoc state) {
166   this.state = state;
167     }
168
169     public void setCountry(String JavaDoc country) {
170   this.country = country;
171     }
172
173     public void setZipCode(String JavaDoc zipCode) {
174   this.zipCode = zipCode;
175     }
176
177     public void setGivenName(String JavaDoc givenName){
178       this.givenName = givenName;
179     }
180
181     public void setFamilyName(String JavaDoc familyName){
182        this.familyName = familyName;
183     }
184
185     public void setEmail(String JavaDoc email){
186       this.email = email;
187     }
188
189     public void setTelephone(String JavaDoc telephone){
190         this.telephone = telephone;
191     }
192
193     public String JavaDoc toString() {
194       String JavaDoc space = " ";
195       String JavaDoc ret = getUserId() + space + getStreetName1() + space + getStreetName2() + space + getCity() + space + getState() + space + getCountry() + space + getZipCode() + space + getGivenName() + space + getFamilyName() + space + getEmail() + space + getTelephone() + "\n";
196
197       return ret;
198     }
199
200 }
201
Popular Tags