From: Roland Haeder Date: Mon, 20 Jul 2015 09:57:03 +0000 (+0200) Subject: Added support for all current columns for reading from database file X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=26e5c3c4c49253578272a4fd6b121e76004dd414;p=jfinancials-lib.git Added support for all current columns for reading from database file Signed-off-by:Roland Häder --- diff --git a/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java b/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java index bb7df12..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 @@ -461,7 +461,7 @@ public class BaseContact extends BaseFrameworkSystem { * * @return the zipCode */ - public int getZipCode () { + public long getZipCode () { return this.zipCode; } @@ -470,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; } @@ -516,12 +516,12 @@ 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 if (street != null) { this.setStreet(street); } - if (city != null) { + if (zipCode > 0) { this.setZipCode(zipCode); } if (city != null) { @@ -560,9 +560,10 @@ 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 if (phoneNumber != null) { this.setPhoneNumber(phoneNumber); @@ -576,6 +577,9 @@ public class BaseContact extends BaseFrameworkSystem { if (emailAddress != null) { this.setEmailAddress(emailAddress); } + if (birthday != null) { + this.setBirthday(birthday); + } if (comment != null) { this.setComment(comment); } diff --git a/Addressbook/src/org/mxchange/addressbook/contact/Contact.java b/Addressbook/src/org/mxchange/addressbook/contact/Contact.java index 9b13801..2860ee2 100644 --- a/Addressbook/src/org/mxchange/addressbook/contact/Contact.java +++ b/Addressbook/src/org/mxchange/addressbook/contact/Contact.java @@ -85,7 +85,7 @@ public interface Contact extends FrameworkInterface { * * @return the zipCode */ - public int getZipCode(); + public long getZipCode(); /** * City @@ -158,7 +158,7 @@ public interface Contact extends FrameworkInterface { * @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); /** * Updates name data in this Contact instance @@ -177,7 +177,8 @@ public interface Contact extends FrameworkInterface { * @param cellNumber Cellphone number * @param faxNumber Fax number * @param email Email address + * @param birthday Birthday * @param comment Comments */ - public void updateOtherData (final String phoneNumber, final String cellNumber, final String faxNumber, final String email, final String comment); + public void updateOtherData (final String phoneNumber, final String cellNumber, final String faxNumber, final String email, final String birthday, final String comment); } diff --git a/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java b/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java index 8a026e1..b1d8012 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java @@ -304,8 +304,102 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken contact.updateNameData(gender, null, null, null); break; + case 2: // Surname + assert(contact instanceof Contact) : "First token was not boolean"; + assert(gender != '?') : "Gender is not detected."; + + // Update data + contact.updateNameData(gender, strippedToken, null, null); + break; + + case 3: // Family name + assert(contact instanceof Contact) : "First token was not boolean"; + assert(gender != '?') : "Gender is not detected."; + + // Update data + contact.updateNameData(gender, null, strippedToken, null); + break; + + case 4: // Company name + assert(contact instanceof Contact) : "First token was not boolean"; + assert(gender != '?') : "Gender is not detected."; + + // Update data + contact.updateNameData(gender, null, null, strippedToken); + break; + + case 5: // Street number + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateAddressData(strippedToken, 0, null, null); + break; + + case 6: // ZIP code + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateAddressData(null, num, null, null); + break; + + case 7: // City name + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateAddressData(null, 0, strippedToken, null); + break; + + case 8: // Country code + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateAddressData(null, 0, null, strippedToken); + break; + + case 9: // Phone number + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateOtherData(strippedToken, null, null, null, null, null); + break; + + case 10: // Fax number + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateOtherData(null, strippedToken, null, null, null, null); + break; + + case 11: // Cellphone number + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateOtherData(null, null, strippedToken, null, null, null); + break; + + case 12: // Email address + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateOtherData(null, null, null, strippedToken, null, null); + break; + + case 13: // Birthday + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateOtherData(null, null, null, null, strippedToken, null); + break; + + case 14: // Birthday + assert(contact instanceof Contact) : "First token was not boolean"; + + // Update data + contact.updateOtherData(null, null, null, null, null, strippedToken); + break; + default: // New data entry - this.getLogger().warn("Will not handle unknown data " + strippedToken + " at index " + count); + this.getLogger().warn(MessageFormat.format("Will not handle unknown data {0} at index {1}", strippedToken, count)); break; } @@ -330,7 +424,7 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken try { input = this.storageFile.readLine(); - } catch (IOException ex) { + } catch (final IOException ex) { this.getLogger().catching(ex); } diff --git a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java index 3199f81..0b31e2f 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java @@ -235,6 +235,7 @@ public class ContactManager extends BaseManager implements ManageableContact { * * @param contact Instance to change data * @param client Client instance to call back + * @todo Didn't handle birthday */ @Override public void doChangeOtherData (final Contact contact, final Client client) { @@ -260,7 +261,7 @@ public class ContactManager extends BaseManager implements ManageableContact { String comment = this.enterOwnComment(); // Update contact instance - contact.updateOtherData(phoneNumber, cellNumber, faxNumber, email, comment); + contact.updateOtherData(phoneNumber, cellNumber, faxNumber, email, null, comment); } else { // Then re-ask them ... throw new UnsupportedOperationException("Changing contact entries not finished.");