KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > standard > examples > beans > Customer


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.taglibs.standard.examples.beans;
18
19 import java.util.Date JavaDoc;
20 import java.text.*;
21
22 /**
23  * Object that represents a Customer.
24  *
25  * @author Pierre Delisle
26  * @version $Revision: 1.3 $ $Date: 2004/02/28 01:01:41 $
27  */

28
29 public class Customer {
30     
31     //*********************************************************************
32
// Instance variables
33

34     /** Holds value of property key. */
35     int key;
36     
37     /** Holds value of property lastName. */
38     private String JavaDoc lastName;
39     
40     /** Holds value of property firstName. */
41     private String JavaDoc firstName;
42     
43     /** Holds value of property birthDate. */
44     private Date JavaDoc birthDate;
45     
46     /** Holds value of property address. */
47     private Address address;
48        
49     /** Holds value of property phoneHome. */
50     private String JavaDoc phoneHome;
51     
52     /** Holds value of property phoneCell. */
53     private String JavaDoc phoneCell;
54     
55     static DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
56     
57     //*********************************************************************
58
// Constructors
59

60     public Customer() {}
61     
62     public Customer(int key,
63     String JavaDoc lastName,
64     String JavaDoc firstName,
65     Date JavaDoc birthDate,
66     Address address,
67     String JavaDoc phoneHome,
68     String JavaDoc phoneCell) {
69         init(key, lastName, firstName, birthDate, address, phoneHome, phoneCell);
70     }
71     
72     public void init(int key,
73     String JavaDoc lastName,
74     String JavaDoc firstName,
75     Date JavaDoc birthDate,
76     Address address,
77     String JavaDoc phoneHome,
78     String JavaDoc 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     //*********************************************************************
89
// Properties
90

91     /**
92      * Getter for property key.
93      * @return Value of property key.
94      */

95     public int getKey() {
96         return key;
97     }
98     
99     /**
100      * Setter for property key.
101      * @param key New value of property key.
102      */

103     public void setKey(int key) {
104         this.key = key;
105     }
106     
107     /**
108      * Getter for property lastName.
109      * @return Value of property lastName.
110      */

111     public String JavaDoc getLastName() {
112         return lastName;
113     }
114     
115     /**
116      * Setter for property lastName.
117      * @param lastName New value of property lastName.
118      */

119     public void setLastName(String JavaDoc lastName) {
120         this.lastName = lastName;
121     }
122     
123     /**
124      * Getter for property firstName.
125      * @return Value of property firstName.
126      */

127     public String JavaDoc getFirstName() {
128         return firstName;
129     }
130     
131     /**
132      * Setter for property firstName.
133      * @param firstName New value of property firstName.
134      */

135     public void setFirstName(String JavaDoc firstName) {
136         this.firstName = firstName;
137     }
138     
139     /**
140      * Getter for property birthDate.
141      * @return Value of property birthDate.
142      */

143     public Date JavaDoc getBirthDate() {
144         return birthDate;
145     }
146     
147     /**
148      * Setter for property birthDate.
149      * @param birthDate New value of property birthDate.
150      */

151     public void setBirthDate(Date JavaDoc birthDate) {
152         this.birthDate = birthDate;
153     }
154     
155     /**
156      * Getter for property address.
157      * @return Value of property address.
158      */

159     public Address getAddress() {
160         return address;
161     }
162     
163     /**
164      * Setter for property address.
165      * @param address New value of property address.
166      */

167     public void setAddress(Address address) {
168         this.address = address;
169     }
170     
171     /**
172      * Getter for property phoneHome.
173      * @return Value of property phoneHome.
174      */

175     public String JavaDoc getPhoneHome() {
176         return phoneHome;
177     }
178     
179     /**
180      * Setter for property phoneHome.
181      * @param phoneHome New value of property phoneHome.
182      */

183     public void setPhoneHome(String JavaDoc phoneHome) {
184         this.phoneHome = phoneHome;
185     }
186     
187     /**
188      * Getter for property phoneCell.
189      * @return Value of property phoneCell.
190      */

191     public String JavaDoc getPhoneCell() {
192         return phoneCell;
193     }
194     
195     /**
196      * Setter for property phoneCell.
197      * @param phoneCell New value of property phoneCell.
198      */

199     public void setPhoneCell(String JavaDoc phoneCell) {
200         this.phoneCell = phoneCell;
201     }
202     
203     //*********************************************************************
204
// Utility Methods
205

206     /**
207      * Return a String representation of this object.
208      */

209     public String JavaDoc toString() {
210         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
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