X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Forg%2Fmxchange%2Faddressbook%2Fclient%2Fconsole%2FConsoleClient.java;h=4fd9b35e2293146aa110eb1f741d4ad2300564ee;hb=de75d32b4097e17ee3c690172ca7c2dd0b8dcea0;hp=6f74ce211bff0fcd0f8f134addb45b81335874d9;hpb=30828ffb29ae2b24441d957e5646f5f83847e62c;p=addressbook-swing.git diff --git a/src/org/mxchange/addressbook/client/console/ConsoleClient.java b/src/org/mxchange/addressbook/client/console/ConsoleClient.java index 6f74ce2..4fd9b35 100644 --- a/src/org/mxchange/addressbook/client/console/ConsoleClient.java +++ b/src/org/mxchange/addressbook/client/console/ConsoleClient.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Roland Haeder + * Copyright (C) 2016, 2020 Free Software Foundation * * 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 @@ -32,21 +32,21 @@ import org.mxchange.addressbook.menu.item.SelectableMenuItem; import org.mxchange.addressbook.menu.item.console.ConsoleMenuItem; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; -import org.mxchange.jcontacts.contact.gender.Gender; -import org.mxchange.jcontacts.contact.gender.GenderUtils; -import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; +import org.mxchange.jcontacts.contact.title.PersonalTitle; +import org.mxchange.jcontacts.contact.title.PersonalTitleUtils; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataAlreadyAddedException; 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.cellphone.DialableCellphoneNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; /** * A client for the console *

- * @author Roland Haeder + * @author Roland Häder */ public class ConsoleClient extends BaseAddressbookClient implements AddressbookClient { @@ -103,11 +103,11 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC throw new NullPointerException("contact is null"); //NOI18N } - // Get translated gender as the user may want to see "Mr.", "Mrs." - String gender = GenderUtils.getTranslatedGender(contact); + // Get translated title as the user may want to see "Mr.", "Mrs." + String title = PersonalTitleUtils.getTranslatedPersonalTitle(contact); - // Now put all together: gender, surname, family name - this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", gender, contact.getContactFirstName(), contact.getContactFamilyName())); + // Now put all together: title, surname, family name + this.outputMessage(MessageFormat.format("Anrede, Vorname, Name: {0} {1} {2}", title, contact.getContactFirstName(), contact.getContactFamilyName())); // Trace message this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N @@ -124,8 +124,8 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC throw new NullPointerException("contact is null"); //NOI18N } - // Cellphone and such ... - this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getContactLandLineNumber(), contact.getContactFaxNumber(), contact.getContactCellphoneNumber(), contact.getContactComment())); + // Mobile and such ... + this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getContactLandLineNumber(), contact.getContactFaxNumber(), contact.getContactMobileNumber(), contact.getContactComment())); // Trace message this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N @@ -193,8 +193,8 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC // Get manager and cast it ContactFacade manager = (ContactFacade) this.getFacade(); - // Gender: - Gender gender = manager.enterOwnGender(); + // PersonalTitle: + PersonalTitle title = manager.enterOwnPersonalTitle(); // Surname String firstName = manager.enterOwnFirstName(); @@ -203,7 +203,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String familyName = manager.enterOwnFamilyName(); // Update contact instance - contact.setContactGender(gender); + contact.setContactPersonalTitle(title); contact.setContactFirstName(firstName); contact.setContactFamilyName(familyName); @@ -235,7 +235,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC DialableLandLineNumber phoneNumber = manager.enterOwnPhoneNumber(); // Phone number - DialableCellphoneNumber cellphonePhoneNumber = manager.enterOwnCellNumber(); + DialableMobileNumber mobileNumber = manager.enterOwnCellNumber(); // Fax number DialableFaxNumber faxNumber = manager.enterOwnFaxNumber(); @@ -248,7 +248,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC // Update contact instance contact.setContactLandLineNumber(phoneNumber); - contact.setContactCellphoneNumber(cellphonePhoneNumber); + contact.setContactMobileNumber(mobileNumber); contact.setContactFaxNumber(faxNumber); contact.setContactEmailAddress(email); contact.setContactComment(comment); @@ -265,8 +265,8 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC // Get manager and cast it ContactFacade manager = (ContactFacade) this.getFacade(); - // First ask for gender - Gender gender = manager.enterOwnGender(); + // First ask for title + PersonalTitle title = manager.enterOwnPersonalTitle(); // 2nd for first name String firstName = manager.enterOwnFirstName(); @@ -275,7 +275,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC String familyName = manager.enterOwnFamilyName(); // Construct UserContact instance - Contact contact = new UserContact(gender, firstName, familyName); + Contact contact = new UserContact(title, firstName, familyName); // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N @@ -317,7 +317,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC try { // Enter/add own data manager.doEnterOwnData(); - } catch (final ContactAlreadyAddedException ex) { + } catch (final BusinessDataAlreadyAddedException ex) { // Already added this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben."); } @@ -366,6 +366,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public char enterChar (final char[] validChars, final String message) { // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("validChars={0},message={1} - CALLED!", Arrays.toString(validChars), message)); //NOI18N @@ -401,23 +402,23 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } @Override - public Gender enterGender (final String message) { + public PersonalTitle enterPersonalTitle (final String message) { // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N // Get valid chars - char[] validChars = Gender.validChars(); + char[] validChars = PersonalTitle.validChars(); // Debug message //* NOISY-DEBUG: */ System.out.println(validChars); // Call inner method - char gender = this.enterChar(validChars, message); + char title = this.enterChar(validChars, message); - // Now get a Gender instance back - Gender g = Gender.fromChar(gender); + // Now get a PersonalTitle instance back + PersonalTitle g = PersonalTitle.fromChar(title); // g must not be null - assert (g instanceof Gender) : "g is not set."; //NOI18N + assert (g instanceof PersonalTitle) : "g is not set."; //NOI18N // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N @@ -427,6 +428,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public int enterInt (final int minimum, final int maximum, final String message) { // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N @@ -454,6 +456,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) { // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("minLength={0},maxLength={1},message={2}allowEmpty={3} - CALLED!", minLength, maxLength, message, allowEmpty)); //NOI18N @@ -507,6 +510,7 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC } @Override + @SuppressWarnings ("UseOfSystemOutOrSystemErr") public void outputMessage (final String message) { System.out.println(message); } @@ -531,7 +535,7 @@ 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) 2016 by Roland Haeder, this is free software"); //NOI18N + this.outputMessage("Copyright(c) 2016 by Roland Häder, this is free software"); //NOI18N // Debug message this.getLoggerBeanLocal().logDebug("Intro shown to user"); //NOI18N @@ -656,4 +660,5 @@ public class ConsoleClient extends BaseAddressbookClient implements AddressbookC // Trace message this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N } + }