--- /dev/null
+/*
+ * 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;
+
+import org.mxchange.jcore.BaseFrameworkSystem;
+
+/**
+ * General class
+ *
+ * @author Roland Haeder
+ */
+public class BaseAddressbookSystem extends BaseFrameworkSystem {
+ /**
+ * No instances can be created of this class
+ */
+ protected BaseAddressbookSystem () {
+ }
+}
+++ /dev/null
-/*
- * 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;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.mxchange.addressbook.application.Application;
-import org.mxchange.addressbook.client.Client;
-import org.mxchange.addressbook.database.frontend.DatabaseFrontend;
-import org.mxchange.addressbook.manager.contact.ManageableContact;
-
-/**
- * General class
- *
- * @author Roland Haeder
- */
-public class BaseFrameworkSystem implements FrameworkInterface {
-
- /**
- * Instance for own properties
- */
- private static final Properties properties = new Properties(System.getProperties());
-
- /**
- * Class' logger
- */
- private final Logger LOG;
-
- /**
- * Application instance
- */
- private Application application;
-
- /**
- * Bundle instance
- */
- private final ResourceBundle bundle;
-
- /**
- * Client instance
- */
- private Client client;
-
- /**
- * Contact manager instance
- */
- private ManageableContact contactManager;
-
- /**
- * Name of used database table, handled over to backend
- */
- private String tableName;
-
- /**
- * DatabaseFrontend instance
- */
- private DatabaseFrontend wrapper;
-
- /**
- * Initialize object
- */
- {
- LOG = LogManager.getLogger(this);
- bundle = ResourceBundle.getBundle("org/mxchange/addressbook/localization/bundle"); // NOI18N
- }
-
- /**
- * No instances can be created of this class
- */
- protected BaseFrameworkSystem () {
- // Init properties file
- this.initProperties();
- }
-
- /**
- * Application instance
- *
- * @return the application
- */
- @Override
- public final Application getApplication () {
- return this.application;
- }
-
- /**
- * Getter for human-readable string from given key
- *
- * @param key Key to return
- * @return Human-readable message
- */
- @Override
- public final String getMessageStringFromKey (final String key) {
- // Return message
- return this.getBundle().getString(key);
- }
-
- /**
- * Some "getter for a value from given column name. This name will be
- * translated into a method name and then this method is called.
- *
- * @param columnName Column name
- * @return Value from field
- */
- @Override
- public Object getValueFromColumn (final String columnName) {
- throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0}", columnName)); //NOI18N
- }
-
- /**
- * Some "getter" for target class instance from given name.
- *
- * @param instance Instance to iterate on
- * @param targetClass Class name to look for
- * @return Class instance
- */
- @SuppressWarnings ("unchecked")
- private Class<? extends FrameworkInterface> getClassFromTarget (final FrameworkInterface instance, final String targetClass) {
- // Trace message
- this.getLogger().debug(MessageFormat.format("instance={0},targetClass={1}", instance, targetClass)); //NOI18N
-
- // Instance reflaction of this class
- Class<? extends FrameworkInterface> c = instance.getClass();
-
- // Analyze class
- while (!targetClass.equals(c.getSimpleName())) {
- // Debug message
- this.getLogger().debug(MessageFormat.format("c={0}", c.getSimpleName())); //NOI18N
-
- // Get super class (causes unchecked warning)
- c = (Class<? extends FrameworkInterface>) c.getSuperclass();
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("c={0} - EXIT!", c)); //NOI18N
-
- // Return it
- return c;
- }
-
- /**
- * Some "getter" for a Method instance from given method name
- *
- * @param instance Actual instance to call
- * @param targetClass Target class name
- * @param methodName Method name
- * @return A Method instance
- */
- private Method getMethodFromName (final FrameworkInterface instance, final String targetClass, final String methodName) {
- // Trace messahe
- this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
-
- // Get target class instance
- Class<? extends FrameworkInterface> c = this.getClassFromTarget(instance, targetClass);
-
- // Init field instance
- Method method = null;
-
- // Use reflection to get all attributes
- try {
- method = c.getDeclaredMethod(methodName, new Class<?>[0]);
- } catch (final SecurityException ex) {
- // Security problem
- this.abortProgramWithException(ex);
- } catch (final NoSuchMethodException ex) {
- // Method not found
- this.abortProgramWithException(ex);
- }
-
- // Assert on field
- assert (method instanceof Method) : "method is not a Method instance"; //NOI18N
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("method={0} - EXIT!", method)); //NOI18N
-
- // Return it
- return method;
- }
-
- /**
- * Aborts program with given exception
- *
- * @param throwable Any type of Throwable
- */
- protected final void abortProgramWithException (final Throwable throwable) {
- // Log exception ...
- this.getLogger().catching(throwable);
-
- // .. and exit
- System.exit(1);
-
- }
-
- /**
- * Application instance
- *
- * @param application the application to set
- */
- protected final void setApplication (final Application application) {
- this.application = application;
- }
-
- /**
- * Client instance
- *
- * @return the client
- */
- @Override
- public final Client getClient () {
- return this.client;
- }
-
- /**
- * Getter for bundle instance
- *
- * @return Resource bundle
- */
- protected final ResourceBundle getBundle () {
- return this.bundle;
- }
-
- /**
- * Client instance
- *
- * @param client the client to set
- */
- protected final void setClient (final Client client) {
- this.client = client;
- }
-
- /**
- * Contact manager instance
- *
- * @return the contactManager
- */
- @Override
- public final ManageableContact getContactManager () {
- return this.contactManager;
- }
-
- /**
- * Contact manager instance
- *
- * @param contactManager the contactManager to set
- */
- protected final void setContactManager (final ManageableContact contactManager) {
- this.contactManager = contactManager;
- }
-
- /**
- * Checks if given boolean field is available and set to same value
- *
- * @param columnName Column name to check
- * @param bool Boolean value
- * @return Whether all conditions are met
- */
- @Override
- public boolean isValueEqual (final String columnName, final boolean bool) {
- // Not implemented
- throw new UnsupportedOperationException(MessageFormat.format("Not implemented. columnName={0},bool={1}", columnName, bool)); //NOI18N
- }
-
- /**
- * Log exception
- *
- * @param exception Exception to log
- */
- @Override
- public final void logException (final Throwable exception) {
- // Log this exception
- this.getLogger().catching(exception);
- }
-
- /**
- * Prepares all properties, the file is written if it is not found
- */
- private void initProperties () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("{0} properties are loaded already.", BaseFrameworkSystem.properties.size())); //NOI18N
-
- // Are some properties loaded?
- if (!BaseFrameworkSystem.properties.isEmpty()) {
- // Some are already loaded, abort here
- return;
- }
-
- try {
- // Try to read it
- BaseFrameworkSystem.properties.load(new BufferedReader(new InputStreamReader(new FileInputStream(FrameworkInterface.PROPERTIES_CONFIG_FILE))));
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("{0} properties has been loaded.", BaseFrameworkSystem.properties.size())); //NOI18N
- } catch (final FileNotFoundException ex) {
- // Debug message
- this.getLogger().debug(MessageFormat.format("Properties file {0} not found: {1}", FrameworkInterface.PROPERTIES_CONFIG_FILE, ex)); //NOI18N
-
- /*
- * The file is not found which is normal for first run, so
- * initialize default values.
- */
- this.initPropertiesWithDefault();
-
- // Write file
- this.writePropertiesFile();
- } catch (final IOException ex) {
- // Something else didn't work
- this.abortProgramWithException(ex);
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Initializes properties with default values
- */
- private void initPropertiesWithDefault () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Init default values:
- // Default database backend
- BaseFrameworkSystem.properties.put("org.mxchange.addressbook.database.backendType", "base64csv"); //NOI18N
-
- // For MySQL backend
- BaseFrameworkSystem.properties.put("org.mxchange.addressbook.database.mysql.host", "localhost"); //NOI18N
- BaseFrameworkSystem.properties.put("org.mxchange.addressbook.database.mysql.dbname", "test"); //NOI18N
- BaseFrameworkSystem.properties.put("org.mxchange.addressbook.database.mysql.login", ""); //NOI18N
- BaseFrameworkSystem.properties.put("org.mxchange.addressbook.database.mysql.password", ""); //NOI18N
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Writes the properties file to disk
- */
- private void writePropertiesFile () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- try {
- // Write it
- BaseFrameworkSystem.properties.store(new PrintWriter(FrameworkInterface.PROPERTIES_CONFIG_FILE), "This file is automatically generated. You may wish to alter it."); //NOI18N
- } catch (final IOException ex) {
- this.abortProgramWithException(ex);
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Converts a column name like "foo_bar" to an attribute name like "fooBar"
- *
- * @param columnName Column name to convert
- * @return Attribute name
- */
- protected String convertColumnNameToAttribute (final String columnName) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N
-
- // First all lower case
- String lower = columnName.toLowerCase();
-
- // Then split on "_"
- StringTokenizer tokenizer = new StringTokenizer(lower, "_"); //NOI18N
-
- // Resulting string
- StringBuilder builder = new StringBuilder(tokenizer.countTokens());
-
- // Init counter
- int count = 0;
-
- // Walk through all
- while (tokenizer.hasMoreTokens()) {
- // Get token
- String token = tokenizer.nextToken();
-
- // Is later than first element?
- if (count > 0) {
- // Make first character upper-case
- char c = token.charAt(0);
- token = String.valueOf(c).toUpperCase() + token.substring(1);
- }
-
- // Add token
- builder.append(token);
-
- // Increment counter
- count++;
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("builder={0} - EXIT!", builder)); //NOI18N
-
- // Return result
- return builder.toString();
- }
-
- /**
- * Converts a column name like "foo_bar" to a method name like "getFooBar"
- * for non-booleans and to "isFooBar" for boolean fields.
- *
- * @param columnName Column name to convert
- * @param isBool Whether the parameter is boolean
- * @return Attribute name
- */
- protected String convertColumnNameToGetterMethod (final String columnName, boolean isBool) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N
-
- // Then split on "_"
- StringTokenizer tokenizer = new StringTokenizer(columnName, "_"); //NOI18N
-
- // Resulting string
- StringBuilder builder = new StringBuilder(tokenizer.countTokens());
-
- // Is it boolean?
- if (isBool) {
- // Append "is"
- builder.append("is"); //NOI18N
- } else {
- // Append "get"
- builder.append("get"); //NOI18N
- }
-
- // Walk through all
- while (tokenizer.hasMoreTokens()) {
- // Get token
- String token = tokenizer.nextToken();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("token={0}", token)); //NOI18N
-
- // Make it upper-case
- char c = token.charAt(0);
- token = String.valueOf(c).toUpperCase() + token.substring(1);
-
- // Add token
- builder.append(token);
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("builder={0} - EXIT!", builder)); //NOI18N
-
- // Return result
- return builder.toString();
- }
-
- /**
- * Returns boolean field value from given method call
- *
- * @param instance The instance to call
- * @param targetClass Target class to look in
- * @param methodName Method name to look for
- * @return Boolean value from field
- */
- protected boolean getBooleanField (final FrameworkInterface instance, final String targetClass, final String methodName) {
- // Trace messahe
- this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
-
- // Get method instance
- Method method = this.getMethodFromName(instance, targetClass, methodName);
-
- // Get value from field
- Boolean value = false;
-
- try {
- value = (Boolean) method.invoke(instance);
- } catch (final IllegalArgumentException ex) {
- // Other problem
- this.abortProgramWithException(ex);
- } catch (final IllegalAccessException ex) {
- // Other problem
- this.abortProgramWithException(ex);
- } catch (final InvocationTargetException ex) {
- // Other problem
- this.abortProgramWithException(ex);
- }
-
- // Return value
- return value;
- }
-
- /**
- * Returns any field value from given method call
- *
- * @param instance The instance to call
- * @param targetClass Target class to look in
- * @param methodName Method name to look for
- * @return Any value from field
- */
- protected Object getField (final FrameworkInterface instance, final String targetClass, final String methodName) {
- // Trace messahe
- this.getLogger().trace(MessageFormat.format("targetClass={0},methodName={1}", targetClass, methodName)); //NOI18N
-
- // Get method to call
- Method method = this.getMethodFromName(instance, targetClass, methodName);
-
- // Get value from field
- Object object = null;
-
- try {
- object = method.invoke(instance);
- } catch (final IllegalArgumentException ex) {
- // Other problem
- this.abortProgramWithException(ex);
- } catch (final IllegalAccessException ex) {
- // Other problem
- this.abortProgramWithException(ex);
- } catch (final InvocationTargetException ex) {
- // Other problem
- this.abortProgramWithException(ex);
- }
-
- // Return value
- return object;
- }
-
- /**
- * Getter for logger
- *
- * @return Logger
- */
- protected final Logger getLogger () {
- return this.LOG;
- }
-
- /**
- * Getter for property which must exist
- *
- * @param key Key to get
- * @return Propety value
- */
- protected final String getProperty (final String key) {
- return BaseFrameworkSystem.properties.getProperty(String.format("org.mxchange.addressbook.%s", key)); //NOI18N
- }
-
- /**
- * Name of used database table, handled over to backend
- *
- * @return the tableName
- */
- protected final String getTableName () {
- return this.tableName;
- }
-
- /**
- * Name of used database table, handled over to backend
- *
- * @param tableName the tableName to set
- */
- protected final void setTableName (final String tableName) {
- this.tableName = tableName;
- }
-
- /**
- * Getter for DatabaseFrontend instance
- *
- * @return DatabaseFrontend instance
- */
- protected DatabaseFrontend getWrapper () {
- return this.wrapper;
- }
-
- /**
- * Setter for wrapper instance
- *
- * @param wrapper A DatabaseFrontend instance
- */
- protected void setWrapper (final DatabaseFrontend wrapper) {
- this.wrapper = wrapper;
- }
-
- /**
- * Some "getter" for an array from given string and tokenizer
- *
- * @param str String to tokenize and get array from
- * @param delimiter Delimiter
- * @param size Size of array
- * @return Array from tokenized string
- */
- protected String[] getArrayFromString (final String str, final String delimiter, final int size) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("str={0},delimiter={1},size={2} - CALLED!", str, delimiter, size)); //NOI18N
-
- // Get tokenizer
- StringTokenizer tokenizer = new StringTokenizer(str, delimiter);
-
- // Init array and index
- String[] tokens = new String[size];
- int index = 0;
-
- // Run through all tokens
- while (tokenizer.hasMoreTokens()) {
- // Get current token and add it
- tokens[index] = tokenizer.nextToken();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Token at index{0}: {1}", index, tokens[1])); //NOI18N
-
- // Increment index
- index++;
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("tokens({0})={1} - EXIT!", tokens.length, Arrays.toString(tokens))); //NOI18N
-
- // Return it
- return tokens;
- }
-
- /**
- * Checks whether the given field is a boolean field by probing it.
- *
- * @param instance Instance to call
- * @param targetClass Target class
- * @param columnName Column name to check
- * @return Whether the given column name represents a boolean field
- */
- protected boolean isBooleanField (final FrameworkInterface instance, final String targetClass, final String columnName) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("instance={0},targetCLass={1},columnName={2} - CALLED!", instance, targetClass, columnName)); //NOI18N
-
- // Convert column name to getter name (boolean)
- String methodName = this.convertColumnNameToGetterMethod(columnName, true);
-
- // Get class instance
- Class<? extends FrameworkInterface> c = this.getClassFromTarget(instance, targetClass);
-
- // Defauzlt is boolean
- boolean isBool = true;
-
- try {
- // Now try to instance the method
- Method method = c.getDeclaredMethod(methodName, new Class<?>[0]);
- } catch (final NoSuchMethodException ex) {
- // Debug message
- this.getLogger().debug(MessageFormat.format("Method {0} does not exist, field {1} cannot be boolean: {2}", methodName, columnName, ex)); //NOI18N
-
- // Not found
- isBool = false;
- } catch (final SecurityException ex) {
- // Really bad?
- this.abortProgramWithException(ex);
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("isBool={0} - EXIT!", isBool)); //NOI18N
-
- // Return result
- return isBool;
- }
-}
+++ /dev/null
-/*
- * 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;
-
-import org.mxchange.addressbook.application.Application;
-import org.mxchange.addressbook.client.Client;
-import org.mxchange.addressbook.manager.contact.ManageableContact;
-
-/**
- * A general interface which should be always expanded
- *
- * @author Roland Haeder
- */
-public interface FrameworkInterface {
- /*
- * Properties file name
- */
- public static final String PROPERTIES_CONFIG_FILE = "config.properties";
-
- /**
- * Getter for contact manager
- *
- * @return Contact manager instance
- */
- public ManageableContact getContactManager ();
-
- /**
- * Client instance
- *
- * @return the client
- */
- public Client getClient ();
-
- /**
- * Application instance
- *
- * @return the application
- */
- public Application getApplication ();
-
- /**
- * Getter for human-readable string from given key
- *
- * @param key Key to return
- * @return Human-readable message
- */
- public String getMessageStringFromKey (final String key);
-
- /**
- * Logs given exception
- *
- * @param exception Exception to log
- */
- public void logException (final Throwable exception);
-
- /**
- * Checks if given boolean field is available and set to same value
- *
- * @param columnName Column name to check
- * @param bool Boolean value
- * @return Whether all conditions are met
- */
- public boolean isValueEqual (final String columnName, final boolean bool);
-
- /**
- * Some "getter for a value from given column name. This name will be
- * translated into a method name and then this method is called.
- *
- * @param columnName Column name
- * @return Value from field
- */
- public Object getValueFromColumn (final String columnName);
-}
package org.mxchange.addressbook.application;
import java.text.MessageFormat;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.client.console.ConsoleClient;
import org.mxchange.addressbook.client.gui.SwingClient;
-import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
-import org.mxchange.addressbook.manager.application.ApplicationManager;
+import org.mxchange.jcore.application.Application;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
+import org.mxchange.jcore.manager.application.ApplicationManager;
/**
* ============================================
* @author Roland Haeder
* @version 0.0
*/
-public class AddressbookApplication extends BaseFrameworkSystem implements Application {
+public class AddressbookApplication extends BaseAddressbookSystem implements Application {
/**
* Application title
*/
@Override
public void doMainLoop () {
+ // Get client and cast it
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
// Debug message
this.getLogger().trace("CALLED!"); //NOI18N
this.showIntro();
// Set current menu to main
- this.getClient().setCurrentMenu("main"); //NOI18N
+ client.setCurrentMenu("main"); //NOI18N
// --- Main loop starts here ---
while (this.getClient().isRunning()) {
// The application is still active, show menu selection
- this.getClient().showCurrentMenu();
+ client.showCurrentMenu();
try {
// Ask for user input and run proper method
- this.getClient().doUserMenuChoice();
+ client.doUserMenuChoice();
} catch (final UnhandledUserChoiceException ex) {
this.getLogger().catching(ex);
}
+++ /dev/null
-/*
- * 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.application;
-
-import org.mxchange.addressbook.FrameworkInterface;
-
-/**
- *
- * @author Roland Haeder
- */
-public interface Application extends FrameworkInterface {
-
- /**
- * Bootstraps the application
- */
- public void doBootstrap ();
-
- /**
- * Run the main loop
- */
- public void doMainLoop ();
-
- /**
- * Shutdown the application
- */
- public void doShutdown ();
-}
--- /dev/null
+/*
+ * 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.client;
+
+import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
+import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
+
+/**
+ * A special client interface for addressbook applications.
+ *
+ * @author Roland Haeder
+ */
+public interface AddressbookClient extends Client {
+
+ /**
+ * Displays a "box" for the address
+ *
+ * @param contact Contact to show address from
+ */
+ public void displayAddressBox (final Contact contact);
+
+ /**
+ * The user changes own name data
+ *
+ * @param contact
+ */
+ public void doChangeOwnNameData (final Contact contact);
+
+ /**
+ * The user changes own address data
+ *
+ * @param contact Contact instance to change
+ */
+ public void doChangeOwnAddressData (final Contact contact);
+
+ /**
+ * The user changes own other data
+ *
+ * @param contact Constact instance to change
+ */
+ public void doChangeOwnOtherData (final Contact contact);
+
+ /**
+ * Allows the user to enter own data
+ *
+ * @return Finished Contact instance
+ */
+ public Contact doEnterOwnData ();
+
+ /**
+ * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
+ *
+ * @param message Message to output
+ * @return Gender enum
+ */
+ public Gender enterGender (final String message);
+
+ /**
+ * Displays a "box" for the name
+ *
+ * @param contact Contact to show name from
+ */
+ public void displayNameBox (final Contact contact);
+
+ /**
+ * Displays a "box" for other data
+ *
+ * @param contact Contact to show other data from
+ */
+ public void displayOtherDataBox (final Contact contact);
+
+ /**
+ * Let the user choose what to change on the address: [n]ame, [a]ddress,
+ * [o]ther
+ *
+ * @param contact Contact instance to let the user change data
+ * @throws UnhandledUserChoiceException If choice is not supported
+ */
+ public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
+
+ /**
+ * Asks the user for a choice and proceeds accordingly
+ *
+ * @throws UnhandledUserChoiceException If choice is not supported
+ */
+ public void doUserMenuChoice () throws UnhandledUserChoiceException;
+
+ /**
+ * Asks the the user to enter a single character which must match validChars
+ *
+ * @param validChars Valid chars that are accepted
+ * @param message Message to user
+ * @return Allowed character
+ */
+ public char enterChar (final char[] validChars, final String message);
+
+ /**
+ * Reads a string of minimum and maximum length from the user. An empty
+ * string should be generally not allowed, but might be okay for e.g.
+ * company name.
+ *
+ * @param minLength Minimum length of the string to read
+ * @param maxLength Maximum length of the string to read
+ * @param message Message to user
+ * @param allowEmpty Whether empty strings are allowed
+ * @return Entered string by user or null if empty string is allowed
+ */
+ public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
+
+ /**
+ * Reads an integer (int) from the user
+ *
+ * @param minimum Minimum allowed number
+ * @param maximum Maximum allowed number
+ * @param message Message to user
+ * @return Entered string by user or null if empty string is allowed
+ */
+ public int enterInt (final int minimum, final int maximum, final String message);
+
+ /**
+ * Setter for current menu choice
+ *
+ * @param currentMenu Current menu choice
+ */
+ public void setCurrentMenu (final String currentMenu);
+
+ /**
+ * Some "Getter" for menu item
+ *
+ * @param accessKey Key to press to access this menu
+ * @param text Text to show to user
+ * @return
+ */
+ public SelectableMenuItem getMenuItem (final char accessKey, final String text);
+
+ /**
+ * Shows given menu entry in client
+ *
+ * @param item Menu item to show
+ */
+ public void showEntry (final SelectableMenuItem item);
+
+ /**
+ * Shows current menu selection to the user
+ */
+ public void showCurrentMenu ();
+}
--- /dev/null
+/*
+ * 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.client;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+import org.mxchange.addressbook.manager.contact.ContactManager;
+import org.mxchange.addressbook.manager.contact.ManageableContact;
+import org.mxchange.addressbook.menu.Menu;
+import org.mxchange.jcore.client.BaseClient;
+import org.mxchange.jcore.client.Client;
+
+/**
+ * A general addressbook client
+ *
+ * @author Roland Haeder
+ */
+public abstract class BaseAddressbookClient extends BaseClient {
+
+ /**
+ * Current menu choice
+ */
+ private String currentMenu;
+
+ /**
+ * Menu system
+ */
+ private final Map<String, Menu> menus;
+
+ /**
+ * No instances can be created of this class
+ */
+ protected BaseAddressbookClient () {
+ // Init menu map
+ this.menus = new HashMap<>(10);
+ }
+
+ /**
+ * Current menu choice
+ *
+ * @return the currentMenu
+ */
+ public final String getCurrentMenu () {
+ return this.currentMenu;
+ }
+
+ /**
+ * Current menu choice
+ *
+ * @param currentMenu the currentMenu to set
+ */
+ public final void setCurrentMenu (final String currentMenu) {
+ this.currentMenu = currentMenu;
+ }
+
+ /**
+ * "Getter" for given menu type
+ *
+ * @param menuType Menu type instance to return
+ * @return Menu or null if not found
+ */
+ public Menu getMenu (final String menuType) {
+ // Default is not found
+ Menu menu = null;
+
+ // Check array
+ if (this.getMenus().containsKey(menuType)) {
+ // Found!
+ menu = this.getMenus().get(menuType);
+ }
+
+ // Return it
+ return menu;
+ }
+
+ /**
+ * Fills menu map with swing menus
+ */
+ protected abstract void fillMenuMap ();
+
+ /**
+ * Getter for menus map
+ *
+ * @return Map of all menus
+ */
+ protected final Map<String, Menu> getMenus () {
+ return this.menus;
+ }
+
+ /**
+ * Initializes contact manager
+ */
+ protected void initContactManager () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Debug message
+ this.getLogger().debug("Initializing contact manager ..."); //NOI18N
+
+ // Init contact manager with console client
+ // @TODO Static initial amount of contacts
+ ManageableContact manager = new ContactManager((Client) this);
+
+ // Set it here
+ this.setContactManager(manager);
+
+ // Debug message
+ this.getLogger().debug("Contact manager has been initialized."); //NOI18N
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
+
+ /**
+ * Shows given menu
+ *
+ * @param menuType Given menu to show
+ */
+ protected void showMenu (final String menuType) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("menuType={0} - CALLED!", menuType)); //NOI18N
+
+ Menu menu = this.getMenu(menuType);
+
+ // Is the menu set?
+ if (!(menu instanceof Menu)) {
+ // Not found
+ // @todo Own exception?
+ throw new NullPointerException(MessageFormat.format("Menu '{0}' not found.", menuType)); //NOI18N
+ }
+
+ // Show menu
+ menu.show((Client) this);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
+}
+++ /dev/null
-/*
- * 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.client;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.manager.contact.ContactManager;
-import org.mxchange.addressbook.manager.contact.ManageableContact;
-import org.mxchange.addressbook.menu.Menu;
-
-/**
- * A general client
- *
- * @author Roland Haeder
- */
-public abstract class BaseClient extends BaseFrameworkSystem {
-
- /**
- * Current menu choice
- */
- private String currentMenu;
-
- /**
- * Application is not running by default
- */
- private boolean isRunning;
-
- /**
- * Menu system
- */
- private final Map<String, Menu> menus;
-
- /**
- * No instances can be created of this class
- */
- protected BaseClient () {
- // Init menu map
- this.menus = new HashMap<>(10);
- }
-
- /**
- * Shutdown method for all clients
- */
- public void doShutdown () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Disable client
- this.disableIsRunning();
-
- // Shuts down contact manager
- this.getContactManager().doShutdown();
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Enables the client
- */
- public final void enableIsRunning () {
- this.isRunning = true;
- }
-
- /**
- * Current menu choice
- *
- * @return the currentMenu
- */
- public final String getCurrentMenu () {
- return this.currentMenu;
- }
-
- /**
- * Current menu choice
- *
- * @param currentMenu the currentMenu to set
- */
- public final void setCurrentMenu (final String currentMenu) {
- this.currentMenu = currentMenu;
- }
-
- /**
- * "Getter" for given menu type
- *
- * @param menuType Menu type instance to return
- * @return Menu or null if not found
- */
- public Menu getMenu (final String menuType) {
- // Default is not found
- Menu menu = null;
-
- // Check array
- if (this.getMenus().containsKey(menuType)) {
- // Found!
- menu = this.getMenus().get(menuType);
- }
-
- // Return it
- return menu;
- }
-
- /**
- * Determines whether the application is still active by checking some
- * conditions
- *
- * @return Whether the application is still active
- */
- public final boolean isRunning () {
- // In console client, 0 may have been used
- return this.isRunning;
- }
-
- /**
- * Disables the client
- */
- protected final void disableIsRunning () {
- this.isRunning = false;
- }
-
- /**
- * Fills menu map with swing menus
- */
- protected abstract void fillMenuMap ();
-
- /**
- * Getter for menus map
- *
- * @return Map of all menus
- */
- protected final Map<String, Menu> getMenus () {
- return this.menus;
- }
-
- /**
- * Initializes contact manager
- */
- protected void initContactManager () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Debug message
- this.getLogger().debug("Initializing contact manager ..."); //NOI18N
-
- // Init contact manager with console client
- // @TODO Static initial amount of contacts
- ManageableContact manager = new ContactManager((Client) this);
-
- // Set it here
- this.setContactManager(manager);
-
- // Debug message
- this.getLogger().debug("Contact manager has been initialized."); //NOI18N
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Shows given menu
- *
- * @param menuType Given menu to show
- */
- protected void showMenu (final String menuType) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("menuType={0} - CALLED!", menuType)); //NOI18N
-
- Menu menu = this.getMenu(menuType);
-
- // Is the menu set?
- if (!(menu instanceof Menu)) {
- // Not found
- // @todo Own exception?
- throw new NullPointerException(MessageFormat.format("Menu '{0}' not found.", menuType)); //NOI18N
- }
-
- // Show menu
- menu.show((Client) this);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * 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.client;
-
-import org.mxchange.addressbook.FrameworkInterface;
-import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
-import org.mxchange.addressbook.contact.Contact;
-import org.mxchange.addressbook.contact.Gender;
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-
-/**
- * An interface for application clients
- *
- * @author Roland Haeder
- */
-public interface Client extends FrameworkInterface {
-
- /**
- * Displays a "box" for the address
- *
- * @param contact Contact to show address from
- */
- public void displayAddressBox (final Contact contact);
-
- /**
- * The user changes own name data
- *
- * @param contact
- */
- public void doChangeOwnNameData (final Contact contact);
-
- /**
- * The user changes own address data
- *
- * @param contact Contact instance to change
- */
- public void doChangeOwnAddressData (final Contact contact);
-
- /**
- * The user changes own other data
- *
- * @param contact Constact instance to change
- */
- public void doChangeOwnOtherData (final Contact contact);
-
- /**
- * Allows the user to enter own data
- *
- * @return Finished Contact instance
- */
- public Contact doEnterOwnData ();
-
- /**
- * Shuts down the client and therefore whole application
- */
- public void doShutdown ();
-
- /**
- * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
- *
- * @param message Message to output
- * @return Gender enum
- */
- public Gender enterGender (final String message);
-
- /**
- * Displays a message to the user
- *
- * @param message Message to show to the user
- */
- public void outputMessage (final String message);
-
- /**
- * Displays a "box" for the name
- *
- * @param contact Contact to show name from
- */
- public void displayNameBox (final Contact contact);
-
- /**
- * Displays a "box" for other data
- *
- * @param contact Contact to show other data from
- */
- public void displayOtherDataBox (final Contact contact);
-
- /**
- * Let the user choose what to change on the address: [n]ame, [a]ddress,
- * [o]ther
- *
- * @param contact Contact instance to let the user change data
- * @throws UnhandledUserChoiceException If choice is not supported
- */
- public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
-
- /**
- * Asks the user for a choice and proceeds accordingly
- *
- * @throws UnhandledUserChoiceException If choice is not supported
- */
- public void doUserMenuChoice () throws UnhandledUserChoiceException;
-
- /**
- * Enables isRunning attribute which singals that the client is running
- */
- public void enableIsRunning ();
-
- /**
- * Asks the the user to enter a single character which must match validChars
- *
- * @param validChars Valid chars that are accepted
- * @param message Message to user
- * @return Allowed character
- */
- public char enterChar (final char[] validChars, final String message);
-
- /**
- * Reads a string of minimum and maximum length from the user. An empty
- * string should be generally not allowed, but might be okay for e.g.
- * company name.
- *
- * @param minLength Minimum length of the string to read
- * @param maxLength Maximum length of the string to read
- * @param message Message to user
- * @param allowEmpty Whether empty strings are allowed
- * @return Entered string by user or null if empty string is allowed
- */
- public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
-
- /**
- * Reads an integer (int) from the user
- *
- * @param minimum Minimum allowed number
- * @param maximum Maximum allowed number
- * @param message Message to user
- * @return Entered string by user or null if empty string is allowed
- */
- public int enterInt (final int minimum, final int maximum, final String message);
-
- /**
- * Setter for current menu choice
- *
- * @param currentMenu Current menu choice
- */
- public void setCurrentMenu (final String currentMenu);
-
- /**
- * Some "Getter" for menu item
- *
- * @param accessKey Key to press to access this menu
- * @param text Text to show to user
- * @return
- */
- public SelectableMenuItem getMenuItem (final char accessKey, final String text);
-
- /**
- * Determines whether the client is still active by checking some conditions
- *
- * @return Whether the client is still active
- */
- public boolean isRunning ();
-
- /**
- * Shows given menu entry in client
- *
- * @param item Menu item to show
- */
- public void showEntry (final SelectableMenuItem item);
-
- /**
- * Shows introduction to user
- */
- public void showWelcome ();
-
- /**
- * Shows current menu selection to the user
- */
- public void showCurrentMenu ();
-
- /**
- * Inizializes this client
- */
- public void init ();
-}
import java.util.Arrays;
import java.util.Scanner;
import org.mxchange.addressbook.application.AddressbookApplication;
-import org.mxchange.addressbook.application.Application;
-import org.mxchange.addressbook.client.BaseClient;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.client.BaseAddressbookClient;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.contact.user.UserContact;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
+import org.mxchange.addressbook.manager.contact.ManageableContact;
import org.mxchange.addressbook.menu.Menu;
import org.mxchange.addressbook.menu.MenuTools;
import org.mxchange.addressbook.menu.console.ConsoleMenu;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
import org.mxchange.addressbook.menu.item.console.ConsoleMenuItem;
+import org.mxchange.jcore.application.Application;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
/**
* A client for the console
*
* @author Roland Haeder
*/
-public class ConsoleClient extends BaseClient implements Client {
+public class ConsoleClient extends BaseAddressbookClient implements AddressbookClient {
/**
* Scanner instance for reading data from console input
this.setApplication(application);
// Init scanner instance
- this.scanner = new Scanner(System.in);
+ this.scanner = new Scanner(System.in, "UTF-8"); //NOI18N
// Trace message
this.getLogger().trace("EXIT!"); //NOI18N
throw new IllegalArgumentException("Contact is not own data."); //NOI18N
}
+ // Get manager and cast it
+ ManageableContact manager = (ManageableContact) this.getManager();
+
// Own address data
- String street = this.getContactManager().enterOwnStreet();
+ String street = manager.enterOwnStreet();
// Get zip code
- int zipCode = this.getContactManager().enterOwnZipCode();
+ int zipCode = manager.enterOwnZipCode();
// Get city name
- String city = this.getContactManager().enterOwnCity();
+ String city = manager.enterOwnCity();
// Get country code
- String countryCode = this.getContactManager().enterOwnCountryCode();
+ String countryCode = manager.enterOwnCountryCode();
// Update address data
contact.updateAddressData(street, zipCode, city, countryCode);
throw new IllegalArgumentException("Contact is not own data."); //NOI18N
}
+ // Get manager and cast it
+ ManageableContact manager = (ManageableContact) this.getManager();
+
// Gender:
- Gender gender = this.getContactManager().enterOwnGender();
+ Gender gender = manager.enterOwnGender();
// Surname
- String surname = this.getContactManager().enterOwnSurname();
+ String surname = manager.enterOwnSurname();
// Family name
- String familyName = this.getContactManager().enterOwnFamilyName();
+ String familyName = manager.enterOwnFamilyName();
// And company
- String companyName = this.getContactManager().enterOwnCompanyName();
+ String companyName = manager.enterOwnCompanyName();
// Update contact instance
contact.updateNameData(gender, surname, familyName, companyName);
throw new IllegalArgumentException("Contact is not own data."); //NOI18N
}
+ // Get manager and cast it
+ ManageableContact manager = (ManageableContact) this.getManager();
+
// Phone number
- String phoneNumber = this.getContactManager().enterOwnPhoneNumber();
+ String phoneNumber = manager.enterOwnPhoneNumber();
// Phone number
- String cellNumber = this.getContactManager().enterOwnCellNumber();
+ String cellNumber = manager.enterOwnCellNumber();
// Fax number
- String faxNumber = this.getContactManager().enterOwnFaxNumber();
+ String faxNumber = manager.enterOwnFaxNumber();
// Email address
- String email = this.getContactManager().enterOwnEmailAddress();
+ String email = manager.enterOwnEmailAddress();
// Comment
- String comment = this.getContactManager().enterOwnComment();
+ String comment = manager.enterOwnComment();
// Update contact instance
contact.updateOtherData(phoneNumber, cellNumber, faxNumber, email, null, comment);
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
+ // Get manager and cast it
+ ManageableContact manager = (ManageableContact) this.getManager();
+
// First ask for gender
- Gender gender = this.getContactManager().enterOwnGender();
+ Gender gender = manager.enterOwnGender();
// 2nd for surname
- String surname = this.getContactManager().enterOwnSurname();
+ String surname = manager.enterOwnSurname();
// And 3rd for family name
- String familyName = this.getContactManager().enterOwnFamilyName();
+ String familyName = manager.enterOwnFamilyName();
// Company name ...
- String companyName = this.getContactManager().enterOwnCompanyName();
+ String companyName = manager.enterOwnCompanyName();
// Construct UserContact instance
Contact contact = new UserContact(gender, surname, familyName, companyName);
// Output textural message and ask for a char as input
char choice = this.enterChar(accessKeys, "Bitte Auswahl eingeben (0=Programm beenden): ");
+ // Get manager and cast it
+ ManageableContact manager = (ManageableContact) this.getManager();
+
// @TODO Rewrite this ugly switch() block
switch (choice) {
case '1':
try {
// Enter/add own data
- this.getContactManager().doEnterOwnData();
+ manager.doEnterOwnData();
} catch (final ContactAlreadyAddedException ex) {
// Already added
this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
break;
case '2': // Change own data
- this.getContactManager().doChangeOwnData();
+ manager.doChangeOwnData();
break;
case '3': // Add new addess
- this.getContactManager().doAddOtherAddress();
+ manager.doAddOtherAddress();
break;
case '4': // List contacts
- this.getContactManager().doListContacts();
+ manager.doListContacts();
break;
case '5': // Search addresses
- this.getContactManager().doSearchContacts();
+ manager.doSearchContacts();
break;
case '6': // Change other addess
- this.getContactManager().doChangeOtherAddress();
+ manager.doChangeOtherAddress();
break;
case '7': // Delete other address
- this.getContactManager().doDeleteOtherAddress();
+ manager.doDeleteOtherAddress();
break;
case '0': // Program exit
this.outputMessage("Copyright(c) 2015 by Roland Haeder, this is free software");
// Debug message
- this.getLogger().debug("Intro shown to user");
+ this.getLogger().debug("Intro shown to user"); //NOI18N
}
@Override
// Contact must not be null
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Ask the user for editing [name], [a]ddress or [other] data
char choice = this.enterChar(new char[] {'n', 'a', 'o', 'x'}, "Welchen Daten möchten Sie ändern? (n=Namensdaten, a=Anschriftsdaten, o=Andere, x=Zurück zur Hauptauswahl) ");
+ // Get manager and cast it
+ ManageableContact manager = (ManageableContact) this.getManager();
+
// @TODO Get rid of this ugly switch block, too
switch (choice) {
case 'n': // Name data
- this.getContactManager().doChangeNameData(contact);
+ manager.doChangeNameData(contact);
break;
case 'a': // Address data
- this.getContactManager().doChangeAddressData(contact);
+ manager.doChangeAddressData(contact);
break;
case 'o': // Other data
- this.getContactManager().doChangeOtherData(contact);
+ manager.doChangeOtherData(contact);
break;
case 'x': // Exit this menu
default:
// @TODO throw own exception
- throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice));
+ throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N
}
// Trace message
// Read line
String input = this.readString();
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("input={0}", input)); //NOI18N
+
// This must be only one character
if (input.length() != 1) {
// Return zero
// First read a string
String input = this.readString();
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("input={0}", input)); //NOI18N
+
// Init number with invalid value
int num = -1;
num = Integer.parseInt(input);
} catch (final NumberFormatException e) {
this.outputMessage("Bitte geben Sie nur Zahlen ein!");
- this.getLogger().warn(MessageFormat.format("No numbers-only entered. input={0},message={1}", input, e.getMessage()));
+ this.getLogger().warn(MessageFormat.format("No numbers-only entered. input={0},message={1}", input, e.getMessage())); //NOI18N
}
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("num={0} - EXIT!", num)); //NOI18N
+
// Return read number
return num;
}
/**
* Fills menu map with menu entries
*/
- @Override
protected final void fillMenuMap () {
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
// Initialize first (main) menu
- Menu menu = new ConsoleMenu("main", this);
+ Menu menu = new ConsoleMenu("main", this); //NOI18N
// Add it
- this.getMenus().put("main", menu);
+ this.getMenus().put("main", menu); //NOI18N
// Trace message
this.getLogger().trace("EXIT!"); //NOI18N
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.table.TableModel;
-import org.mxchange.addressbook.BaseFrameworkSystem;
+import org.mxchange.addressbook.BaseAddressbookSystem;
import org.mxchange.addressbook.application.AddressbookApplication;
-import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
+import org.mxchange.addressbook.manager.contact.ManageableContact;
import org.mxchange.addressbook.model.contact.ContactTableModel;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
/**
*
* @author Roland Haeder
*/
-public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame {
+public class AddressbookFrame extends BaseAddressbookSystem implements ClientFrame {
/**
* Own instance
// Debug line
this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
+ // Get and cast manager instance
+ ManageableContact manager = (ManageableContact) this.getClient().getManager();
+
// Has the user entered own data?
- if (this.getClient().getContactManager().isOwnContactAdded()) {
+ if (manager.isOwnContactAdded()) {
// Debug message
this.getLogger().debug("Disabling menus: isOwnContactAdded()=false"); //NOI18N
@Override
public void actionPerformed (final ActionEvent e) {
try {
- self.getClient().getContactManager().doEnterOwnData();
+ ManageableContact manager = (ManageableContact) self.getClient().getManager();
+ manager.doEnterOwnData();
} catch (final ContactAlreadyAddedException ex) {
// Already added, log away
// @TODO maybe output message here?
*/
@Override
public void actionPerformed (final ActionEvent e) {
- self.getClient().getContactManager().doChangeOwnData();
+ ManageableContact manager = (ManageableContact) self.getClient().getManager();
+ manager.doChangeOwnData();
}
});
*/
@Override
public void actionPerformed (final ActionEvent e) {
- self.getClient().getContactManager().doAddOtherAddress();
+ ManageableContact manager = (ManageableContact) self.getClient().getManager();
+ manager.doAddOtherAddress();
}
});
/**
* Class for "add address" button
*/
- private static class AddActionListener extends BaseFrameworkSystem implements ActionListener {
+ private static class AddActionListener extends BaseAddressbookSystem implements ActionListener {
/**
* Dialog instance
*/
/**
* Class for "cancel address" button
*/
- private static class CancelActionListener extends BaseFrameworkSystem implements ActionListener {
+ private static class CancelActionListener extends BaseAddressbookSystem implements ActionListener {
/**
* Dialog instance
*/
*/
package org.mxchange.addressbook.client.gui;
-import org.mxchange.addressbook.FrameworkInterface;
-import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.contact.Contact;
-import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
+import org.mxchange.jcore.FrameworkInterface;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
/**
* An interface for applications with a frame
*/
package org.mxchange.addressbook.client.gui;
-import org.mxchange.addressbook.application.Application;
-import org.mxchange.addressbook.client.BaseClient;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.addressbook.client.BaseAddressbookClient;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
-import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
-import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
import org.mxchange.addressbook.menu.Menu;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.application.Application;
+import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
/**
*
* @author Roland Haeder
*/
-public class SwingClient extends BaseClient implements Client {
+public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
/**
* Swing frame instance
import java.text.MessageFormat;
import java.util.Objects;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.client.AddressbookClient;
+import org.mxchange.jcore.client.Client;
/**
* A general contact
* @author Roland Haeder
* @version 0.0
*/
-public class BaseContact extends BaseFrameworkSystem {
+public class BaseContact extends BaseAddressbookSystem {
/**
* Birth day
* "Serializes" this object into a CSV string (this time with semicolons)
*
* @return "CSV-serialized" version of the stored data
+ * @deprecated Don't use this anymore
*/
+ @Deprecated
public String getCsvStringFromStoreableObject () {
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
protected final void setZipCode (final long zipCode) {
this.zipCode = zipCode;
}
-
+
@Override
public int hashCode () {
// Validate gender instance
throw new NullPointerException("client is null");
}
+ // Cast client
+ AddressbookClient c = (AddressbookClient) client;
+
// Display name "box"
- client.displayNameBox((Contact) this);
+ c.displayNameBox((Contact) this);
// Display address "box"
- client.displayAddressBox((Contact) this);
+ c.displayAddressBox((Contact) this);
// Display other data "box"
- client.displayOtherDataBox((Contact) this);
+ c.displayOtherDataBox((Contact) this);
}
/**
this.birthday = birthday;
}
- /**
- * Checks if given boolean field is available and set to same value
- *
- * @param columnName Column name to check
- * @param bool Boolean value
- * @return Whether all conditions are met
- */
- @Override
- public boolean isValueEqual (final String columnName, final boolean bool) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("columnName={0},bool={1} - CALLED!", columnName, bool));
-
- // Convert column name to field name
- String methodName = this.convertColumnNameToGetterMethod(columnName, true);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("field={0}", methodName));
-
- // Init class instance
- boolean value = this.getBooleanField(this, "BaseContact", methodName);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("value={0}", value));
-
- // Compare it
- boolean isFound = (bool == value);
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound));
-
- // Return result
- return isFound;
- }
-
/**
* Some "getter for a value from given column name. This name will be
* translated into a method name and then this method is called.
public Object getValueFromColumn (final String columnName) {
// Trace message
this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName));
-
+
// Determine if the given column is boolean
if (this.isBooleanField(this, "BaseContact", columnName)) {
// Yes, then call other method
return this.getBooleanField(this, "BaseContact", columnName);
}
-
+
// Convert column name to field name
String methodName = this.convertColumnNameToGetterMethod(columnName, false);
-
+
// Debug message
this.getLogger().debug(MessageFormat.format("field={0}", methodName));
-
+
// Get field
Object value = this.getField(this, "BaseContact", methodName);
-
+
// Trace message
this.getLogger().trace("value=" + value + " - EXIT!");
-
+
// Return it
return value;
}
+
+ /**
+ * Checks if given boolean field is available and set to same value
+ *
+ * @param columnName Column name to check
+ * @param bool Boolean value
+ * @return Whether all conditions are met
+ */
+ @Override
+ public boolean isValueEqual (final String columnName, final boolean bool) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("columnName={0},bool={1} - CALLED!", columnName, bool));
+
+ // Convert column name to field name
+ String methodName = this.convertColumnNameToGetterMethod(columnName, true);
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("field={0}", methodName));
+
+ // Init class instance
+ boolean value = this.getBooleanField(this, "BaseContact", methodName);
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("value={0}", value));
+
+ // Compare it
+ boolean isFound = (bool == value);
+
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound));
+
+ // Return result
+ return isFound;
+ }
}
*/
package org.mxchange.addressbook.contact;
-import org.mxchange.addressbook.FrameworkInterface;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.jcore.FrameworkInterface;
+import org.mxchange.jcore.client.Client;
/**
*
import org.mxchange.addressbook.contact.BaseContact;
import org.mxchange.addressbook.contact.Contact;
-import org.mxchange.addressbook.database.storage.csv.StoreableCsv;
+import org.mxchange.jcore.database.storage.csv.StoreableCsv;
/**
* A contact that can be placed into "contact books"
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.contact.book.BookContact;
-import org.mxchange.addressbook.database.storage.csv.StoreableCsv;
+import org.mxchange.jcore.database.storage.csv.StoreableCsv;
/**
*
+++ /dev/null
-/*
- * 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.database.backend;
-
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.text.MessageFormat;
-import java.util.Enumeration;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.exceptions.UnsupportedDatabaseDriverException;
-
-/**
- * Generall database backend
- *
- * @author Roland Haeder
- */
-public class BaseDatabaseBackend extends BaseFrameworkSystem {
-
- /**
- * No instances from this class
- */
- protected BaseDatabaseBackend () {
- }
-
- /**
- * Validates driver name and throws an exception if the driver is not valid
- *
- * @param driverName Driver name (e.g. "mysql")
- * @throws org.mxchange.addressbook.exceptions.UnsupportedDatabaseDriverException If the given driver name cannot be solved into a driver instance
- */
- protected void validateDriver (final String driverName) throws UnsupportedDatabaseDriverException {
- // Trace message
- this.getLogger().trace(MessageFormat.format("driverName={0} - CALLED!", driverName)); //NOI18N
-
- // Try to find the driver in driver list
- Enumeration<Driver> drivers = DriverManager.getDrivers();
-
- // Default is not found
- boolean isFound = false;
-
- // Search for it
- while (drivers.hasMoreElements()) {
- // Get element
- Driver driver = drivers.nextElement();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Driver {0} is installed.", driver)); //NOI18N
-
- // Get class name
- String className = driver.getClass().getName();
-
- // Is this wanted?
- if (className.contains(driverName)) {
- // Debug message
- this.getLogger().debug("Found driver!"); //NOI18N
-
- // Found it
- isFound = true;
- break;
- }
- }
-
- // Is it found?
- if (!isFound) {
- // Throw exception
- throw new UnsupportedDatabaseDriverException(driverName);
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * 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.database.backend;
-
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.Iterator;
-import org.mxchange.addressbook.FrameworkInterface;
-import org.mxchange.addressbook.database.storage.Storeable;
-import org.mxchange.addressbook.exceptions.BadTokenException;
-
-/**
- * A generic interface for database frontends
- *
- * @author Roland Haeder
- */
-public interface DatabaseBackend extends FrameworkInterface {
-
- /**
- * Tries a connection to the database
- *
- * @throws java.sql.SQLException If the connection attempt fails
- */
- public void connectToDatabase () throws SQLException;
-
- /**
- * Shuts down this backend
- */
- public void doShutdown ();
-
- /**
- * Some "getter" for row index from given boolean row value
- *
- * @param columnName Name of column
- * @param bool Boolean value to look for
- * @return Row index
- */
- public int getRowIndexFromColumn (final String columnName, final boolean bool);
-
- /**
- * Some "getter" for total table row count
- *
- * @return Total row count
- * @throws java.sql.SQLException If an SQL error occurs
- */
- public int getTotalCount () throws SQLException;
-
- /**
- * Checks whether at least one row is found with given boolean value.
- *
- * @param columnName Column to check for boolean value
- * @param bool Boolean value to check
- * @return Whether boolean value is found and returns at least one row
- * @throws java.sql.SQLException If an SQL error occurs
- */
- public boolean isRowFound (final String columnName, final boolean bool) throws SQLException;
-
- /**
- * Rewinds backend
- */
- public void rewind ();
-
- /**
- * Get length of underlaying file
- *
- * @return Length of underlaying file
- */
- public long length ();
-
- /**
- * Stores an object in the database.
- *
- * @param object Object to store in database
- * @throws java.io.IOException From inner class
- */
- public void store (final Storeable object) throws IOException;
-
- /**
- * Gets an iterator for contacts
- *
- * @return Iterator for contacts
- * @throws org.mxchange.addressbook.exceptions.BadTokenException If the CSV token is badly formulated
- */
- public Iterator<? extends Storeable> iterator () throws BadTokenException;
-
- /**
- * Reads a single row from database.
- *
- * @param rowIndex Row index (or how much to skip)
- * @return A Storeable instance
- * @throws org.mxchange.addressbook.exceptions.BadTokenException If a token was badly formatted
- */
- public Storeable readRow (final int rowIndex) throws BadTokenException;
-}
+++ /dev/null
-/*
- * 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.database.backend.csv;
-
-import java.io.DataOutput;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.Iterator;
-import java.util.List;
-import org.mxchange.addressbook.FrameworkInterface;
-import org.mxchange.addressbook.contact.Contact;
-import org.mxchange.addressbook.database.backend.BaseDatabaseBackend;
-import org.mxchange.addressbook.database.backend.DatabaseBackend;
-import org.mxchange.addressbook.database.frontend.DatabaseFrontend;
-import org.mxchange.addressbook.database.storage.Storeable;
-import org.mxchange.addressbook.database.storage.csv.StoreableCsv;
-import org.mxchange.addressbook.exceptions.BadTokenException;
-
-/**
- * A database backend with CSV file as storage implementation
- *
- * @author Roland Haeder
- */
-public class Base64CsvDatabaseBackend extends BaseDatabaseBackend implements DatabaseBackend {
-
- /**
- * Output stream for this storage engine
- */
- private RandomAccessFile storageFile;
-
- /**
- * Constructor with table name
- *
- * @param tableName Name of "table"
- * @param wrapper Wrapper instance to call back
- */
- public Base64CsvDatabaseBackend (final String tableName, final DatabaseFrontend wrapper) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("tableName={0},wrapper={1}", tableName, wrapper)); //NOI18N
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Trying to initialize table {0} ...", tableName)); //NOI18N
-
- // Set table name here, too
- this.setTableName(tableName);
-
- // Set wrapper here
- this.setWrapper(wrapper);
-
- // Construct file name
- String fileName = String.format("data/table_%s.b64", tableName); //NOI18N
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Trying to open file {0} ...", fileName)); //NOI18N
-
- try {
- // Try to initialize the storage (file instance)
- this.storageFile = new RandomAccessFile(fileName, "rw"); //NOI18N
- } catch (final FileNotFoundException ex) {
- // Did not work
- this.getLogger().error(MessageFormat.format("File {0} cannot be opened: {1}", fileName, ex.toString())); //NOI18N
- System.exit(1);
- }
-
- // Output message
- this.getLogger().debug(MessageFormat.format("Database for {0} has been initialized.", tableName)); //NOI18N
- }
-
- /**
- * This database backend does not need to connect
- */
- @Override
- public void connectToDatabase () throws SQLException {
- // Empty body
- }
-
- /**
- * Shuts down this backend
- */
- @Override
- public void doShutdown () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- try {
- // Close file
- this.getStorageFile().close();
- } catch (final IOException ex) {
- // Abort program
- this.abortProgramWithException(ex);
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Some "getter" for row index from given boolean row value
- *
- * @param columnName Name of column
- * @param bool Boolean value to look for
- * @return Row index
- */
- @Override
- public int getRowIndexFromColumn (final String columnName, final boolean bool) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("columnName={0},bool={1} - CALLED!", columnName, bool)); //NOI18N
-
- // Row indexes start with zero
- int rowIndex = 0;
-
- // First rewind
- this.rewind();
-
- // Try to find the proper row
- while (!this.isEndOfFile()) {
- // Read line
- String line = this.readLine();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("line={0}", line));
-
- // Callback the wrapper to handle parsing
- try {
- Storeable storeable = this.getWrapper().parseLineToStoreable(line);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("storeable={0}", storeable));
-
- // Is the value qual
- if (storeable.isValueEqual(columnName, bool)) {
- // Debug message
- this.getLogger().debug(MessageFormat.format("Found storeable={0} for columnName={1} and bool={2}", storeable, columnName, bool));
-
- // Found it
- break;
- }
- } catch (final BadTokenException ex) {
- // Bad token found
- this.abortProgramWithException(ex);
- }
-
- // Count up
- rowIndex++;
- }
-
- // Return it
- return rowIndex;
- }
-
- /**
- * Some "getter" for total row count
- *
- * @return Total row count
- */
- @Override
- public int getTotalCount () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- try {
- // Do a deprecated call
- // @todo this needs rewrite!
- return this.readList().size();
- } catch (final BadTokenException ex) {
- this.abortProgramWithException(ex);
- }
-
- // Invalid return
- this.getLogger().trace("Returning -1 ... : EXIT!"); //NOI18N
- return -1;
- }
-
- /**
- * Checks whether at least one row is found with given boolean value.
- *
- * @param columnName Column to check for boolean value
- * @param bool Boolean value to check
- * @return Whether boolean value is found and returns at least one row
- */
- @Override
- public boolean isRowFound (final String columnName, final boolean bool) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("columnName={0},bool={1} - CALLED!", columnName, bool)); //NOI18N
-
- // Is at least one entry found?
- if (this.getTotalCount() == 0) {
- // No entry found at all
- return false;
- }
-
- // Default is not found
- boolean isFound = false;
-
- // Firsr rewind
- this.rewind();
-
- // Then loop through all lines
- while (!this.isEndOfFile()) {
- // Read line
- String line = this.readLine();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("line={0}", line));
-
- try {
- // And parse it to a Contact instance
- Contact contact = (Contact) this.getWrapper().parseLineToStoreable(line);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("contact={0}", contact));
-
- // This should not be null
- if (contact == null) {
- // Throw exception
- throw new NullPointerException("contact is null");
- }
-
- // Now let the contact object check if it has such attribute
- if (contact.isValueEqual(columnName, bool)) {
- // Yes, it is set
- isFound = true;
- break;
- }
- } catch (final BadTokenException ex) {
- // Don't continue with bad data
- this.abortProgramWithException(ex);
- }
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound));
-
- // Return result
- return isFound;
- }
-
- /**
- * Gets an iterator for contacts
- *
- * @return Iterator for contacts
- * @throws org.mxchange.addressbook.exceptions.BadTokenException If the
- * underlaying method has found an invalid token
- */
- @Override
- public Iterator<? extends Storeable> iterator () throws BadTokenException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- /*
- * Then read the file into RAM (yes, not perfect for >1000 entries ...)
- * and get a List back.
- */
- List<? extends Storeable> list = this.readList();
-
- // List must be set
- assert (list instanceof List) : "list has not been set."; //NOI18N
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("list.iterator()={0} - EXIT!", list.iterator())); //NOI18N
-
- // Get iterator from list and return it
- return list.iterator();
- }
-
- /**
- * Get length of underlaying file
- *
- * @return Length of underlaying file
- */
- @Override
- public long length () {
- long length = 0;
-
- try {
- length = this.getStorageFile().length();
- this.getLogger().debug(MessageFormat.format("length={0}", length)); //NOI18N
- } catch (final IOException ex) {
- // Length cannot be determined
- // Abort program
- this.abortProgramWithException(ex);
- }
-
- // Return result
- this.getLogger().trace(MessageFormat.format("length={0} : EXIT!", length)); //NOI18N
- return length;
- }
-
- /**
- * Reads a single row from database.
- *
- * @param rowIndex Row index (or how much to skip)
- * @return A Storeable instance
- * @throws org.mxchange.addressbook.exceptions.BadTokenException If a token
- * was badly formatted
- */
- @Override
- public Storeable readRow (final int rowIndex) throws BadTokenException {
- // First rewind
- this.rewind();
-
- // Intialize variables
- int count = -1;
- Storeable storeable = null;
-
- // Read all rows
- while (!this.isEndOfFile() || (count < rowIndex)) {
- // Read row
- String line = this.readLine();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("line={0}", line));
-
- // Callback the wrapper to handle parsing
- storeable = this.getWrapper().parseLineToStoreable(line);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("storeable={0}", storeable));
-
- // Increment counter
- count++;
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("storeable={0} - EXIT!", storeable));
- // Return found element
- return storeable;
- }
-
- /**
- * Rewinds backend
- */
- @Override
- public void rewind () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- try {
- // Rewind underlaying database file
- this.getStorageFile().seek(0);
- } catch (final IOException ex) {
- // Abort program
- this.abortProgramWithException(ex);
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Stores given object by "visiting" it
- *
- * @param object An object implementing Storeable
- * @throws java.io.IOException From "inner" class
- */
- @Override
- public void store (final Storeable object) throws IOException {
- // Trace message
- this.getLogger().trace(MessageFormat.format("object={0} - CALLED!", object)); //NOI18N
-
- // Object must not be null
- if (object == null) {
- // Abort here
- throw new NullPointerException("object is null"); //NOI18N
- }
-
- // Make sure the instance is there (DataOutput flawor)
- assert (this.storageFile instanceof DataOutput);
-
- // Try to cast it, this will fail if the interface is not implemented
- StoreableCsv csv = (StoreableCsv) object;
-
- // Now get a string from the object that needs to be stored
- String str = csv.getCsvStringFromStoreableObject();
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("str({0})={1}", str.length(), str)); //NOI18N
-
- // Encode line in BASE-64
- byte[] encoded = Base64.getEncoder().encode(str.getBytes());
-
- // The string is now a valid CSV string
- this.getStorageFile().write(encoded);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Adds given contact to list
- *
- * @param instance An instance of FrameworkInterface to add
- * @param list List instance
- */
- private void addToList (final Storeable instance, final List<Storeable> list) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", instance)); //NOI18N
-
- // No null here
- if (instance == null) {
- // Throw exception
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (list == null) {
- // Throw exception
- throw new NullPointerException("list is null"); //NOI18N
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("contact={0}", instance)); //NOI18N
-
- // Is the contact read?
- if (instance instanceof FrameworkInterface) {
- // Then add it
- boolean added = list.add(instance);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("contact={0} added={1}", instance, added)); //NOI18N
-
- // Has it been added?
- if (!added) {
- // Not added
- this.getLogger().warn("Contact object has not been added."); //NOI18N
- }
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Returns storage file
- *
- * @return Storage file instance
- */
- private RandomAccessFile getStorageFile () {
- return this.storageFile;
- }
-
- /**
- * Checks whether end of file has been reached
- *
- * @return Whether lines are left to read
- */
- private boolean isEndOfFile () {
- // Default is EOF
- boolean isEof = true;
-
- try {
- isEof = (this.getStorageFile().getFilePointer() >= this.length());
- } catch (final IOException ex) {
- // Length cannot be determined
- this.getLogger().catching(ex);
- }
-
- // Return status
- this.getLogger().trace(MessageFormat.format("isEof={0} : EXIT!", isEof)); //NOI18N
- return isEof;
- }
-
- /**
- * Reads a line from file base
- *
- * @return Read line from file
- */
- private String readLine () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Init input
- String input = null;
-
- try {
- // Read single line
- String base64 = this.getStorageFile().readLine();
-
- // Is the line null?
- if (base64 == null) {
- // Then throw NPE here
- throw new NullPointerException("base64 is null");
- }
-
- // Decode BASE-64
- byte[] decoded = Base64.getDecoder().decode(base64);
-
- // Convert to string
- input = new String(decoded);
- } catch (final IOException ex) {
- this.getLogger().catching(ex);
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
-
- // Return read string or null
- return input;
- }
-
- /**
- * Reads the database file, if available, and adds all read lines into the
- * list.
- *
- * @return A list with Contact instances
- */
- private List<? extends Storeable> readList () throws BadTokenException {
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // First rewind
- this.rewind();
-
- // Get file size and divide it by 140 (possible average length of one line)
- int lines = Math.round(this.length() / 140 + 0.5f);
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("lines={0}", lines)); //NOI18N
-
- // Instance list
- // @TODO The maximum length could be guessed from file size?
- List<Storeable> list = new ArrayList<>(lines);
-
- // Init variables
- String line;
- Storeable instance = null;
-
- // Read all lines
- while (!this.isEndOfFile()) {
- // Then read a line
- line = this.readLine();
-
- // Parse line
- instance = this.getWrapper().parseLineToStoreable(line);
-
- // The contact instance should be there now
- assert (instance instanceof FrameworkInterface) : MessageFormat.format("instance is not set: {0}", instance); //NOI18N
-
- // Add contact
- this.addToList(instance, list);
- }
-
- // Return finished list
- this.getLogger().trace(MessageFormat.format("list.size()={0} : EXIT!", list.size())); //NOI18N
- return list;
- }
-}
+++ /dev/null
-/*
- * 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.database.backend.mysql;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import org.mxchange.addressbook.database.backend.BaseDatabaseBackend;
-import org.mxchange.addressbook.database.backend.DatabaseBackend;
-import org.mxchange.addressbook.database.storage.Storeable;
-import org.mxchange.addressbook.exceptions.BadTokenException;
-import org.mxchange.addressbook.exceptions.UnsupportedDatabaseDriverException;
-
-/**
- * A backend class for MySQL connections
- *
- * @author Roland Haeder
- */
-public class MySqlDatabaseBackend extends BaseDatabaseBackend implements DatabaseBackend {
- /**
- * An instance of a datbase connection
- */
- private static Connection connection;
-
- /**
- * Prepared statement for full row count
- */
- private PreparedStatement totalRowCount;
-
- /**
- * Constructor with table name
- *
- * @param tableName Table to access
- * @throws org.mxchange.addressbook.exceptions.UnsupportedDatabaseDriverException
- */
- public MySqlDatabaseBackend (final String tableName) throws UnsupportedDatabaseDriverException {
- // Validate driver
- this.validateDriver("mysql"); //NOI18N
-
- // Now that the driver is there, set the table name
- this.setTableName(tableName);
- }
-
- @Override
- public void connectToDatabase () throws SQLException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Is the connection already there?
- if (MySqlDatabaseBackend.connection instanceof Connection) {
- // Already connected
- this.getLogger().debug("Connection is already established."); //NOI18N
-
- // No need to connect
- return;
- }
-
- // Generate connection string
- String connect = String.format("jdbc:mysql://%s/%s", //NOI18N
- this.getProperty("database.mysql.host"), //NOI18N
- this.getProperty("database.mysql.dbname") //NOI18N
- );
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Attempting to connect to {0} ...", connect)); //NOI18N
-
- // Now get a connection instance back
- MySqlDatabaseBackend.connection = DriverManager.getConnection(
- connect,
- this.getProperty("database.mysql.login"), //NOI18N
- this.getProperty("database.mysql.password") //NOI18N
- );
-
- // Is the connection really up?
- if (MySqlDatabaseBackend.connection.isClosed()) {
- // Connection is closed again
- throw new SQLException("Connection is closed."); //NOI18N
- }
-
- // Debug message
- this.getLogger().debug("Connection is up, preparing some statements ..."); //NOI18N
-
- // Here, the connection is established, so prepare some statements
- this.totalRowCount = MySqlDatabaseBackend.connection.prepareStatement(String.format("SELECT COUNT(`id`) AS `cnt` FROM `%s` LIMIT 1", this.getTableName())); //NOI18N
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- @Override
- public void doShutdown () {
- // This should not happen:
- assert(MySqlDatabaseBackend.connection instanceof Connection) : MessageFormat.format("connection is not valid: {0}", MySqlDatabaseBackend.connection); //NOI18N
-
- try {
- // Close down database connection
- MySqlDatabaseBackend.connection.close();
- } catch (final SQLException ex) {
- // Something happened during close()
- this.abortProgramWithException(ex);
- }
- }
-
- /**
- * Some "getter" for row index from given boolean row value
- *
- * @param columnName Name of column
- * @param bool Boolean value to look for
- * @return Row index
- */
- @Override
- public int getRowIndexFromColumn (final String columnName, final boolean bool) {
- throw new UnsupportedOperationException(MessageFormat.format("columnName={0},bool={1}", columnName, bool));
- }
-
- @Override
- public int getTotalCount () throws SQLException {
- // Trace message
- this.getLogger().trace(MessageFormat.format("tableName={0} - CALLED!", this.getTableName())); //NOI18N
-
- // Nothing counted by default
- int count = 0;
-
- // Prepared statements are cool ...
- if (this.totalRowCount.execute()) {
- // Did fully work, so get result set
- ResultSet set = this.totalRowCount.getResultSet();
-
- // First rewind it
- assert(set.last()) : ": last() failed"; //NOI18N
-
- // Get integer from 'cnt' alias (see statement)
- count = set.getInt("cnt"); //NOI18N
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("count={0}", count)); //NOI18N
-
- // Go back to beginning
- set.beforeFirst();
- } else {
- // Empty result
- this.getLogger().warn(MessageFormat.format("COUNT() query didn't return any result on table {0}.", this.getTableName())); //NOI18N
- }
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("count={0} - EXIT!", count)); //NOI18N
-
- // Return result
- return count;
- }
-
- /**
- * Checks whether at least one row is found with given boolean value.
- *
- * @param columnName Column to check for boolean value
- * @param bool Boolean value to check
- * @return Whether boolean value is found and returns at least one row
- */
- @Override
- public boolean isRowFound (final String columnName, final boolean bool) throws SQLException {
- // Is at least one entry found?
- if (this.getTotalCount() == 0) {
- // No entry found at all
- return false;
- }
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public Iterator<? extends Storeable> iterator () throws BadTokenException {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public long length () {
- throw new UnsupportedOperationException("Not implemented for this backend."); //NOI18N
- }
-
- @Override
- public Storeable readRow (final int rowIndex) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void rewind () {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void store (final Storeable object) throws IOException {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-}
+++ /dev/null
-/*
- * 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.database.frontend;
-
-import java.sql.SQLException;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.database.backend.DatabaseBackend;
-import org.mxchange.addressbook.database.backend.csv.Base64CsvDatabaseBackend;
-import org.mxchange.addressbook.database.backend.mysql.MySqlDatabaseBackend;
-import org.mxchange.addressbook.exceptions.UnsupportedDatabaseBackendException;
-import org.mxchange.addressbook.exceptions.UnsupportedDatabaseDriverException;
-
-/**
- * General database frontend class
- *
- * @author Roland Haeder
- */
-public abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implements DatabaseFrontend {
-
- /**
- * Instance for database backend
- */
- private DatabaseBackend backend;
-
- /**
- * No instances from this class
- */
- protected BaseDatabaseFrontend () {
- }
-
- /**
- * Instance for database backend
- *
- * @return the backend
- */
- protected final DatabaseBackend getBackend () {
- return this.backend;
- }
-
- /**
- * Instance for database backend
- *
- * @param backend the backend to set
- */
- protected final void setBackend (final DatabaseBackend backend) {
- this.backend = backend;
- }
-
- /**
- * Initialize backend
- *
- * @throws org.mxchange.addressbook.exceptions.UnsupportedDatabaseBackendException If the backend is not supported
- * @throws java.sql.SQLException If a SQL database backend fails to connect
- */
- protected void initBackend () throws UnsupportedDatabaseBackendException, SQLException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Read property
- // @TODO rewrite this to own properties file
- String backendType = this.getProperty("database.backendType"); //NOI18N
-
- // Try it
- try {
- // Switch on backend type
- switch (backendType) {
- case "mysql": // MySQL backend, this requires more information //NOI18N
- this.backend = new MySqlDatabaseBackend(this.getTableName());
- break;
-
- case "base64csv": // BASE64-encoded CSV rows //NOI18N
- this.backend = new Base64CsvDatabaseBackend(this.getTableName(), this);
- break;
-
- default: // Unsupported
- throw new UnsupportedDatabaseBackendException(backendType);
- }
-
- // Try to run a connect on it
- this.backend.connectToDatabase();
- } catch (final UnsupportedDatabaseDriverException ex) {
- // Continue to throw
- throw new UnsupportedDatabaseBackendException(backendType, ex);
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * 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.database.frontend;
-
-import org.mxchange.addressbook.FrameworkInterface;
-import org.mxchange.addressbook.database.storage.Storeable;
-import org.mxchange.addressbook.exceptions.BadTokenException;
-
-/**
- * A generic interface for database frontends
- *
- * @author Roland Haeder
- */
-public interface DatabaseFrontend extends FrameworkInterface {
- /**
- * 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
- * @throws org.mxchange.addressbook.exceptions.BadTokenException If a token was badly formatted
- */
- public Storeable parseLineToStoreable (final String line) throws BadTokenException;
-}
import org.mxchange.addressbook.contact.book.BookContact;
import org.mxchange.addressbook.contact.user.UserContact;
import org.mxchange.addressbook.database.contact.ContactDatabaseConstants;
-import org.mxchange.addressbook.database.frontend.BaseDatabaseFrontend;
-import org.mxchange.addressbook.database.storage.Storeable;
-import org.mxchange.addressbook.exceptions.BadTokenException;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.addressbook.exceptions.UnsupportedDatabaseBackendException;
import org.mxchange.addressbook.manager.contact.ContactManager;
+import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend;
+import org.mxchange.jcore.database.storage.Storeable;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
/**
* Stores and retrieves Contact instances
import java.sql.SQLException;
import org.mxchange.addressbook.contact.Contact;
-import org.mxchange.addressbook.database.frontend.DatabaseFrontend;
-import org.mxchange.addressbook.exceptions.BadTokenException;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcore.database.frontend.DatabaseFrontend;
+import org.mxchange.jcore.exceptions.BadTokenException;
/**
*
*
* @param contact Contact instance to check
* @return Whether the given Contact instance is found
- * @throws org.mxchange.addressbook.exceptions.BadTokenException Continued throw
+ * @throws org.mxchange.jcore.exceptions.BadTokenException Continued throw
*/
public boolean isContactFound (final Contact contact) throws BadTokenException;
+++ /dev/null
-/*
- * 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.database.storage;
-
-import org.mxchange.addressbook.FrameworkInterface;
-
-/**
- * An interface for objects being stored in databases
- *
- * @author Roland Haeder
- */
-public interface Storeable extends FrameworkInterface {
-}
+++ /dev/null
-/*
- * 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.database.storage.csv;
-
-import org.mxchange.addressbook.database.storage.Storeable;
-
-/**
- * An interface for classes which should be storeable as a CSV string
- *
- * @author Roland Haeder
- * @deprecated This method was for an old way of storing data into
- * comma-separated value files. Now that there is BASE64-encoding, this formating
- * is no longer needed.
- */
-@Deprecated
-public interface StoreableCsv extends Storeable {
-
- /**
- * Getter for a CSV-formated string from object
- *
- * @return
- * @deprecated See interface deprecation
- */
- @Deprecated
- public String getCsvStringFromStoreableObject ();
-}
+++ /dev/null
-/*
- * 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.exceptions;
-
-import java.text.MessageFormat;
-
-/**
- * This exception is thrown when a token has been badly formated. This may
- * happen when a CSV file is broken.
- *
- * @author Roland Haeder
- */
-public class BadTokenException extends Exception {
-
- /**
- * Constructor with token and count
- * @param token Token that is not valid
- * @param count Count
- */
- public BadTokenException (final String token, final int count) {
- super(MessageFormat.format("Token {0} at position {1} has not double-quotes on both ends.", token, count));
- }
-
-}
+++ /dev/null
-/*
- * 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.exceptions;
-
-/**
- * This exception is thrown when initFrame() is called twice.
- *
- * @author Roland Haeder
- */
-public class FrameAlreadyInitializedException extends Exception {
-
- /**
- * Default constructor
- */
- public FrameAlreadyInitializedException () {
- }
-
-}
+++ /dev/null
-/*
- * 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.exceptions;
-
-/**
- * This exception is thrown when the user made a valid choice but it was not
- * handled by the program.
- *
- * @author Roland Haeder
- */
-public class UnhandledUserChoiceException extends Exception {
-
- /**
- *
- * @param message
- */
- public UnhandledUserChoiceException (final String message) {
- super(message);
- }
-}
+++ /dev/null
-/*
- * 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.exceptions;
-
-import java.text.MessageFormat;
-
-/**
- * An exception thrown when the given backend type is not valid
- *
- * @author Roland Haeder
- */
-public class UnsupportedDatabaseBackendException extends Exception {
-
- /**
- *
- * @param backendType
- */
- public UnsupportedDatabaseBackendException (final String backendType) {
- // Call super constructor
- super(MessageFormat.format("Backend {0} is not supported.", backendType)); //NOI18N
- }
-
- /**
- * Constructor with backend type and cause
- *
- * @param backendType Backend type
- * @param cause
- */
- public UnsupportedDatabaseBackendException (final String backendType, final Throwable cause) {
- // Call super constructor
- super(MessageFormat.format("Backend {0} is not supported.", backendType), cause); //NOI18N
- }
-
-}
+++ /dev/null
-# 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/>.
-
-AddressbookFrame.border.name.title.text=Anrede, Vorname, Nachname:
-AddressbookFrame.border.address.title.text=Anschrift:
-AddressbookFrame.border.other.title.text=Andere Angaben:
-AddressbookFrame.button.addAddress.text=Adresse hinzuf\u00fcgen
-AddressbookFrame.button.cancel.text=Abbrechen
-AddressbookFrame.menu.file.text=Datei
-AddressbookFrame.menu.addressbook.text=Adressbuch
-AddressbookFrame.statusLabel.initializing.text=Initialisiere ...
-AddressbookFrame.statusLabel.done.text=Fertig.
-AddressbookFrame.statusLabel.shutdown.text=Shuttting down ...
-AddressbookFrame.menuItem.exitProgram.text=Programm beenden
-AddressbookFrame.menuItem.exitProgram.toolTipText=Beendet das Programm und speichert alle Einstellungen ab.
-AddressbookFrame.menuItem.addOwnData.text=Eigene Adresse hinzuf\u00fcgen
-AddressbookFrame.menuItem.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten.
-AddressbookFrame.menuItem.editOwnData.text=Eigene Adresse \u00e4ndern
-AddressbookFrame.menuItem.editOwnData.toolTipText=Erlaubt das \u00c4ndern eigener Daten.
-AddressbookFrame.menuItem.addNewContact.text=Neue Adresse hinzuf\u00fcgen
-AddressbookFrame.menuItem.addNewContact.toolTipText=Eine neue Adresse hinzuf\u00fcgen.
-AddressbookFrame.dialog.addContact.title.text=Neue Adresse hinzuf\u00fcgen
-AddressbookFrame.main.title.text=Adressen auflisten
-AddressbookFrame.gender.text=Anrede:
-AddressbookFrame.gender.toolTipText=W\u00e4hlen Sie die Anrede aus.
-AddressbookFrame.surname.text=Vorname:
-AddressbookFrame.surname.toolTipText=Geben Sie den Vornamen ein.
-AddressbookFrame.familyName.text=Nachname:
-AddressbookFrame.familyName.toolTipText=Geben Sie den Nachnamen ein.
-AddressbookFrame.street.text=Stra\u00dfe:
-AddressbookFrame.street.toolTipText=Geben Sie die Stra\u00dfe ein.
-AddressbookFrame.number.text=Hausnummer:
-AddressbookFrame.number.toolTipText=Geben Sie die Hausnummer ein.
-AddressbookFrame.zip.text=PLZ:
-AddressbookFrame.zip.toolTipText=Geben Sie die Postleitzahl ein.
-AddressbookFrame.city.text=Stadt:
-AddressbookFrame.city.toolTipText=Geben Sie die Stadt ein.
-AddressbookFrame.emailAddress.text=Email-Adresse:
-AddressbookFrame.emailAddress.toolTipText=Geben Sie die Email-Adresse ein.
-AddressbookFrame.phoneNumber.text=Telefon:
-AddressbookFrame.phoneNumber.toolTipText=Geben Sie die Telefonnummer ein.
-AddressbookFrame.cellphoneNumber.text=Mobil:
-AddressbookFrame.cellphoneNumber.toolTipText=Geben Sie die Handynummer ein.
-AddressbookFrame.faxNumber.text=Fax:
-AddressbookFrame.faxNumber.toolTipText=Geben Sie die Faxnummer ein.
-AddressbookFrame.comment.text=Anmerkungen:
-AddressbookFrame.comment.toolTipText=Geben Sie eine Anmerkung (Freifeld) ein.
-BaseContact.gender.unknown.text=Unbekannt
-BaseContact.gender.male.text=Herr
-BaseContact.gender.female.text=Frau
-BaseContact.gender.company.text=Firma
-ContactManager.columnName.gender.text=Anrede
-ContactManager.columnName.surname.text=Vorname
-ContactManager.columnName.familyName.text=Nachname
-ContactManager.columnName.street.text=Strasse
-ContactManager.columnName.houseNumber.text=Hausnummer
-ContactManager.columnName.zipCode.text=Postleitzahl
-ContactManager.columnName.city.text=Stadt
+++ /dev/null
-# 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/>.
-
-AddressbookFrame.border.name.title.text=Gender, surname, family name:
-AddressbookFrame.border.address.title.text=Address:
-AddressbookFrame.border.other.title.text=Other data:
-AddressbookFrame.button.addAddress.text=Add address
-AddressbookFrame.button.cancel.text=Cancel
-AddressbookFrame.menu.file.text=File
-AddressbookFrame.menu.addressbook.text=Addressbook
-AddressbookFrame.statusLabel.initializing.text=Initializing ...
-AddressbookFrame.statusLabel.done.text=Done.
-AddressbookFrame.statusLabel.shutdown.text=Shuttting down ...
-AddressbookFrame.menuItem.exitProgram.toolTipText=Exits the program and saves all data.
-AddressbookFrame.menuItem.exitProgram.text=Exit program
-AddressbookFrame.menuItem.addOwnData.text=Add own address
-AddressbookFrame.menuItem.addOwnData.toolTipText=Allows the user to add own address data
-AddressbookFrame.menuItem.editOwnData.text=Edit own data
-AddressbookFrame.menuItem.editOwnData.toolTipText=Allows the user to edit own address data
-AddressbookFrame.menuItem.addNewContact.text=Add new address
-AddressbookFrame.menuItem.addNewContact.toolTipText=Add a new address.
-AddressbookFrame.dialog.addContact.title.text=Add new address
-AddressbookFrame.main.title.text=List addresses
-AddressbookFrame.gender.text=Gender:
-AddressbookFrame.gender.toolTipText=Choose gender.
-AddressbookFrame.surname.text=Surname:
-AddressbookFrame.surname.toolTipText=Enter surname.
-AddressbookFrame.familyName.text=Family name:
-AddressbookFrame.familyName.toolTipText=Enter family name.
-AddressbookFrame.street.text=Street:
-AddressbookFrame.street.toolTipText=Enter street.
-AddressbookFrame.number.text=Number:
-AddressbookFrame.number.toolTipText=Enter number.
-AddressbookFrame.zip.text=ZIP:
-AddressbookFrame.zip.toolTipText=Enter zip code.
-AddressbookFrame.city.text=City:
-AddressbookFrame.city.toolTipText=Enter city.
-AddressbookFrame.emailAddress.text=Email address:
-AddressbookFrame.emailAddress.toolTipText=Enter email address.
-AddressbookFrame.phoneNumber.text=Phone:
-AddressbookFrame.phoneNumber.toolTipText=Enter phone number.
-AddressbookFrame.cellphoneNumber.text=Mobile:
-AddressbookFrame.cellphoneNumber.toolTipText=Enter mobile number.
-AddressbookFrame.faxNumber.text=Fax:
-AddressbookFrame.faxNumber.toolTipText=Enter fax number.
-AddressbookFrame.comment.text=Note:
-AddressbookFrame.comment.toolTipText=Enter a note (free field).
-BaseContact.gender.unknown.text=Unknown
-BaseContact.gender.male.text=Mr.
-BaseContact.gender.female.text=Mrs.
-BaseContact.gender.company.text=Company
-ContactManager.columnName.gender.text=Gender
-ContactManager.columnName.surname.text=Surname
-ContactManager.columnName.familyName.text=Family name
-ContactManager.columnName.street.text=Street
-ContactManager.columnName.houseNumber.text=House number
-ContactManager.columnName.zipCode.text=ZIP code
-ContactManager.columnName.city.text=City
+++ /dev/null
-/*
- * 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;
-
-import org.mxchange.addressbook.BaseFrameworkSystem;
-
-/**
- * A general manager
- *
- * @author Roland Haeder
- * @version 0.0
- */
-public class BaseManager extends BaseFrameworkSystem implements Manageable {
-
- /**
- * No instances can be created of this class
- */
- protected BaseManager () {
- }
-}
+++ /dev/null
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.manager;\r
-\r
-import org.mxchange.addressbook.FrameworkInterface;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public interface Manageable extends FrameworkInterface {\r
-}\r
+++ /dev/null
-/*
- * 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.application;
-
-import org.mxchange.addressbook.application.Application;
-import org.mxchange.addressbook.manager.BaseManager;
-
-/**
- *
- * @author Roland Haeder
- */
-public class ApplicationManager extends BaseManager implements ManageableApplication {
-
- /**
- * Getter for application manager
- *
- * @param application An instance of a Application class
- * @return
- */
- public static final ManageableApplication getManager (final Application application) {
- // Application instance must be set
- if (application == null) {
- // Abort here
- throw new NullPointerException("application is null"); //NOI18N
- }
-
- // Get manager
- ManageableApplication manager = new ApplicationManager(application);
-
- // Return manager
- return manager;
- }
-
- /**
- * Constructor for this manager
- *
- * @param application An instance of an Application class
- */
- private ApplicationManager (final Application application) {
- // Application instance must be set
- if (application == null) {
- // Abort here
- throw new NullPointerException("application is null"); //NOI18N
- }
-
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Set application instance
- this.setApplication(application);
- }
-
- @Override
- public void start () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Bootstrap application
- this.getApplication().doBootstrap();
-
- // Run the main loop
- this.getApplication().doMainLoop();
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * 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.application;
-
-import org.mxchange.addressbook.manager.Manageable;
-
-/**
- *
- * @author Roland Haeder
- */
-public interface ManageableApplication extends Manageable {
-
- /**
- * Launches application
- */
- public void start ();
-}
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.database.frontend.contact.ContactDatabaseFrontend;
import org.mxchange.addressbook.database.frontend.contact.ContactFrontend;
-import org.mxchange.addressbook.exceptions.BadTokenException;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
-import org.mxchange.addressbook.manager.BaseManager;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.BadTokenException;
+import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
+import org.mxchange.jcore.manager.BaseManager;
/**
* A manager for contacts, please note that this implementation loads the whole
throw new NullPointerException("contact is null"); //NOI18N
}
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
// First display it again
- this.getClient().displayAddressBox(contact);
+ client.displayAddressBox(contact);
// Is it own data?
if (contact.isOwnContact()) {
// Deligate to client
- this.getClient().doChangeOwnAddressData(contact);
+ client.doChangeOwnAddressData(contact);
} else {
// Other contact's address data to change
throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
throw new NullPointerException("contact is null"); //NOI18N
}
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
// First display them again
- this.getClient().displayNameBox(contact);
+ client.displayNameBox(contact);
// Is this own data?
if (contact.isOwnContact()) {
// Re-ask own data
- this.getClient().doChangeOwnNameData(contact);
+ client.doChangeOwnNameData(contact);
} else {
// Then re-ask them ...
throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
throw new NullPointerException("contact is null"); //NOI18N
}
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
// First display them again
- this.getClient().displayOtherDataBox(contact);
+ client.displayOtherDataBox(contact);
// Is this own data?
if (contact.isOwnContact()) {
// Re-ask own data
- this.getClient().doChangeOwnOtherData(contact);
+ client.doChangeOwnOtherData(contact);
} else {
// Then re-ask them ...
throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
// Display contact
contact.show(this.getClient());
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
try {
// Ask user what to change
- this.getClient().userChooseChangeContactData(contact);
+ client.userChooseChangeContactData(contact);
} catch (final UnhandledUserChoiceException ex) {
this.getLogger().catching(ex);
}
throw new ContactAlreadyAddedException();
}
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
// Deligate this call to the client
- Contact contact = this.getClient().doEnterOwnData();
+ Contact contact = client.doEnterOwnData();
// Is it set?
if (contact instanceof Contact) {
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();
+ // 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();
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
+ // 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): ");
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
}
/**
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- return this.getClient().enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
+ // Get and cast client instance
+ AddressbookClient client = (AddressbookClient) this.getClient();
+
+ return client.enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
}
@Override
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
-import org.mxchange.addressbook.manager.Manageable;
+import org.mxchange.jcore.manager.Manageable;
/**
*
* @author Roland Haeder
*/
public interface ManageableContact extends Manageable {
-
- /**
- * Shuts down this contact manager
- */
- public void doShutdown ();
-
/**
* Allows the user to enter own cellphone number.
*
import java.text.MessageFormat;
import java.util.List;
import org.apache.logging.log4j.Logger;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
/**
* Utility class for menu structure
*
* @author Roland Haeder
*/
-public class AddressbookMenu extends BaseFrameworkSystem {
+public class AddressbookMenu extends BaseAddressbookSystem {
/**
* Copies entries for given type into the menu list
} else if (client == null) {
// Abort here
throw new NullPointerException("contact is null"); //NOI18N
+ } else if (!(client instanceof AddressbookClient)) {
+ // Not correct instance
+ throw new IllegalArgumentException(MessageFormat.format("client{0} must implement AddressbookClient", client));
}
+ // Cast client to proper interface
+ AddressbookClient c = (AddressbookClient) client;
+
// Get list size
int size = menuList.size();
switch (menuType) {
case "main": // Main menu //NOI18N
// Enter own data
- menuList.add(client.getMenuItem('1', "Eigene Adresse anlegen"));
+ menuList.add(c.getMenuItem('1', "Eigene Adresse anlegen"));
// Change own data
- menuList.add(client.getMenuItem('2', "Eigene Adresse ändern"));
+ menuList.add(c.getMenuItem('2', "Eigene Adresse ändern"));
// Add new addess
- menuList.add(client.getMenuItem('3', "Neue Adresse hinzufügen"));
+ menuList.add(c.getMenuItem('3', "Neue Adresse hinzufügen"));
// List entries
- menuList.add(client.getMenuItem('4', "Adressbuch anzeigen"));
+ menuList.add(c.getMenuItem('4', "Adressbuch anzeigen"));
// Address search
- menuList.add(client.getMenuItem('5', "Adresse suchen"));
+ menuList.add(c.getMenuItem('5', "Adresse suchen"));
// Change other address
- menuList.add(client.getMenuItem('6', "Adresse ändern"));
+ menuList.add(c.getMenuItem('6', "Adresse ändern"));
// Delete other address
- menuList.add(client.getMenuItem('7', "Adresse löschen"));
+ menuList.add(c.getMenuItem('7', "Adresse löschen"));
// Always last line: Exit program
- menuList.add(client.getMenuItem('0', "Programm verlassen"));
+ menuList.add(c.getMenuItem('0', "Programm verlassen"));
break;
default: // Not supported
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.BaseAddressbookSystem;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
/**
*
* @author Roland Haeder
*/
-public class BaseMenu extends BaseFrameworkSystem {
+public class BaseMenu extends BaseAddressbookSystem {
/**
* Menu list
SelectableMenuItem item = iterator.next();
// Show this item
- item.show(client);
+ item.show((AddressbookClient) client);
}
// Trace message
package org.mxchange.addressbook.menu;
import java.util.Iterator;
-import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
/**
*
import java.util.Iterator;
import java.util.Map;
import org.apache.logging.log4j.Logger;
-import org.mxchange.addressbook.BaseFrameworkSystem;
+import org.mxchange.addressbook.BaseAddressbookSystem;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
/**
*
* @author Roland Haeder
*/
-public class MenuTools extends BaseFrameworkSystem {
+public class MenuTools extends BaseAddressbookSystem {
/**
* Gets an array with all available access keys back from given menu map.
package org.mxchange.addressbook.menu.console;
import java.text.MessageFormat;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.menu.AddressbookMenu;
import org.mxchange.addressbook.menu.BaseMenu;
import org.mxchange.addressbook.menu.Menu;
+import org.mxchange.jcore.client.Client;
/**
*
this.initMenu(menuType, client);
// Add all items
- AddressbookMenu.addItemsToList(this.getMenuList(), menuType, client);
+ AddressbookMenu.addItemsToList(this.getMenuList(), menuType, (AddressbookClient) client);
}
}
-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.menu.item;\r
-\r
-import org.mxchange.addressbook.BaseFrameworkSystem;\r
-\r
-/**\r
- *\r
- * @author Roland Haeder\r
- */\r
-public class BaseMenuItem extends BaseFrameworkSystem {\r
-\r
-}\r
+/*
+ * 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.menu.item;
+
+import org.mxchange.addressbook.BaseAddressbookSystem;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class BaseMenuItem extends BaseAddressbookSystem {
+
+}
*/
package org.mxchange.addressbook.menu.item;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.jcore.client.Client;
/**
*
package org.mxchange.addressbook.menu.item.console;
import java.text.MessageFormat;
-import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.client.AddressbookClient;
import org.mxchange.addressbook.menu.item.BaseMenuItem;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
+import org.mxchange.jcore.client.Client;
/**
*
return this.accessKey;
}
+ /**
+ * Access key
+ *
+ * @param accessKey the accessKey to set
+ */
+ private void setAccessKey (char accessKey) {
+ this.accessKey = accessKey;
+ }
+
/**
* Text to user
*
return this.text;
}
+ /**
+ * Text to user
+ *
+ * @param text the text to set
+ */
+ private void setText (String text) {
+ this.text = text;
+ }
+
@Override
public void show (final Client client) {
// Trace message
if (client == null) {
// Abort here
throw new NullPointerException("client is null");
+ } else if (!(client instanceof AddressbookClient)) {
+ // Wrong interface
+ throw new IllegalArgumentException("client " + client + " must implement AddressbookClient");
}
+ // Cast it
+ AddressbookClient c = (AddressbookClient) client;
+
// Call-back client over menu
- client.showEntry(this);
+ c.showEntry(this);
// Trace message
this.getLogger().trace("EXIT!"); //NOI18N
}
- /**
- * Text to user
- *
- * @param text the text to set
- */
- private void setText (String text) {
- this.text = text;
- }
-
- /**
- * Access key
- *
- * @param accessKey the accessKey to set
- */
- private void setAccessKey (char accessKey) {
- this.accessKey = accessKey;
- }
-
}
+++ /dev/null
-/*
- * 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.model;
-
-import java.text.MessageFormat;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.TableModelListener;
-import org.mxchange.addressbook.BaseFrameworkSystem;
-
-/**
- *
- * @author Roland Haeder
- */
-public class BaseModel extends BaseFrameworkSystem {
-
- /**
- * List of event listeners
- */
- private final EventListenerList eventListenerList;
-
- /**
- * Protected constructor
- */
- protected BaseModel () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Init listener list
- this.eventListenerList = new EventListenerList();
- }
-
- /**
- * Adds a lister of this type to the list
- *
- * @param listener Listener instance
- */
- public void addListDataListener (final ListDataListener listener) {
- // Trace message
- this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
-
- // Listener must not be null
- if (listener == null) {
- // Abort here
- throw new NullPointerException("listener is null");
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass()));
-
- // Remove listener
- this.eventListenerList.add(ListDataListener.class, listener);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Adds a TableModel listener instance to the event list.
- *
- * @param listener Lister instance
- */
- public void addTableModelListener (final TableModelListener listener) {
- // Trace message
- this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
-
- // Listener must not be null
- if (listener == null) {
- // Abort here
- throw new NullPointerException("listener is null");
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass()));
-
- // Add listener
- this.eventListenerList.add(TableModelListener.class, listener);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Removes given listener
- *
- * @param listener Listener instance
- */
- public void removeListDataListener (final ListDataListener listener) {
- // Trace message
- this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
-
- // Listener must not be null
- if (listener == null) {
- // Abort here
- throw new NullPointerException("listener is null");
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass()));
-
- // Remove listener
- this.eventListenerList.remove(ListDataListener.class, listener);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- /**
- * Removes a TableModel listener instance from the event list.
- *
- * @param listener Listener instance
- */
- public void removeTableModelListener (final TableModelListener listener) {
- // Trace message
- this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
-
- // Listener must not be null
- if (listener == null) {
- // Abort here
- throw new NullPointerException("listener is null");
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass()));
-
- // Remove listener
- this.eventListenerList.remove(TableModelListener.class, listener);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-}
import java.text.MessageFormat;
import javax.swing.table.TableModel;
-import org.mxchange.addressbook.client.Client;
-import org.mxchange.addressbook.model.BaseModel;
+import org.mxchange.addressbook.manager.contact.ManageableContact;
+import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.model.BaseModel;
/**
* A table model for contacts
@Override
public int getColumnCount () {
+ // Get manager
+ ManageableContact manager = (ManageableContact) this.getClient().getManager();
+
// Deligate this call to contact manager
- return this.getClient().getContactManager().getColumnCount();
+ return manager.getColumnCount();
}
@Override
public String getColumnName (final int columnIndex) {
+ // Get manager
+ ManageableContact manager = (ManageableContact) this.getClient().getManager();
+
// Deligate this call to contact manager
- return this.getClient().getContactManager().getTranslatedColumnName(columnIndex);
+ return manager.getTranslatedColumnName(columnIndex);
}
@Override
public int getRowCount () {
+ // Get manager
+ ManageableContact manager = (ManageableContact) this.getClient().getManager();
+
// Deligate this call to contact manager
- return this.getClient().getContactManager().size();
+ return manager.size();
}
@Override
public Object getValueAt (final int rowIndex, final int columnIndex) {
- // Let the manager do this job for us
- return this.getClient().getContactManager().getValueFromRowColumn(rowIndex, columnIndex);
+ // Get manager
+ ManageableContact manager = (ManageableContact) this.getClient().getManager();
+
+ // Deligate this call to contact manager
+ return manager.getValueFromRowColumn(rowIndex, columnIndex);
}
@Override
--- /dev/null
+# 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/>.
+
+AddressbookFrame.border.name.title.text=Anrede, Vorname, Nachname:
+AddressbookFrame.border.address.title.text=Anschrift:
+AddressbookFrame.border.other.title.text=Andere Angaben:
+AddressbookFrame.button.addAddress.text=Adresse hinzuf\u00fcgen
+AddressbookFrame.button.cancel.text=Abbrechen
+AddressbookFrame.menu.file.text=Datei
+AddressbookFrame.menu.addressbook.text=Adressbuch
+AddressbookFrame.statusLabel.initializing.text=Initialisiere ...
+AddressbookFrame.statusLabel.done.text=Fertig.
+AddressbookFrame.statusLabel.shutdown.text=Shuttting down ...
+AddressbookFrame.menuItem.exitProgram.text=Programm beenden
+AddressbookFrame.menuItem.exitProgram.toolTipText=Beendet das Programm und speichert alle Einstellungen ab.
+AddressbookFrame.menuItem.addOwnData.text=Eigene Adresse hinzuf\u00fcgen
+AddressbookFrame.menuItem.addOwnData.toolTipText=Erlaubt das Hinzuf\u00fcgen eigener Daten.
+AddressbookFrame.menuItem.editOwnData.text=Eigene Adresse \u00e4ndern
+AddressbookFrame.menuItem.editOwnData.toolTipText=Erlaubt das \u00c4ndern eigener Daten.
+AddressbookFrame.menuItem.addNewContact.text=Neue Adresse hinzuf\u00fcgen
+AddressbookFrame.menuItem.addNewContact.toolTipText=Eine neue Adresse hinzuf\u00fcgen.
+AddressbookFrame.dialog.addContact.title.text=Neue Adresse hinzuf\u00fcgen
+AddressbookFrame.main.title.text=Adressen auflisten
+AddressbookFrame.gender.text=Anrede:
+AddressbookFrame.gender.toolTipText=W\u00e4hlen Sie die Anrede aus.
+AddressbookFrame.surname.text=Vorname:
+AddressbookFrame.surname.toolTipText=Geben Sie den Vornamen ein.
+AddressbookFrame.familyName.text=Nachname:
+AddressbookFrame.familyName.toolTipText=Geben Sie den Nachnamen ein.
+AddressbookFrame.street.text=Stra\u00dfe:
+AddressbookFrame.street.toolTipText=Geben Sie die Stra\u00dfe ein.
+AddressbookFrame.number.text=Hausnummer:
+AddressbookFrame.number.toolTipText=Geben Sie die Hausnummer ein.
+AddressbookFrame.zip.text=PLZ:
+AddressbookFrame.zip.toolTipText=Geben Sie die Postleitzahl ein.
+AddressbookFrame.city.text=Stadt:
+AddressbookFrame.city.toolTipText=Geben Sie die Stadt ein.
+AddressbookFrame.emailAddress.text=Email-Adresse:
+AddressbookFrame.emailAddress.toolTipText=Geben Sie die Email-Adresse ein.
+AddressbookFrame.phoneNumber.text=Telefon:
+AddressbookFrame.phoneNumber.toolTipText=Geben Sie die Telefonnummer ein.
+AddressbookFrame.cellphoneNumber.text=Mobil:
+AddressbookFrame.cellphoneNumber.toolTipText=Geben Sie die Handynummer ein.
+AddressbookFrame.faxNumber.text=Fax:
+AddressbookFrame.faxNumber.toolTipText=Geben Sie die Faxnummer ein.
+AddressbookFrame.comment.text=Anmerkungen:
+AddressbookFrame.comment.toolTipText=Geben Sie eine Anmerkung (Freifeld) ein.
+BaseContact.gender.unknown.text=Unbekannt
+BaseContact.gender.male.text=Herr
+BaseContact.gender.female.text=Frau
+BaseContact.gender.company.text=Firma
+ContactManager.columnName.gender.text=Anrede
+ContactManager.columnName.surname.text=Vorname
+ContactManager.columnName.familyName.text=Nachname
+ContactManager.columnName.street.text=Strasse
+ContactManager.columnName.houseNumber.text=Hausnummer
+ContactManager.columnName.zipCode.text=Postleitzahl
+ContactManager.columnName.city.text=Stadt
--- /dev/null
+# 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/>.
+
+AddressbookFrame.border.name.title.text=Gender, surname, family name:
+AddressbookFrame.border.address.title.text=Address:
+AddressbookFrame.border.other.title.text=Other data:
+AddressbookFrame.button.addAddress.text=Add address
+AddressbookFrame.button.cancel.text=Cancel
+AddressbookFrame.menu.file.text=File
+AddressbookFrame.menu.addressbook.text=Addressbook
+AddressbookFrame.statusLabel.initializing.text=Initializing ...
+AddressbookFrame.statusLabel.done.text=Done.
+AddressbookFrame.statusLabel.shutdown.text=Shuttting down ...
+AddressbookFrame.menuItem.exitProgram.toolTipText=Exits the program and saves all data.
+AddressbookFrame.menuItem.exitProgram.text=Exit program
+AddressbookFrame.menuItem.addOwnData.text=Add own address
+AddressbookFrame.menuItem.addOwnData.toolTipText=Allows the user to add own address data
+AddressbookFrame.menuItem.editOwnData.text=Edit own data
+AddressbookFrame.menuItem.editOwnData.toolTipText=Allows the user to edit own address data
+AddressbookFrame.menuItem.addNewContact.text=Add new address
+AddressbookFrame.menuItem.addNewContact.toolTipText=Add a new address.
+AddressbookFrame.dialog.addContact.title.text=Add new address
+AddressbookFrame.main.title.text=List addresses
+AddressbookFrame.gender.text=Gender:
+AddressbookFrame.gender.toolTipText=Choose gender.
+AddressbookFrame.surname.text=Surname:
+AddressbookFrame.surname.toolTipText=Enter surname.
+AddressbookFrame.familyName.text=Family name:
+AddressbookFrame.familyName.toolTipText=Enter family name.
+AddressbookFrame.street.text=Street:
+AddressbookFrame.street.toolTipText=Enter street.
+AddressbookFrame.number.text=Number:
+AddressbookFrame.number.toolTipText=Enter number.
+AddressbookFrame.zip.text=ZIP:
+AddressbookFrame.zip.toolTipText=Enter zip code.
+AddressbookFrame.city.text=City:
+AddressbookFrame.city.toolTipText=Enter city.
+AddressbookFrame.emailAddress.text=Email address:
+AddressbookFrame.emailAddress.toolTipText=Enter email address.
+AddressbookFrame.phoneNumber.text=Phone:
+AddressbookFrame.phoneNumber.toolTipText=Enter phone number.
+AddressbookFrame.cellphoneNumber.text=Mobile:
+AddressbookFrame.cellphoneNumber.toolTipText=Enter mobile number.
+AddressbookFrame.faxNumber.text=Fax:
+AddressbookFrame.faxNumber.toolTipText=Enter fax number.
+AddressbookFrame.comment.text=Note:
+AddressbookFrame.comment.toolTipText=Enter a note (free field).
+BaseContact.gender.unknown.text=Unknown
+BaseContact.gender.male.text=Mr.
+BaseContact.gender.female.text=Mrs.
+BaseContact.gender.company.text=Company
+ContactManager.columnName.gender.text=Gender
+ContactManager.columnName.surname.text=Surname
+ContactManager.columnName.familyName.text=Family name
+ContactManager.columnName.street.text=Street
+ContactManager.columnName.houseNumber.text=House number
+ContactManager.columnName.zipCode.text=ZIP code
+ContactManager.columnName.city.text=City