]> git.mxchange.org Git - addressbook-lib.git/commitdiff
Renaming season: renamed manager -> facade
authorRoland Haeder <roland@mxchange.org>
Fri, 2 Oct 2015 07:49:47 +0000 (09:49 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 2 Oct 2015 07:49:47 +0000 (09:49 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcore.jar
src/org/mxchange/addressbook/client/BaseAddressbookClient.java
src/org/mxchange/addressbook/facade/contact/AddressbookContactFacade.java [new file with mode: 0644]
src/org/mxchange/addressbook/facade/contact/ContactFacade.java [new file with mode: 0644]
src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java [deleted file]
src/org/mxchange/addressbook/manager/contact/ManageableContactAddressbook.java [deleted file]

index a656d48c28300f77bb29968479825c31341dbb3d..b78e9d086424604cf9e0a6e47676bc9eab13f12d 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index effa814cc046867f8493481c1733f0e5ff2171cc..5f12b48383bdc035721a94c60fb96d68e31036d3 100644 (file)
@@ -23,8 +23,8 @@ import java.util.Map;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import org.mxchange.addressbook.manager.contact.AddressbookContactManager;
-import org.mxchange.addressbook.manager.contact.ManageableContactAddressbook;
+import org.mxchange.addressbook.facade.contact.AddressbookContactFacade;
+import org.mxchange.addressbook.facade.contact.ContactFacade;
 import org.mxchange.addressbook.menu.Menu;
 import org.mxchange.jcore.client.BaseClient;
 import org.mxchange.jcore.client.Client;
@@ -156,12 +156,12 @@ public abstract class BaseAddressbookClient extends BaseClient implements Addres
                // Debug message
                this.getLogger().logDebug("Initializing contact manager ..."); //NOI18N
 
-               // Init contact manager with console client
+               // Init contact facade with console client
                // TODO Static initial amount of contacts
-               ManageableContactAddressbook manager = new AddressbookContactManager((Client) this);
+               ContactFacade facade = new AddressbookContactFacade((Client) this);
 
                // Set it here
-               this.setManager(manager);
+               this.setManager(facade);
 
                // Debug message
                this.getLogger().logDebug("Contact manager has been initialized."); //NOI18N
diff --git a/src/org/mxchange/addressbook/facade/contact/AddressbookContactFacade.java b/src/org/mxchange/addressbook/facade/contact/AddressbookContactFacade.java
new file mode 100644 (file)
index 0000000..440c223
--- /dev/null
@@ -0,0 +1,670 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.facade.contact;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
+import org.mxchange.jcore.manager.BaseManager;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+
+/**
+ * A facade for contacts.
+ * <p>
+ * @author Roland Haeder
+ * @version 0.0
+ */
+public class AddressbookContactFacade extends BaseManager implements ContactFacade {
+
+       /**
+        * Column name list
+        */
+       private final List<String> columnNames;
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal logger;
+
+       /**
+        * Translated column name list
+        */
+       private final List<String> translatedColumnNames;
+
+       /**
+        * Constructor which accepts maxContacts for maximum (initial) contacts and
+        * a client instance.
+        * <p>
+        * @param client Client instance to use
+        * @throws java.sql.SQLException If an SQL error occurs
+        */
+       public AddressbookContactFacade (final Client client) throws SQLException {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
+
+               // Make sure all parameters are set correctly
+               if (null == client) {
+                       // Abort here
+                       throw new NullPointerException("client is null"); //NOI18N
+               }
+
+               // Set client instance
+               this.setClient(client);
+
+               // Init database connection
+               DatabaseFrontend frontend = new AddressbookContactDatabaseFrontend(this);
+               this.setFrontend(frontend);
+
+               // Initialize list
+               this.columnNames = new ArrayList<>(15);
+               this.translatedColumnNames = new ArrayList<>(15);
+
+               // And fill it
+               this.fillColumnNamesFromBundle();
+
+               // Debug message
+               //* NOISY-DEBUG: */ this.getLogger().logDebug("client=" + client);
+       }
+
+       @Override
+       public void addContact (final Contact contact) throws ContactAlreadyAddedException {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+               // Contact instance must not be null
+               if (null == contact) {
+                       // Abort here
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Add it
+               ((AddressbookContactFrontend) this.getFrontend()).addContact(contact);
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void doAddOtherAddress () {
+               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+       }
+
+       @Override
+       public void doChangeAddressData (final Contact contact) {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+               // Contact must not be null
+               if (null == contact) {
+                       // Abort here
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+               if (!(this.getClient() instanceof AddressbookClient)) {
+                       // Cannot cast
+                       throw new IllegalArgumentException(MessageFormat.format("this.getClient()={0} does not implement AddressbookClient", this.getClient())); //NOI18N
+               }
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               // First display it again
+               client.displayAddressBox(contact);
+
+               // Is it own data?
+               if (contact.isOwnContact()) {
+                       // Deligate to client
+                       client.doChangeOwnAddressData(contact);
+               } else {
+                       // Other contact's address data to change
+                       throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void doChangeNameData (final Contact contact) {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+               // Contact must not be null
+               if (null == contact) {
+                       // Abort here
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               // First display them again
+               client.displayNameBox(contact);
+
+               // Is this own data?
+               if (contact.isOwnContact()) {
+                       // Re-ask own data
+                       client.doChangeOwnNameData(contact);
+               } else {
+                       // Then re-ask them ...
+                       throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void doChangeOtherAddress () {
+               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+       }
+
+       @Override
+       public void doChangeOtherData (final Contact contact) {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+               // Contact must not be null
+               if (null == contact) {
+                       // Abort here
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               // First display them again
+               client.displayOtherDataBox(contact);
+
+               // Is this own data?
+               if (contact.isOwnContact()) {
+                       // Re-ask own data
+                       client.doChangeOwnOtherData(contact);
+               } else {
+                       // Then re-ask them ...
+                       throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               /*
+                * First check if the user has registered own contact, before that
+                * nothing can be changed.
+                */
+               if (!this.isOwnContactAdded()) {
+                       // Not added
+                       this.getClient().outputMessage("Sie haben noch nicht Ihre Daten eingegeben."); //NOI18N
+
+                       // Skip any below code
+                       return;
+               }
+
+               // Instance
+               Contact contact = this.getOwnContact();
+
+               // It must be found
+               assert (contact instanceof Contact) : ": contact is not implementing Contact: " + contact;
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               // Display contact
+               client.show(contact);
+
+               try {
+                       // Ask user what to change
+                       client.userChooseChangeContactData(contact);
+               } catch (final UnhandledUserChoiceException ex) {
+                       this.getLogger().logException(ex);
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void doDeleteOtherAddress () {
+               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+       }
+
+       @Override
+       public void doEnterOwnData () throws ContactAlreadyAddedException, IOException {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Is own contact already added?
+               if (this.isOwnContactAdded()) {
+                       // Don't continue here
+                       throw new ContactAlreadyAddedException();
+               }
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               // Deligate this call to the client
+               Contact contact = client.doEnterOwnData();
+
+               // Is it set?
+               if (contact instanceof Contact) {
+                       // Add it to contact "book"
+                       this.registerContact(contact);
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void doListContacts () {
+               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+       }
+
+       @Override
+       public void doSearchContacts () {
+               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+       }
+
+       @Override
+       public void doShutdown () throws SQLException, IOException {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Shut down the database layer
+               ((AddressbookContactFrontend) this.getFrontend()).doShutdown();
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       @Override
+       public String enterOwnCellNumber () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
+       }
+
+       @Override
+       public String enterOwnCity () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
+       }
+
+       @Override
+       public String enterOwnComment () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
+       }
+
+       @Override
+       public String enterOwnCompanyName () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
+       }
+
+       @Override
+       public String enterOwnCountryCode () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();
+       }
+
+       @Override
+       public String enterOwnEmailAddress () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
+       }
+
+       @Override
+       public String enterOwnFamilyName () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
+       }
+
+       @Override
+       public String enterOwnFaxNumber () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
+       }
+
+       @Override
+       public String enterOwnFirstName () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
+       }
+
+       @Override
+       public Gender enterOwnGender () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
+       }
+
+       @Override
+       public String enterOwnPhoneNumber () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
+       }
+
+       @Override
+       public String enterOwnStreet () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
+       }
+
+       @Override
+       public int enterOwnZipCode () {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Get and cast client instance
+               AddressbookClient client = (AddressbookClient) this.getClient();
+
+               return client.enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
+       }
+
+       @Override
+       public final int getColumnCount () {
+               assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
+
+               return this.columnNames.size();
+       }
+
+       @Override
+       public String getColumnName (final int columnIndex) {
+               assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
+
+               // Get column name at index
+               return this.columnNames.get(columnIndex);
+       }
+
+       @Override
+       public String getTranslatedColumnName (final int columnIndex) {
+               assert (this.translatedColumnNames instanceof List) : "this.translatedColumnNames is not initialized"; //NOI18N
+
+               // Get column name at index
+               return this.translatedColumnNames.get(columnIndex);
+       }
+
+       @Override
+       public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex)); //NOI18N
+
+               // Then get specific row from database which is a Contact instance
+               Storable storable = this.getFrontend().getStorableAtRow(rowIndex);
+
+               // Debug message
+               this.getLogger().logDebug(MessageFormat.format("storable={0}", storable)); //NOI18N
+
+               // It may return null
+               if (null == storable) {
+                       // Nothing found
+                       this.getLogger().logWarning("contact is null - returning null ..."); //NOI18N
+                       return null;
+               }
+
+               // Convert column index -> name
+               String columnName = this.getColumnName(columnIndex);
+
+               // Debug message
+               this.getLogger().logDebug(MessageFormat.format("columnName={0}", columnName)); //NOI18N
+
+               // Now get that column
+               Object value = null;
+               try {
+                       value = storable.getValueFromColumn(columnName);
+               } catch (final IllegalArgumentException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+                       this.abortProgramWithException(ex);
+               }
+
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
+
+               // Return it
+               return value;
+       }
+
+       @Override
+       public boolean isOwnContactAdded () throws IOException {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Init variable
+               boolean isAdded = false;
+
+               try {
+                       // Deligate this call to frontend
+                       isAdded = ((AddressbookContactFrontend) this.getFrontend()).isOwnContactFound();
+               } catch (final SQLException | IOException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+                       // Something bad happened
+                       this.abortProgramWithException(ex);
+               }
+
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
+
+               // Return result
+               return isAdded;
+       }
+
+       @Override
+       public void registerContact (final Contact contact) {
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+               // Sanity check
+               if (null == contact) {
+                       // Abort here
+                       throw new NullPointerException("contact is null"); //NOI18N
+               }
+               try {
+                       // Check if contact is found
+                       if (((AddressbookContactFrontend) this.getFrontend()).isContactFound(contact)) {
+                               // Contact already added
+                               // TODO Do something here
+                       } else if ((contact.isOwnContact()) && (this.isOwnContactAdded())) {
+                               // Own contact already added
+                               // TODO Do something
+                       }
+
+                       // Add contact to internal list
+                       this.addContact(contact);
+               } catch (final ContactAlreadyAddedException | SQLException | IOException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+                       // Abort here
+                       this.abortProgramWithException(ex);
+               }
+
+               // Trace message
+               this.getLogger().logTrace("EXIT!"); //NOI18N
+       }
+
+       /**
+        * Logs given exception and exits program
+        *
+        * @param throwable Throwable
+        */
+       private void abortProgramWithException (Throwable throwable) {
+               // Log exception
+               this.logException(throwable);
+
+               // Abort here
+               System.exit(1);
+       }
+
+       /**
+        * Fills the column names array with strings from bundle
+        */
+       private void fillColumnNamesFromBundle () {
+               assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
+               assert (this.translatedColumnNames instanceof List) : "this.translatedColumnNames is not initialized"; //NOI18N
+
+               // Debug message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // First get an iterator from key set to iterate over
+               Iterator<String> iterator = this.getBundle().keySet().iterator();
+
+               // Then iterate over all
+               while (iterator.hasNext()) {
+                       // Get next element
+                       String key = iterator.next().toLowerCase();
+
+                       // Does the key start with AddressbookContactFacade.columnName ?
+                       if (key.startsWith("ContactManager.columnName")) { //NOI18N
+                               // This is the wanted entry.
+                               this.getLogger().logDebug(MessageFormat.format("key={0}", key)); //NOI18N
+
+                               // Convert string to array based on delimiter '.'
+                               String[] tokens = this.getArrayFromString(key, "."); //NOI18N
+
+                               // Token array must contain 4 elements (AddressbookContactFacade.columnName.foo.text)
+                               assert (tokens.length == 4) : MessageFormat.format("Array tokens contains not 4 elements: {0}", Arrays.toString(tokens)); //NOI18N
+
+                               // Get pre-last element
+                               String columnName = tokens[tokens.length - 2];
+
+                               // Debug message
+                               this.getLogger().logDebug(MessageFormat.format("columnName={0} - adding ...", columnName)); //NOI18N
+
+                               // So add it
+                               this.columnNames.add(columnName);
+                               this.translatedColumnNames.add(this.getBundle().getString(key));
+                       }
+               }
+
+               // Debug message
+               this.getLogger().logTrace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
+       }
+
+       /**
+        * Getter for logger instance
+        *
+        * @return Logger instance
+        */
+       private LoggerBeanLocal getLogger () {
+               return this.logger;
+       }
+
+       /**
+        * "Getter" for own contact instance or null if not found
+        * <p>
+        * @return Contact instance or null
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.lang.NoSuchMethodException If a method cannot be found
+        * @throws java.lang.IllegalAccessException If a method is not accessible
+        * @throws java.lang.reflect.InvocationTargetException Any other problems?
+        */
+       private Contact getOwnContact () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+               // Trace message
+               this.getLogger().logTrace("CALLED!"); //NOI18N
+
+               // Deligate this call to database frontend
+               Contact contact = ((AddressbookContactFrontend) this.getFrontend()).getOwnContact();
+
+               // Trace message
+               this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+
+               // Return instance or null
+               return contact;
+       }
+
+       /**
+        * Logs given exception
+        * <p>
+        * @param exception Throwable
+        */
+       protected void logException (final Throwable exception) {
+               this.getLogger().logException(exception);
+       }
+}
diff --git a/src/org/mxchange/addressbook/facade/contact/ContactFacade.java b/src/org/mxchange/addressbook/facade/contact/ContactFacade.java
new file mode 100644 (file)
index 0000000..9af1c73
--- /dev/null
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.facade.contact;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcore.manager.Manageable;
+
+/**
+ * An interface for addressbook contact manager
+ * <p>
+ * @author Roland Haeder
+ */
+public interface ContactFacade extends Manageable {
+
+       /**
+        * Adds given Contact instance to list
+        * <p>
+        * @param contact Contact instance to add
+        * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added
+        */
+       public void addContact (final Contact contact) throws ContactAlreadyAddedException;
+
+       /**
+        * Let the user add a new other address
+        */
+       public void doAddOtherAddress ();
+
+       /**
+        * The user can change address data, like street, ZIP code, city and country
+        * of given Contact instance.
+        * <p>
+        * @param contact Instance to change data
+        */
+       public void doChangeAddressData (final Contact contact);
+
+       /**
+        * The user can change name data, like gender, surname, family name and
+        * company name (if business contact).
+        * <p>
+        * @param contact Instance to change data
+        */
+       public void doChangeNameData (final Contact contact);
+
+       /**
+        * Let the user change other address
+        */
+       public void doChangeOtherAddress ();
+
+       /**
+        * The user can change other data, like phone numbers or comments.
+        * <p>
+        * @param contact Instance to change data
+        */
+       public void doChangeOtherData (final Contact contact);
+
+       /**
+        * Let the user change own data
+        * <p>
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO error occurs
+        * @throws java.lang.NoSuchMethodException If a method cannot be found
+        * @throws java.lang.IllegalAccessException If a method is not accessible
+        * @throws java.lang.reflect.InvocationTargetException Any other problems?
+        */
+       public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Let the user delete other address
+        */
+       public void doDeleteOtherAddress ();
+
+       /**
+        * Asks user for own data
+        * <p>
+        * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException
+        * If own contact is already added
+        * @throws java.io.IOException If an IO error was found
+        */
+       public void doEnterOwnData () throws ContactAlreadyAddedException, IOException;
+
+       /**
+        * List all contacts
+        */
+       public void doListContacts ();
+
+       /**
+        * Searches address book for a contact
+        */
+       public void doSearchContacts ();
+
+       /**
+        * Allows the user to enter own cellphone number.
+        * <p>
+        * @return Cellphone number
+        */
+       public String enterOwnCellNumber ();
+
+       /**
+        * Allows the user to enter own city name.
+        * <p>
+        * @return City name
+        */
+       public String enterOwnCity ();
+
+       /**
+        * Allows the user to enter comment for own entry.
+        * <p>
+        * @return Comment
+        */
+       public String enterOwnComment ();
+
+       /**
+        * Allows the user to enter own company name.
+        * <p>
+        * @return Company name
+        */
+       public String enterOwnCompanyName ();
+
+       /**
+        * Allows the user to enter own country code.
+        * <p>
+        * @return Country code
+        */
+       public String enterOwnCountryCode ();
+
+       /**
+        * Allows the user to enter own email address.
+        * <p>
+        * @return Email address
+        */
+       public String enterOwnEmailAddress ();
+
+       /**
+        * Allows the user to enter own family name.
+        * <p>
+        * @return Family name
+        */
+       public String enterOwnFamilyName ();
+
+       /**
+        * Allows the user to enter own fax number.
+        * <p>
+        * @return Fax number
+        */
+       public String enterOwnFaxNumber ();
+
+       /**
+        * Allows the user to enter own surname.
+        * <p>
+        * @return Surname
+        */
+       public String enterOwnFirstName ();
+
+       /**
+        * Allows the user to enter own gender.
+        * <p>
+        * @return Gender
+        */
+       public Gender enterOwnGender ();
+
+       /**
+        * Allows the user to enter own phone number.
+        * <p>
+        * @return Phone number
+        */
+       public String enterOwnPhoneNumber ();
+
+       /**
+        * Allows the user to enter own street and house number.
+        * <p>
+        * @return Street and house number
+        */
+       public String enterOwnStreet ();
+
+       /**
+        * Allows the user to enter own ZIP code.
+        * <p>
+        * @return ZIP code
+        */
+       public int enterOwnZipCode ();
+
+       /**
+        * Getter for column count
+        * <p>
+        * @return Column count TODO: This is needed for TableModel in Swing
+        */
+       public int getColumnCount ();
+
+       /**
+        * Getter for column name at given index.
+        * <p>
+        * @param columnIndex Column index
+        * @return Database column name TODO: This is needed for TableModel in Swing
+        */
+       public String getColumnName (final int columnIndex);
+
+       /**
+        * Getter for translated column name at given index.
+        * <p>
+        * @param columnIndex Column index
+        * @return Human-readable column name TODO: This is needed for TableModel in
+        * Swing
+        */
+       public String getTranslatedColumnName (final int columnIndex);
+
+       /**
+        * Somewhat "getter" for value from given row and column index
+        * <p>
+        * @param rowIndex Row index
+        * @param columnIndex Column index
+        * @return Value from given row/column
+        * @throws java.lang.NoSuchMethodException If the method was not found
+        * @throws java.lang.IllegalAccessException If the accessed method was not public
+        * @throws java.lang.reflect.InvocationTargetException Something else
+        * happened? TODO: This is needed for TableModel in Swing
+        */
+       public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+       /**
+        * Checks whether own contact is already added by checking all entries for
+        * isOwnContact flag
+        * <p>
+        * @return Whether own contact is already added
+        * @throws java.io.IOException If an IO error occurs
+        */
+       public boolean isOwnContactAdded () throws IOException;
+
+       /**
+        * Adds given contact to address book
+        * <p>
+        * @param contact Contact being added TODO Add check for book size
+        */
+       public void registerContact (final Contact contact);
+}
diff --git a/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java b/src/org/mxchange/addressbook/manager/contact/AddressbookContactManager.java
deleted file mode 100644 (file)
index 7670cec..0000000
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.manager.contact;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import org.mxchange.addressbook.client.AddressbookClient;
-import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcore.client.Client;
-import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
-import org.mxchange.jcore.manager.BaseManager;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-
-/**
- * A manager for contacts.
- * <p>
- * @author Roland Haeder
- * @version 0.0
- */
-public class AddressbookContactManager extends BaseManager implements ManageableContactAddressbook {
-
-       /**
-        * Column name list
-        */
-       private final List<String> columnNames;
-
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal logger;
-
-       /**
-        * Translated column name list
-        */
-       private final List<String> translatedColumnNames;
-
-       /**
-        * Constructor which accepts maxContacts for maximum (initial) contacts and
-        * a client instance.
-        * <p>
-        * @param client Client instance to use
-        * @throws java.sql.SQLException If an SQL error occurs
-        */
-       public AddressbookContactManager (final Client client) throws SQLException {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
-
-               // Make sure all parameters are set correctly
-               if (null == client) {
-                       // Abort here
-                       throw new NullPointerException("client is null"); //NOI18N
-               }
-
-               // Set client instance
-               this.setClient(client);
-
-               // Init database connection
-               DatabaseFrontend frontend = new AddressbookContactDatabaseFrontend(this);
-               this.setFrontend(frontend);
-
-               // Initialize list
-               this.columnNames = new ArrayList<>(15);
-               this.translatedColumnNames = new ArrayList<>(15);
-
-               // And fill it
-               this.fillColumnNamesFromBundle();
-
-               // Debug message
-               //* NOISY-DEBUG: */ this.getLogger().logDebug("client=" + client);
-       }
-
-       @Override
-       public void addContact (final Contact contact) throws ContactAlreadyAddedException {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
-
-               // Contact instance must not be null
-               if (null == contact) {
-                       // Abort here
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-
-               // Add it
-               ((AddressbookContactFrontend) this.getFrontend()).addContact(contact);
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public void doAddOtherAddress () {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public void doChangeAddressData (final Contact contact) {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
-
-               // Contact must not be null
-               if (null == contact) {
-                       // Abort here
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-               if (!(this.getClient() instanceof AddressbookClient)) {
-                       // Cannot cast
-                       throw new IllegalArgumentException(MessageFormat.format("this.getClient()={0} does not implement AddressbookClient", this.getClient())); //NOI18N
-               }
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               // First display it again
-               client.displayAddressBox(contact);
-
-               // Is it own data?
-               if (contact.isOwnContact()) {
-                       // Deligate to client
-                       client.doChangeOwnAddressData(contact);
-               } else {
-                       // Other contact's address data to change
-                       throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
-               }
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public void doChangeNameData (final Contact contact) {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
-
-               // Contact must not be null
-               if (null == contact) {
-                       // Abort here
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               // First display them again
-               client.displayNameBox(contact);
-
-               // Is this own data?
-               if (contact.isOwnContact()) {
-                       // Re-ask own data
-                       client.doChangeOwnNameData(contact);
-               } else {
-                       // Then re-ask them ...
-                       throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
-               }
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public void doChangeOtherAddress () {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public void doChangeOtherData (final Contact contact) {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
-
-               // Contact must not be null
-               if (null == contact) {
-                       // Abort here
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               // First display them again
-               client.displayOtherDataBox(contact);
-
-               // Is this own data?
-               if (contact.isOwnContact()) {
-                       // Re-ask own data
-                       client.doChangeOwnOtherData(contact);
-               } else {
-                       // Then re-ask them ...
-                       throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
-               }
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               /*
-                * First check if the user has registered own contact, before that
-                * nothing can be changed.
-                */
-               if (!this.isOwnContactAdded()) {
-                       // Not added
-                       this.getClient().outputMessage("Sie haben noch nicht Ihre Daten eingegeben."); //NOI18N
-
-                       // Skip any below code
-                       return;
-               }
-
-               // Instance
-               Contact contact = this.getOwnContact();
-
-               // It must be found
-               assert (contact instanceof Contact) : ": contact is not implementing Contact: " + contact;
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               // Display contact
-               client.show(contact);
-
-               try {
-                       // Ask user what to change
-                       client.userChooseChangeContactData(contact);
-               } catch (final UnhandledUserChoiceException ex) {
-                       this.getLogger().logException(ex);
-               }
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public void doDeleteOtherAddress () {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public void doEnterOwnData () throws ContactAlreadyAddedException, IOException {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Is own contact already added?
-               if (this.isOwnContactAdded()) {
-                       // Don't continue here
-                       throw new ContactAlreadyAddedException();
-               }
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               // Deligate this call to the client
-               Contact contact = client.doEnterOwnData();
-
-               // Is it set?
-               if (contact instanceof Contact) {
-                       // Add it to contact "book"
-                       this.registerContact(contact);
-               }
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public void doListContacts () {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public void doSearchContacts () {
-               throw new UnsupportedOperationException("Not supported yet."); //NOI18N
-       }
-
-       @Override
-       public void doShutdown () throws SQLException, IOException {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Shut down the database layer
-               ((AddressbookContactFrontend) this.getFrontend()).doShutdown();
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       @Override
-       public String enterOwnCellNumber () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
-       }
-
-       @Override
-       public String enterOwnCity () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
-       }
-
-       @Override
-       public String enterOwnComment () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
-       }
-
-       @Override
-       public String enterOwnCompanyName () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
-       }
-
-       @Override
-       public String enterOwnCountryCode () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();
-       }
-
-       @Override
-       public String enterOwnEmailAddress () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
-       }
-
-       @Override
-       public String enterOwnFamilyName () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
-       }
-
-       @Override
-       public String enterOwnFaxNumber () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
-       }
-
-       @Override
-       public String enterOwnFirstName () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
-       }
-
-       @Override
-       public Gender enterOwnGender () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
-       }
-
-       @Override
-       public String enterOwnPhoneNumber () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
-       }
-
-       @Override
-       public String enterOwnStreet () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
-       }
-
-       @Override
-       public int enterOwnZipCode () {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Get and cast client instance
-               AddressbookClient client = (AddressbookClient) this.getClient();
-
-               return client.enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
-       }
-
-       @Override
-       public final int getColumnCount () {
-               assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
-
-               return this.columnNames.size();
-       }
-
-       @Override
-       public String getColumnName (final int columnIndex) {
-               assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
-
-               // Get column name at index
-               return this.columnNames.get(columnIndex);
-       }
-
-       @Override
-       public String getTranslatedColumnName (final int columnIndex) {
-               assert (this.translatedColumnNames instanceof List) : "this.translatedColumnNames is not initialized"; //NOI18N
-
-               // Get column name at index
-               return this.translatedColumnNames.get(columnIndex);
-       }
-
-       @Override
-       public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex)); //NOI18N
-
-               // Then get specific row from database which is a Contact instance
-               Storable storable = this.getFrontend().getStorableAtRow(rowIndex);
-
-               // Debug message
-               this.getLogger().logDebug(MessageFormat.format("storable={0}", storable)); //NOI18N
-
-               // It may return null
-               if (null == storable) {
-                       // Nothing found
-                       this.getLogger().logWarning("contact is null - returning null ..."); //NOI18N
-                       return null;
-               }
-
-               // Convert column index -> name
-               String columnName = this.getColumnName(columnIndex);
-
-               // Debug message
-               this.getLogger().logDebug(MessageFormat.format("columnName={0}", columnName)); //NOI18N
-
-               // Now get that column
-               Object value = null;
-               try {
-                       value = storable.getValueFromColumn(columnName);
-               } catch (final IllegalArgumentException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
-                       this.abortProgramWithException(ex);
-               }
-
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N
-
-               // Return it
-               return value;
-       }
-
-       @Override
-       public boolean isOwnContactAdded () throws IOException {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Init variable
-               boolean isAdded = false;
-
-               try {
-                       // Deligate this call to frontend
-                       isAdded = ((AddressbookContactFrontend) this.getFrontend()).isOwnContactFound();
-               } catch (final SQLException | IOException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
-                       // Something bad happened
-                       this.abortProgramWithException(ex);
-               }
-
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
-
-               // Return result
-               return isAdded;
-       }
-
-       @Override
-       public void registerContact (final Contact contact) {
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
-
-               // Sanity check
-               if (null == contact) {
-                       // Abort here
-                       throw new NullPointerException("contact is null"); //NOI18N
-               }
-               try {
-                       // Check if contact is found
-                       if (((AddressbookContactFrontend) this.getFrontend()).isContactFound(contact)) {
-                               // Contact already added
-                               // TODO Do something here
-                       } else if ((contact.isOwnContact()) && (this.isOwnContactAdded())) {
-                               // Own contact already added
-                               // TODO Do something
-                       }
-
-                       // Add contact to internal list
-                       this.addContact(contact);
-               } catch (final ContactAlreadyAddedException | SQLException | IOException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
-                       // Abort here
-                       this.abortProgramWithException(ex);
-               }
-
-               // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
-       }
-
-       /**
-        * Logs given exception and exits program
-        *
-        * @param throwable Throwable
-        */
-       private void abortProgramWithException (Throwable throwable) {
-               // Log exception
-               this.logException(throwable);
-
-               // Abort here
-               System.exit(1);
-       }
-
-       /**
-        * Fills the column names array with strings from bundle
-        */
-       private void fillColumnNamesFromBundle () {
-               assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
-               assert (this.translatedColumnNames instanceof List) : "this.translatedColumnNames is not initialized"; //NOI18N
-
-               // Debug message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // First get an iterator from key set to iterate over
-               Iterator<String> iterator = this.getBundle().keySet().iterator();
-
-               // Then iterate over all
-               while (iterator.hasNext()) {
-                       // Get next element
-                       String key = iterator.next().toLowerCase();
-
-                       // Does the key start with AddressbookContactManager.columnName ?
-                       if (key.startsWith("ContactManager.columnName")) { //NOI18N
-                               // This is the wanted entry.
-                               this.getLogger().logDebug(MessageFormat.format("key={0}", key)); //NOI18N
-
-                               // Convert string to array based on delimiter '.'
-                               String[] tokens = this.getArrayFromString(key, "."); //NOI18N
-
-                               // Token array must contain 4 elements (AddressbookContactManager.columnName.foo.text)
-                               assert (tokens.length == 4) : MessageFormat.format("Array tokens contains not 4 elements: {0}", Arrays.toString(tokens)); //NOI18N
-
-                               // Get pre-last element
-                               String columnName = tokens[tokens.length - 2];
-
-                               // Debug message
-                               this.getLogger().logDebug(MessageFormat.format("columnName={0} - adding ...", columnName)); //NOI18N
-
-                               // So add it
-                               this.columnNames.add(columnName);
-                               this.translatedColumnNames.add(this.getBundle().getString(key));
-                       }
-               }
-
-               // Debug message
-               this.getLogger().logTrace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
-       }
-
-       /**
-        * Getter for logger instance
-        *
-        * @return Logger instance
-        */
-       private LoggerBeanLocal getLogger () {
-               return this.logger;
-       }
-
-       /**
-        * "Getter" for own contact instance or null if not found
-        * <p>
-        * @return Contact instance or null
-        * @throws java.sql.SQLException If an SQL error occurs
-        * @throws java.io.IOException If an IO error occurs
-        * @throws java.lang.NoSuchMethodException If a method cannot be found
-        * @throws java.lang.IllegalAccessException If a method is not accessible
-        * @throws java.lang.reflect.InvocationTargetException Any other problems?
-        */
-       private Contact getOwnContact () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-               // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
-
-               // Deligate this call to database frontend
-               Contact contact = ((AddressbookContactFrontend) this.getFrontend()).getOwnContact();
-
-               // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
-
-               // Return instance or null
-               return contact;
-       }
-
-       /**
-        * Logs given exception
-        * <p>
-        * @param exception Throwable
-        */
-       protected void logException (final Throwable exception) {
-               this.getLogger().logException(exception);
-       }
-}
diff --git a/src/org/mxchange/addressbook/manager/contact/ManageableContactAddressbook.java b/src/org/mxchange/addressbook/manager/contact/ManageableContactAddressbook.java
deleted file mode 100644 (file)
index ac9b1eb..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.manager.contact;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
-import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcore.manager.Manageable;
-
-/**
- * An interface for addressbook contact manager
- * <p>
- * @author Roland Haeder
- */
-public interface ManageableContactAddressbook extends Manageable {
-
-       /**
-        * Adds given Contact instance to list
-        * <p>
-        * @param contact Contact instance to add
-        * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added
-        */
-       public void addContact (final Contact contact) throws ContactAlreadyAddedException;
-
-       /**
-        * Let the user add a new other address
-        */
-       public void doAddOtherAddress ();
-
-       /**
-        * The user can change address data, like street, ZIP code, city and country
-        * of given Contact instance.
-        * <p>
-        * @param contact Instance to change data
-        */
-       public void doChangeAddressData (final Contact contact);
-
-       /**
-        * The user can change name data, like gender, surname, family name and
-        * company name (if business contact).
-        * <p>
-        * @param contact Instance to change data
-        */
-       public void doChangeNameData (final Contact contact);
-
-       /**
-        * Let the user change other address
-        */
-       public void doChangeOtherAddress ();
-
-       /**
-        * The user can change other data, like phone numbers or comments.
-        * <p>
-        * @param contact Instance to change data
-        */
-       public void doChangeOtherData (final Contact contact);
-
-       /**
-        * Let the user change own data
-        * <p>
-        * @throws java.sql.SQLException If an SQL error occurs
-        * @throws java.io.IOException If an IO error occurs
-        * @throws java.lang.NoSuchMethodException If a method cannot be found
-        * @throws java.lang.IllegalAccessException If a method is not accessible
-        * @throws java.lang.reflect.InvocationTargetException Any other problems?
-        */
-       public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
-       /**
-        * Let the user delete other address
-        */
-       public void doDeleteOtherAddress ();
-
-       /**
-        * Asks user for own data
-        * <p>
-        * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException
-        * If own contact is already added
-        * @throws java.io.IOException If an IO error was found
-        */
-       public void doEnterOwnData () throws ContactAlreadyAddedException, IOException;
-
-       /**
-        * List all contacts
-        */
-       public void doListContacts ();
-
-       /**
-        * Searches address book for a contact
-        */
-       public void doSearchContacts ();
-
-       /**
-        * Allows the user to enter own cellphone number.
-        * <p>
-        * @return Cellphone number
-        */
-       public String enterOwnCellNumber ();
-
-       /**
-        * Allows the user to enter own city name.
-        * <p>
-        * @return City name
-        */
-       public String enterOwnCity ();
-
-       /**
-        * Allows the user to enter comment for own entry.
-        * <p>
-        * @return Comment
-        */
-       public String enterOwnComment ();
-
-       /**
-        * Allows the user to enter own company name.
-        * <p>
-        * @return Company name
-        */
-       public String enterOwnCompanyName ();
-
-       /**
-        * Allows the user to enter own country code.
-        * <p>
-        * @return Country code
-        */
-       public String enterOwnCountryCode ();
-
-       /**
-        * Allows the user to enter own email address.
-        * <p>
-        * @return Email address
-        */
-       public String enterOwnEmailAddress ();
-
-       /**
-        * Allows the user to enter own family name.
-        * <p>
-        * @return Family name
-        */
-       public String enterOwnFamilyName ();
-
-       /**
-        * Allows the user to enter own fax number.
-        * <p>
-        * @return Fax number
-        */
-       public String enterOwnFaxNumber ();
-
-       /**
-        * Allows the user to enter own surname.
-        * <p>
-        * @return Surname
-        */
-       public String enterOwnFirstName ();
-
-       /**
-        * Allows the user to enter own gender.
-        * <p>
-        * @return Gender
-        */
-       public Gender enterOwnGender ();
-
-       /**
-        * Allows the user to enter own phone number.
-        * <p>
-        * @return Phone number
-        */
-       public String enterOwnPhoneNumber ();
-
-       /**
-        * Allows the user to enter own street and house number.
-        * <p>
-        * @return Street and house number
-        */
-       public String enterOwnStreet ();
-
-       /**
-        * Allows the user to enter own ZIP code.
-        * <p>
-        * @return ZIP code
-        */
-       public int enterOwnZipCode ();
-
-       /**
-        * Getter for column count
-        * <p>
-        * @return Column count TODO: This is needed for TableModel in Swing
-        */
-       public int getColumnCount ();
-
-       /**
-        * Getter for column name at given index.
-        * <p>
-        * @param columnIndex Column index
-        * @return Database column name TODO: This is needed for TableModel in Swing
-        */
-       public String getColumnName (final int columnIndex);
-
-       /**
-        * Getter for translated column name at given index.
-        * <p>
-        * @param columnIndex Column index
-        * @return Human-readable column name TODO: This is needed for TableModel in
-        * Swing
-        */
-       public String getTranslatedColumnName (final int columnIndex);
-
-       /**
-        * Somewhat "getter" for value from given row and column index
-        * <p>
-        * @param rowIndex Row index
-        * @param columnIndex Column index
-        * @return Value from given row/column
-        * @throws java.lang.NoSuchMethodException If the method was not found
-        * @throws java.lang.IllegalAccessException If the accessed method was not public
-        * @throws java.lang.reflect.InvocationTargetException Something else
-        * happened? TODO: This is needed for TableModel in Swing
-        */
-       public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
-       /**
-        * Checks whether own contact is already added by checking all entries for
-        * isOwnContact flag
-        * <p>
-        * @return Whether own contact is already added
-        * @throws java.io.IOException If an IO error occurs
-        */
-       public boolean isOwnContactAdded () throws IOException;
-
-       /**
-        * Adds given contact to address book
-        * <p>
-        * @param contact Contact being added TODO Add check for book size
-        */
-       public void registerContact (final Contact contact);
-}