]> git.mxchange.org Git - jfinancials-swing.git/blobdiff - src/org/mxchange/addressbook/client/console/ConsoleClient.java
Continued a bit:
[jfinancials-swing.git] / src / org / mxchange / addressbook / client / console / ConsoleClient.java
index d2c31ebba25a2aa73efedfc29883e5e46a41b515..8452a4aa3dbbc35cda2413438042a37ce2f296d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016 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
@@ -38,11 +38,15 @@ import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
 import org.mxchange.jcore.application.Application;
 import org.mxchange.jcore.exceptions.MenuInitializationException;
 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
 
 /**
  * A client for the console
  * <p>
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 public class ConsoleClient extends BaseAddressbookClient implements AddressbookClient {
 
@@ -58,7 +62,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
         */
        public ConsoleClient (final Application application) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
 
                // Set application instance
                this.setApplication(application);
@@ -67,13 +71,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.scanner = new Scanner(System.in, "UTF-8"); //NOI18N
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void displayAddressBox (final Contact contact) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -82,16 +86,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Simple display ...
-               this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getStreet(), contact.getZipCode(), contact.getCity(), contact.getCountryCode()));
+               this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getContactStreet(), contact.getContactZipCode(), contact.getContactCity(), contact.getContactCountry()));
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void displayNameBox (final Contact contact) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -103,16 +107,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String gender = GenderUtils.getTranslatedGender(contact);
 
                // Now put all together: gender, surname, family name
-               this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", gender, contact.getFirstName(), contact.getFamilyName()));
+               this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", gender, contact.getContactFirstName(), contact.getContactFamilyName()));
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void displayOtherDataBox (final Contact contact) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -121,16 +125,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Cellphone and such ...
-               this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getPhoneNumber(), contact.getFaxNumber(), contact.getCellphoneNumber(), contact.getComment()));
+               this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getContactLandLineNumber(), contact.getContactFaxNumber(), contact.getContactMobileNumber(), contact.getContactComment()));
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doChangeOwnAddressData (final Contact contact) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -157,22 +161,22 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String city = manager.enterOwnCity();
 
                // Get country code
-               String countryCode = manager.enterOwnCountryCode();
+               Country country = manager.enterOwnCountryCode();
 
                // Update address data
-               contact.setStreet(streetNumber);
-               contact.setZipCode(zipCode);
-               contact.setCity(city);
-               contact.setCountryCode(countryCode);
+               contact.setContactStreet(streetNumber);
+               contact.setContactZipCode(zipCode);
+               contact.setContactCity(city);
+               contact.setContactCountry(country);
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doChangeOwnNameData (final Contact contact) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -199,18 +203,18 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String familyName = manager.enterOwnFamilyName();
 
                // Update contact instance
