2 * Copyright (C) 2015 Roland Haeder
\r
4 * This program is free software: you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation, either version 3 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
17 package org.mxchange.addressbook.contact;
\r
19 import org.mxchange.addressbook.BaseFrameworkSystem;
\r
20 import org.mxchange.addressbook.client.Client;
\r
25 * @author Roland Haeder
\r
29 public class BaseContact extends BaseFrameworkSystem {
\r
33 private String birthday;
\r
38 private String cellphoneNumber;
\r
43 private String city;
\r
48 private String comment;
\r
53 private String companyName;
\r
58 private String countryCode;
\r
63 private String emailAddress;
\r
68 private String familyName;
\r
73 private String faxNumber;
\r
76 * Gender code of the contact: - M = Mr. (male) - F = Mrs. (female) - C =
\r
79 private char gender;
\r
84 private int houseNumber;
\r
87 * Marker whether this contact is user's own data
\r
89 private boolean ownContact;
\r
94 private String phoneNumber;
\r
99 private String street;
\r
104 private String surname;
\r
109 private int zipCode;
\r
112 * No instances can be created of this class
\r
114 protected BaseContact () {
\r
119 * Enables the flag "own data" which signals that this contact is the user's
\r
122 public void enableFlagOwnContact () {
\r
123 this.ownContact = true;
\r
127 * Check if contacts are same or throw an exception
\r
129 * @param object Other possible contact class
\r
130 * @return Whether both contacts are same
\r
133 public boolean equals (Object object) {
\r
135 BaseContact c = (BaseContact) object;
\r
138 * Now test some data @todo Definedly needs improvement
\r
140 return ((this.getGender() == c.getGender())
\r
141 && (this.getSurname().toLowerCase().equals(c.getSurname().toLowerCase()))
\r
142 && (this.getFamilyName().toLowerCase().equals(c.getFamilyName().toLowerCase())));
\r
148 * @return the birthday
\r
150 public String getBirthday () {
\r
151 return this.birthday;
\r
157 * @param birthday the birthday to set
\r
159 public void setBirthday (final String birthday) {
\r
160 this.birthday = birthday;
\r
166 * @return the cellphoneNumber
\r
168 public String getCellphoneNumber () {
\r
169 return this.cellphoneNumber;
\r
175 * @param cellphoneNumber the cellphoneNumber to set
\r
177 public void setCellphoneNumber (final String cellphoneNumber) {
\r
178 this.cellphoneNumber = cellphoneNumber;
\r
186 public String getCity () {
\r
193 * @param city the city to set
\r
195 public void setCity (final String city) {
\r
202 * @return the comment
\r
204 public String getComment () {
\r
205 return this.comment;
\r
211 * @param comment the comment to set
\r
213 public void setComment (final String comment) {
\r
214 this.comment = comment;
\r
220 * @return the companyName
\r
222 public String getCompanyName () {
\r
223 return this.companyName;
\r
229 * @param companyName the companyName to set
\r
231 public void setCompanyName (final String companyName) {
\r
232 this.companyName = companyName;
\r
238 * @return the countryCode
\r
240 public String getCountryCode () {
\r
241 return this.countryCode;
\r
247 * @param countryCode the countryCode to set
\r
249 public void setCountryCode (final String countryCode) {
\r
250 this.countryCode = countryCode;
\r
256 * @return the emailAddress
\r
258 public String getEmailAddress () {
\r
259 return this.emailAddress;
\r
265 * @param emailAddress the emailAddress to set
\r
267 public void setEmailAddress (final String emailAddress) {
\r
268 this.emailAddress = emailAddress;
\r
274 * @return the familyName
\r
276 public String getFamilyName () {
\r
277 return this.familyName;
\r
283 * @param familyName the familyName to set
\r
285 public void setFamilyName (final String familyName) {
\r
286 this.familyName = familyName;
\r
292 * @return the faxNumber
\r
294 public String getFaxNumber () {
\r
295 return this.faxNumber;
\r
301 * @param faxNumber the faxNumber to set
\r
303 public void setFaxNumber (final String faxNumber) {
\r
304 this.faxNumber = faxNumber;
\r
308 * Gender of the contact
\r
310 * @return the gender
\r
312 public char getGender () {
\r
313 return this.gender;
\r
317 * Gender of the contact
\r
319 * @param gender the gender to set
\r
321 public void setGender (final char gender) {
\r
322 this.gender = gender;
\r
328 * @return the houseNumber
\r
330 public int getHouseNumber () {
\r
331 return this.houseNumber;
\r
337 * @param houseNumber the houseNumber to set
\r
339 public void setHouseNumber (final int houseNumber) {
\r
340 this.houseNumber = houseNumber;
\r
346 * @return the phoneNumber
\r
348 public String getPhoneNumber () {
\r
349 return this.phoneNumber;
\r
355 * @param phoneNumber the phoneNumber to set
\r
357 public void setPhoneNumber (final String phoneNumber) {
\r
358 this.phoneNumber = phoneNumber;
\r
364 * @return the street
\r
366 public String getStreet () {
\r
367 return this.street;
\r
373 * @param street the street to set
\r
375 public void setStreet (final String street) {
\r
376 this.street = street;
\r
382 * @return the surname
\r
384 public String getSurname () {
\r
385 return this.surname;
\r
391 * @param surname the surname to set
\r
393 public void setSurname (final String surname) {
\r
394 this.surname = surname;
\r
398 * Some "getter" for a translated/human-readable gender
\r
399 * @return gender Human-readable gender
\r
401 public String getTranslatedGender () {
\r
403 String translated = null;
\r
406 switch (this.getGender()) {
\r
408 translated = "Herr";
\r
412 translated = "Frau";
\r
415 case 'C': // "Company"
\r
416 translated = "Firma";
\r
419 default: // Unsupported
\r
420 this.getLogger().error("Gender " + this.getGender() + " not supported.");
\r
431 * @return the zipCode
\r
433 public int getZipCode () {
\r
434 return this.zipCode;
\r
440 * @param zipCode the zipCode to set
\r
442 public void setZipCode (final int zipCode) {
\r
443 this.zipCode = zipCode;
\r
447 * Checks whether the contact is user's own data
\r
449 * @return Own data?
\r
451 public boolean isOwnContact () {
\r
452 return this.ownContact;
\r
456 * Shows this contact to the user
\r
458 * @param client Client instance to use
\r
460 public void show (final Client client) {
\r
461 // Display name "box"
\r
462 client.displayNameBox((Contact) this);
\r
464 // Display address "box"
\r
465 client.displayAddressBox((Contact) this);
\r
467 // Display other data "box"
\r
468 client.displayOtherDataBox((Contact) this);
\r