Source code: com/sample/tutorial/update/database/Contact.java
1 /*
2 * Contact.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.sample.tutorial.update.database;
11
12 /**
13 * Contains information on a single contact.
14 *
15 * @author Trevor Milne
16 *
17 */
18
19 public class Contact
20 {
21 /* Attributes */
22
23 /** The unique identifier for this contact. */
24 protected int id;
25
26 /** The first name of this contact. */
27 protected String firstName;
28
29 /** The last name of this contact. */
30 protected String lastName;
31
32 /** The email address of this contact. */
33 protected String email;
34
35
36 /* Constructors */
37
38
39 /**
40 * Constructs an empty <code>Contact</code>.
41 *
42 */
43
44 public Contact()
45 {
46 id = -1;
47 firstName = null;
48 lastName = null;
49 email = null;
50 }
51
52 /**
53 * Constructs an <code>Contact</code> from the supplied values.
54 *
55 */
56
57 public Contact(int setId, String setFirstName, String setLastName, String setEmail)
58 {
59 id = setId;
60 firstName = setFirstName;
61 lastName = setLastName;
62 email = setEmail;
63 }
64
65
66 /* Accessors */
67
68
69 /**
70 * Returns the identifier for this contact.
71 *
72 * @return The contact's unique identifier.
73 *
74 */
75
76 public int getId()
77 {
78 return id;
79 }
80
81 /**
82 * Sets the identifier for this contact.
83 *
84 * @param setId The contact's new unique identifier.
85 *
86 */
87
88 public void setId(int setId)
89 {
90 id = setId;
91 }
92
93 /**
94 * Returns the first name of this contact.
95 *
96 * @return The contact's first name.
97 *
98 */
99
100 public String getFirstName()
101 {
102 return firstName;
103 }
104
105 /**
106 * Sets the first name of this contact.
107 *
108 * @param setFirstName The new first name.
109 *
110 */
111
112 public void setFirstName(String setFirstName)
113 {
114 firstName = setFirstName;
115 }
116
117 /**
118 * Returns the last name of this contact.
119 *
120 * @return The contact's last name.
121 *
122 */
123
124 public String getLastName()
125 {
126 return lastName;
127 }
128
129 /**
130 * Sets the last name of this contact.
131 *
132 * @param setLastName The new last name.
133 *
134 */
135
136 public void setLastName(String setLastName)
137 {
138 lastName = setLastName;
139 }
140
141 /**
142 * Returns the email address of this contact.
143 *
144 * @return The contact's email address.
145 *
146 */
147
148 public String getEmail()
149 {
150 return email;
151 }
152
153 /**
154 * Sets the email address of this contact.
155 *
156 * @param setEmail The new email address.
157 *
158 */
159
160 public void setEmail(String setEmail)
161 {
162 email = setEmail;
163 }
164
165 /**
166 * Copies all attributes into the supplied <code>Contact</code>.
167 *
168 * @param data The <code>Contact</code> to place data into.
169 *
170 */
171
172 public void getData(Contact data)
173 {
174 data.setId(id);
175 data.setFirstName(firstName);
176 data.setLastName(lastName);
177 data.setEmail(email);
178 }
179
180 /**
181 * Copies all attributes from the supplied <code>Contact</code>.
182 *
183 * @param data The <code>Contact</code> to read data from.
184 *
185 */
186
187 public void setData(Contact data)
188 {
189 setId(data.getId());
190 setFirstName(data.getFirstName());
191 setLastName(data.getLastName());
192 setEmail(data.getEmail());
193 }
194
195
196 /* Debug */
197
198
199 public String toString()
200 {
201 return "Contact [" +
202 "id=" + id + ";" +
203 "firstName=" + firstName + ";" +
204 "lastName=" + lastName + ";" +
205 "email=" + email +
206 "]";
207 }
208 }
209