-               contact.setGender(gender);
-               contact.setFirstName(firstName);
-               contact.setFamilyName(familyName);
+               contact.setContactGender(gender);
+               contact.setContactFirstName(firstName);
+               contact.setContactFamilyName(familyName);
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doChangeOwnOtherData (final Contact contact) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
 
                // Is it null?
                if (null == contact) {
@@ -228,13 +232,13 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                ContactFacade manager = (ContactFacade) this.getFacade();
 
                // Phone number
-               String phoneNumber = manager.enterOwnPhoneNumber();
+               DialableLandLineNumber phoneNumber = manager.enterOwnPhoneNumber();
 
                // Phone number
-               String cellphonePhoneNumber = manager.enterOwnCellNumber();
+               DialableMobileNumber cellphonePhoneNumber = manager.enterOwnCellNumber();
 
                // Fax number
-               String faxNumber = manager.enterOwnFaxNumber();
+               DialableFaxNumber faxNumber = manager.enterOwnFaxNumber();
 
                // Email address
                String email = manager.enterOwnEmailAddress();
@@ -243,20 +247,20 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String comment = manager.enterOwnComment();
 
                // Update contact instance
-               contact.setPhoneNumber(phoneNumber);
-               contact.setCellphoneNumber(cellphonePhoneNumber);
-               contact.setFaxNumber(faxNumber);
-               contact.setEmailAddress(email);
-               contact.setComment(comment);
+               contact.setContactLandLineNumber(phoneNumber);
+               contact.setContactCellphoneNumber(cellphonePhoneNumber);
+               contact.setContactFaxNumber(faxNumber);
+               contact.setContactEmailAddress(email);
+               contact.setContactComment(comment);
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public Contact doEnterOwnData () {
                // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
 
                // Get manager and cast it
                ContactFacade manager = (ContactFacade) this.getFacade();
@@ -274,7 +278,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                Contact contact = new UserContact(gender, firstName, familyName);
 
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
 
                // And return object
                return contact;
@@ -283,20 +287,20 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        public void doShutdown () throws SQLException, IOException {
                // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
 
                // Parent call
                super.doShutdown();
 
                // TODO Add other shutdown stuff
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
        public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException {
                // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
 
                // Get all access keys from menu
                char[] accessKeys = MenuTools.getAccessKeysFromMenuMap(this.getMenus(), this.getCurrentMenu());
@@ -358,13 +362,14 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
+       @SuppressWarnings ("UseOfSystemOutOrSystemErr")
        public char enterChar (final char[] validChars, final String message) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("validChars={0},message={1} - CALLED!", Arrays.toString(validChars), message)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("validChars={0},message={1} - CALLED!", Arrays.toString(validChars), message)); //NOI18N
 
                // The validChars must not null be null and filled with at least one char
                if (null == validChars) {
@@ -390,7 +395,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
 
                // Return read char
                return input;
@@ -399,13 +404,14 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        public Gender enterGender (final String message) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N
 
                // Get valid chars
                char[] validChars = Gender.validChars();
 
                // Debug message
                //* NOISY-DEBUG: */ System.out.println(validChars);
+
                // Call inner method
                char gender = this.enterChar(validChars, message);
 
@@ -416,16 +422,17 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                assert (g instanceof Gender) : "g is not set."; //NOI18N
 
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N
 
                // Return it
                return g;
        }
 
        @Override
+       @SuppressWarnings ("UseOfSystemOutOrSystemErr")
        public int enterInt (final int minimum, final int maximum, final String message) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N
 
                // Minimum should not be below zero
                assert (minimum >= 0) : MessageFormat.format("minimum={0} is below zero", minimum); //NOI18N
@@ -443,16 +450,17 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
 
                // Return it
                return input;
        }
 
        @Override
+       @SuppressWarnings ("UseOfSystemOutOrSystemErr")
        public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("minLength={0},maxLength={1},message={2}allowEmpty={3} - CALLED!", minLength, maxLength, message, allowEmpty)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("minLength={0},maxLength={1},message={2}allowEmpty={3} - CALLED!", minLength, maxLength, message, allowEmpty)); //NOI18N
 
                // Check on length, e.g. country codes are excactly 2 chars long
                assert (maxLength >= minLength);
@@ -470,7 +478,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
 
                // Return it
                return input;
@@ -485,7 +493,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        @Override
        public void init () {
                // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
 
                // Init contact manager here
                try {
@@ -499,10 +507,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.fillMenuMap();
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        @Override
+       @SuppressWarnings ("UseOfSystemOutOrSystemErr")
        public void outputMessage (final String message) {
                System.out.println(message);
        }
@@ -527,16 +536,16 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        public void showWelcome () {
                this.outputMessage(MessageFormat.format("Welcome to {0}", AddressbookApplication.printableTitle())); //NOI18N
                this.outputMessage(""); //NOI18N
-               this.outputMessage("Copyright(c) 2015 by Roland Haeder, this is free software"); //NOI18N
+               this.outputMessage("Copyright(c) 2016 by Roland Haeder, this is free software"); //NOI18N
 
                // Debug message
-               this.getLogger().logDebug("Intro shown to user"); //NOI18N
+               this.getLoggerBeanLocal().logDebug("Intro shown to user"); //NOI18N
        }
 
        @Override
        public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
 
                // Contact must not be null
                if (null == contact) {
@@ -545,7 +554,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // 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) ");
+               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
                ContactFacade manager = (ContactFacade) this.getFacade();
@@ -574,7 +583,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                }
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 
        /**
@@ -587,7 +596,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String input = this.readString();
 
                // Debug message
-               this.getLogger().logDebug(MessageFormat.format("input={0}", input)); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("input={0}", input)); //NOI18N
 
                // This must be only one character
                if (input.length() != 1) {
@@ -609,7 +618,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                String input = this.readString();
 
                // Debug message
-               this.getLogger().logDebug(MessageFormat.format("input={0}", input)); //NOI18N
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("input={0}", input)); //NOI18N
 
                // Init number with invalid value
                int num = -1;
@@ -619,11 +628,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                        num = Integer.parseInt(input);
                } catch (final NumberFormatException e) {
                        this.outputMessage("Bitte geben Sie nur Zahlen ein!");
-                       this.getLogger().logWarning(MessageFormat.format("No numbers-only entered. input={0},message={1}", input, e.getMessage())); //NOI18N
+                       this.getLoggerBeanLocal().logWarning(MessageFormat.format("No numbers-only entered. input={0},message={1}", input, e.getMessage())); //NOI18N
                }
 
                // Trace message
-               this.getLogger().logTrace(MessageFormat.format("num={0} - EXIT!", num)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("num={0} - EXIT!", num)); //NOI18N
 
                // Return read number
                return num;
@@ -639,9 +648,9 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
        }
 
        @Override
-       protected final void fillMenuMap () {
+       protected void fillMenuMap () {
                // Trace message
-               this.getLogger().logTrace("CALLED!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
 
                // Initialize first (main) menu
                Menu menu = new ConsoleMenu("main", this); //NOI18N
@@ -650,6 +659,6 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC
                this.getMenus().put("main", menu); //NOI18N
 
                // Trace message
-               this.getLogger().logTrace("EXIT!"); //NOI18N
+               this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
        }
 }