]> git.mxchange.org Git - addressbook-lib.git/commitdiff
Fixes for new changes in jcore
authorRoland Haeder <roland@mxchange.org>
Fri, 14 Aug 2015 18:29:22 +0000 (20:29 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 14 Aug 2015 18:29:22 +0000 (20:29 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

Addressbook/src/org/mxchange/addressbook/contact/book/BookContact.java
Addressbook/src/org/mxchange/addressbook/contact/user/UserContact.java
Addressbook/src/org/mxchange/addressbook/database/frontend/contact/AddressbookContactDatabaseFrontend.java

index 405d3608eefad54f75fd34de70486ed23ad9cf48..d4f4bf12da8209fca48db32607f349e0c83a4153 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.addressbook.contact.book;
 
 import org.mxchange.jcore.contact.BaseContact;
 import org.mxchange.jcore.contact.Contact;
-import org.mxchange.jcore.database.storage.csv.StoreableCsv;
 
 /**
  * A contact that can be placed into "contact books"
@@ -26,7 +25,7 @@ import org.mxchange.jcore.database.storage.csv.StoreableCsv;
  * @author Roland Haeder
  * @version 0.0
  */
-public class BookContact extends BaseContact implements Contact, StoreableCsv {
+public class BookContact extends BaseContact implements Contact {
 
        /**
         * Default constructor, may only be used from database backend
index d03a6d6f987cb35bbeecaf97abc2e432d65dd6b3..1ca7f8968a6595300050437ad2d77d0c4e648dad 100644 (file)
@@ -20,7 +20,6 @@ import java.text.MessageFormat;
 import org.mxchange.addressbook.contact.book.BookContact;
 import org.mxchange.jcore.contact.Contact;
 import org.mxchange.jcore.contact.Gender;
-import org.mxchange.jcore.database.storage.csv.StoreableCsv;
 
 /**
  *
@@ -28,7 +27,7 @@ import org.mxchange.jcore.database.storage.csv.StoreableCsv;
  * @todo After a Collection has been used in ContactManager, change to
  * BaseContact
  */
-public class UserContact extends BookContact implements Contact, StoreableCsv {
+public class UserContact extends BookContact implements Contact {
 
        /**
         * Creates own contact entry
index 24679626233e9648e9f9cbc9c9c88490a188e256..cc088427d280412a029f7fd11512e38142e53e40 100644 (file)
@@ -251,28 +251,6 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                return result.hasNext();
        }
 
-       /**
-        * Parses given line from database backend into a Storeable instance. Please
-        * note that not all backends need this.
-        *
-        * @param line Line from database backend
-        * @return A Storeable instance
-        */
-       @Override
-       public Storeable parseLineToStoreable (final String line) throws BadTokenException {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("line={0} - CALLED!", line)); //NOI18N
-
-               // Call inner method
-               Contact contact = this.parseLineToContact(line);
-
-               // Debug message
-               this.getLogger().debug(MessageFormat.format("contact={0}", contact));
-
-               // Return it
-               return (Storeable) contact;
-       }
-
        /**
         * Reads a single row and parses it to a contact instance
         *
@@ -292,251 +270,4 @@ public class AddressbookContactDatabaseFrontend extends BaseDatabaseFrontend imp
                // Bad state, should not be reached
                throw new IllegalStateException("This should not be reached");
        }
-
-       /**
-        * Parses given line and creates a Contact instance
-        * 
-        * @param line Raw line to parse
-        *
-        * @return Contact instance
-        */
-       private Contact parseLineToContact (final String line) throws BadTokenException {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("line={0} - CALLED!", line)); //NOI18N
-
-               // Init A lot variables
-               Long num = null;
-               Boolean bool = null;
-               Gender gender = null;
-               int count = 0;
-               Contact contact = null;
-
-               // Debug message
-               this.getLogger().debug(MessageFormat.format("line={0}", line)); //NOI18N
-
-               // Then tokenize it
-               // @TODO Move this into separate method
-               StringTokenizer tokenizer = new StringTokenizer(line, ";"); //NOI18N
-
-               // Reset variables
-               count = 0;
-               contact = null;
-
-               // The tokens are now available, so get all
-               while (tokenizer.hasMoreElements()) {
-                       // Reset variables
-                       num = null;
-                       bool = null;
-
-                       // Get next token
-                       String token = tokenizer.nextToken();
-
-                       // If char " is at pos 2 (0,1,2), then cut it of there
-                       if ((token.charAt(0) != '"') && (token.charAt(2) == '"')) {
-                               // UTF-8 writer characters found
-                               token = token.substring(2);
-                       }
-
-                       // Debug message
-                       this.getLogger().debug(MessageFormat.format("token={0}", token)); //NOI18N
-
-                       // Verify token, it must have double-quotes on each side
-                       if ((!token.startsWith("\"")) || (!token.endsWith("\""))) { //NOI18N
-                               // Something bad was read
-                               throw new BadTokenException(token, count); //NOI18N
-                       }
-
-                       // All fine, so remove it
-                       String strippedToken = token.substring(1, token.length() - 1);
-
-                       // Is the string's content "null"?
-                       if (strippedToken.equals("null")) { //NOI18N
-                               // Debug message
-                               this.getLogger().debug(MessageFormat.format("strippedToken={0} - NULL!", strippedToken)); //NOI18N
-
-                               // This needs to be set to null
-                               strippedToken = null;
-                       }
-
-                       // Debug message
-                       this.getLogger().debug(MessageFormat.format("strippedToken={0}", strippedToken)); //NOI18N
-
-                       // Now, let's try a number check, if no null
-                       if (strippedToken != null) {
-                               // Okay, no null, maybe the string bears a decimal number?
-                               try {
-                                       num = Long.valueOf(strippedToken);
-
-                                       // Debug message
-                                       this.getLogger().debug(MessageFormat.format("strippedToken={0} - NUMBER!", strippedToken)); //NOI18N
-                               } catch (final NumberFormatException ex) {
-                                       // No number, then set default
-                                       num = null;
-                               }
-                       }
-
-                       // Now, let's try a boolean check, if no null
-                       if ((strippedToken != null) && (num == null) && ((strippedToken.equals("true")) || (strippedToken.equals("false")))) { //NOI18N
-                               // Debug message
-                               this.getLogger().debug(MessageFormat.format("strippedToken={0} - BOOLEAN!", strippedToken)); //NOI18N
-
-                               // parseBoolean() is relaxed, so no exceptions
-                               bool = Boolean.valueOf(strippedToken);
-                       }
-
-                       // Debug message
-                       this.getLogger().debug(MessageFormat.format("strippedToken={0},num={1},bool={2}", strippedToken, num, bool)); //NOI18N
-
-                       // Now, let's try a gender check, if no null
-                       if ((strippedToken != null) && (num == null) && (bool == null) && (Gender.valueOf(strippedToken) instanceof Gender)) { //NOI18N
-                               // Get first character
-                               gender = Gender.valueOf(strippedToken);
-
-                               // Debug message
-                               this.getLogger().debug(MessageFormat.format("strippedToken={0},gender={1}", strippedToken, gender)); //NOI18N
-
-                               // This instance must be there
-                               assert (gender instanceof Gender) : MessageFormat.format("gender is not set by Gender.fromChar({0})", strippedToken); //NOI18N
-                       }
-
-                       // Now it depends on the counter which position we need to check
-                       switch (count) {
-                               case 0: // isOwnContact
-                                       assert ((bool instanceof Boolean));
-
-                                       // Debug message
-                                       this.getLogger().debug(MessageFormat.format("bool={0}", bool)); //NOI18N
-
-                                       // Is it own contact?
-                                       if (true == bool) {
-                                               // Debug message
-                                               this.getLogger().debug("Creating UserContact object ..."); //NOI18N
-
-                                               // Own entry
-                                               contact = new UserContact();
-                                       } else {
-                                               // Debug message
-                                               this.getLogger().debug("Creating BookContact object ..."); //NOI18N
-
-                                               // Other contact
-                                               contact = new BookContact();
-                                       }
-                                       break;
-
-                               case 1: // Gender
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setGender(gender);
-                                       break;
-
-                               case 2: // Surname
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-                                       assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N
-
-                                       // Update data
-                                       contact.setSurname(strippedToken);
-                                       break;
-
-                               case 3: // Family name
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-                                       assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N
-
-                                       // Update data
-                                       contact.setFamilyName(strippedToken);
-                                       break;
-
-                               case 4: // Company name
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-                                       assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N
-
-                                       // Update data
-                                       contact.setCompanyName(strippedToken);
-                                       break;
-
-                               case 5: // Street number
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setHouseNumber(num);
-                                       break;
-
-                               case 6: // ZIP code
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setZipCode(num);
-                                       break;
-
-                               case 7: // City name
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setCity(strippedToken);
-                                       break;
-
-                               case 8: // Country code
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setCountryCode(strippedToken);
-                                       break;
-
-                               case 9: // Phone number
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setPhoneNumber(strippedToken);
-                                       break;
-
-                               case 10: // Fax number
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setFaxNumber(strippedToken);
-                                       break;
-
-                               case 11: // Cellphone number
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setCellphoneNumber(strippedToken);
-                                       break;
-
-                               case 12: // Email address
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setEmailAddress(strippedToken);
-                                       break;
-
-                               case 13: // Birthday
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setBirthday(strippedToken);
-                                       break;
-
-                               case 14: // Comment
-                                       assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
-
-                                       // Update data
-                                       contact.setComment(strippedToken);
-                                       break;
-
-                               default: // New data entry
-                                       this.getLogger().warn(MessageFormat.format("Will not handle unknown data {0} at index {1}", strippedToken, count)); //NOI18N
-                                       break;
-                       }
-
-                       // Increment counter for next round
-                       count++;
-               }
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
-
-               // Return finished instance
-               return contact;
-       }
 }