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.menu.Menu;
import org.mxchange.addressbook.menu.MenuTools;
@Override
public void displayAddressBox (final Contact contact) {
// Trace message
- this.getLogger().trace("contact=" + contact + " - CALLED!"); //NOI18N
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
// Is it null?
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Simple display ...
// Is it null?
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Get translated gender as the user may want to see "Mr.", "Mrs."
// Is it null?
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Cellphone and such ...
// Is it null?
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
- throw new IllegalArgumentException("Contact is not own data.");
+ throw new IllegalArgumentException("Contact is not own data."); //NOI18N
}
// Own address data
// Is it null?
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
- throw new IllegalArgumentException("Contact is not own data.");
+ throw new IllegalArgumentException("Contact is not own data."); //NOI18N
}
// Gender:
// Is it null?
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
- throw new IllegalArgumentException("Contact is not own data.");
+ throw new IllegalArgumentException("Contact is not own data."); //NOI18N
}
// Phone number
// @TODO Rewrite this ugly switch() block
switch (choice) {
- case '1': // Enter/add own data
- this.getContactManager().doEnterOwnData();
+ case '1':
+ try {
+ // Enter/add own data
+ this.getContactManager().doEnterOwnData();
+ } catch (final ContactAlreadyAddedException ex) {
+ // Already added
+ this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
+ }
break;
case '2': // Change own data
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
// The validChars must not null be null and filled with at least one char
if (validChars == null) {
// Is null
- throw new NullPointerException("validChars is null");
+ throw new NullPointerException("validChars is null"); //NOI18N
} else if (validChars.length == 0) {
// Is not filled
- throw new IllegalArgumentException("validChars is not filled.");
+ throw new IllegalArgumentException("validChars is not filled."); //NOI18N
}
char input = 0;
Gender g = Gender.fromChar(gender);
// g must not be null
- assert(g instanceof Gender) : "g is not set.";
+ assert(g instanceof Gender) : "g is not set."; //NOI18N
// Trace message
- this.getLogger().trace("g=" + g + " - EXIT!"); //NOI18N
+ this.getLogger().trace(MessageFormat.format("g={0} - EXIT!", g)); //NOI18N
// Return it
return g;
}
// Trace message
- this.getLogger().trace("input=" + input + " - EXIT!"); //NOI18N
+ this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
// Return it
return input;
@Override
public void showEntry (final SelectableMenuItem item) {
// Access key then text
- this.outputMessage("[" + item.getAccessKey() + "] " + item.getText());
+ this.outputMessage(MessageFormat.format("[{0}] {1}", item.getAccessKey(), item.getText()));
}
/**