X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=Addressbook%2Fsrc%2Forg%2Fmxchange%2Faddressbook%2Fcontact%2FBaseContact.java;h=2a1ecb73ffd0bbf9d1f3605b063a71355379bf39;hb=26e5c3c4c49253578272a4fd6b121e76004dd414;hp=3e9da4cd79664a94c277ce4c967fdef8f63bf6a1;hpb=a9386126082a82d662e37cec79c3d449d89d25cf;p=jfinancials-swing.git diff --git a/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java b/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java index 3e9da4c..2a1ecb7 100644 --- a/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java +++ b/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java @@ -107,7 +107,7 @@ public class BaseContact extends BaseFrameworkSystem { /** * ZIP code */ - private int zipCode; + private long zipCode; /** * No instances can be created of this class @@ -116,14 +116,6 @@ public class BaseContact extends BaseFrameworkSystem { super(); } - /** - * Enables the flag "own data" which signals that this contact is the user's - * own data. - */ - public void enableFlagOwnContact () { - this.ownContact = true; - } - /** * Check if contacts are same or throw an exception * @@ -259,6 +251,36 @@ public class BaseContact extends BaseFrameworkSystem { this.countryCode = countryCode; } + /** + * "Serializes" this object into a CSV string (this time with semicolons) + * + * @return "CSV-serialized" version of the stored data + */ + public String getCsvStringFromStoreableObject () { + // Get all together + String csvString = String.format( + "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"\n", + this.isOwnContact(), + this.getGender(), + this.getSurname(), + this.getFamilyName(), + this.getCompanyName(), + this.getStreet(), + this.getZipCode(), + this.getCity(), + this.getCountryCode(), + this.getPhoneNumber(), + this.getFaxNumber(), + this.getCellphoneNumber(), + this.getEmailAddress(), + this.getBirthday(), + this.getComment() + ); + + // Then return it + return csvString; + } + /** * Email address * @@ -439,7 +461,7 @@ public class BaseContact extends BaseFrameworkSystem { * * @return the zipCode */ - public int getZipCode () { + public long getZipCode () { return this.zipCode; } @@ -448,7 +470,7 @@ public class BaseContact extends BaseFrameworkSystem { * * @param zipCode the zipCode to set */ - public void setZipCode (final int zipCode) { + public void setZipCode (final long zipCode) { this.zipCode = zipCode; } @@ -494,12 +516,20 @@ public class BaseContact extends BaseFrameworkSystem { * @param city City * @param countryCode Country code */ - public void updateAddressData (final String street, final int zipCode, final String city, final String countryCode) { + public void updateAddressData (final String street, final long zipCode, final String city, final String countryCode) { // Set all - this.setStreet(street); - this.setZipCode(zipCode); - this.setCity(city); - this.setCountryCode(countryCode); + if (street != null) { + this.setStreet(street); + } + if (zipCode > 0) { + this.setZipCode(zipCode); + } + if (city != null) { + this.setCity(city); + } + if (countryCode != null) { + this.setCountryCode(countryCode); + } } /** @@ -512,9 +542,15 @@ public class BaseContact extends BaseFrameworkSystem { public void updateNameData (final char gender, final String surname, final String familyName, final String companyName) { // Set all this.setGender(gender); - this.setSurname(surname); - this.setFamilyName(familyName); - this.setCompanyName(companyName); + if (surname != null) { + this.setSurname(surname); + } + if (familyName != null) { + this.setFamilyName(familyName); + } + if (companyName != null) { + this.setCompanyName(companyName); + } } /** @@ -524,44 +560,36 @@ public class BaseContact extends BaseFrameworkSystem { * @param cellphoneNumber Cellphone number * @param faxNumber Fax number * @param emailAddress Email address + * @param birthday Birth day * @param comment Comments */ - public void updateOtherData (final String phoneNumber, final String cellphoneNumber, final String faxNumber, final String emailAddress, final String comment) { + public void updateOtherData (final String phoneNumber, final String cellphoneNumber, final String faxNumber, final String emailAddress, final String birthday, final String comment) { // Set all - this.setPhoneNumber(phoneNumber); - this.setCellphoneNumber(cellphoneNumber); - this.setFaxNumber(faxNumber); - this.setEmailAddress(emailAddress); - this.setComment(comment); + if (phoneNumber != null) { + this.setPhoneNumber(phoneNumber); + } + if (cellphoneNumber != null) { + this.setCellphoneNumber(cellphoneNumber); + } + if (faxNumber != null) { + this.setFaxNumber(faxNumber); + } + if (emailAddress != null) { + this.setEmailAddress(emailAddress); + } + if (birthday != null) { + this.setBirthday(birthday); + } + if (comment != null) { + this.setComment(comment); + } } /** - * "Serializes" this object into a CSV string (this time with semicolons) - * - * @return "CSV-serialized" version of the stored data + * Enables the flag "own data" which signals that this contact is the user's + * own data. */ - public String getCsvStringFromStoreableObject () { - // Get all together - String csvString = String.format( - "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"\n", - this.isOwnContact(), - this.getGender(), - this.getSurname(), - this.getFamilyName(), - this.getCompanyName(), - this.getStreet(), - this.getZipCode(), - this.getCity(), - this.getCountryCode(), - this.getPhoneNumber(), - this.getFaxNumber(), - this.getCellphoneNumber(), - this.getEmailAddress(), - this.getBirthday(), - this.getComment() - ); - - // Then return it - return csvString; + protected void enableFlagOwnContact () { + this.ownContact = true; } }