Signed-off-by:Roland Häder <roland@mxchange.org>
20 files changed:
/**
* Application title
*/
/**
* Application title
*/
- public static final String APP_TITLE = "Adressbuch";
+ public static final String APP_TITLE = "Adressbuch"; //NOI18N
/**
* Application version
*/
/**
* Application version
*/
- public static final String APP_VERSION = "0.0";
+ public static final String APP_VERSION = "0.0"; //NOI18N
* @return A printable name
*/
public static String printableTitle () {
* @return A printable name
*/
public static String printableTitle () {
- return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION);
+ return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
*/
@Override
public void doBootstrap () {
*/
@Override
public void doBootstrap () {
- this.getLogger().debug("Initializing application ...");
+ this.getLogger().debug("Initializing application ..."); //NOI18N
// Init client variable
Client client = null;
// Init client variable
Client client = null;
// Is console or Swing choosen?
if (this.isConsole()) {
// Debug message
// Is console or Swing choosen?
if (this.isConsole()) {
// Debug message
- this.getLogger().debug("Initializing console client ...");
+ this.getLogger().debug("Initializing console client ..."); //NOI18N
// Init console client instance
client = new ConsoleClient(this);
} else if (this.isGui()) {
// Debug message
// Init console client instance
client = new ConsoleClient(this);
} else if (this.isGui()) {
// Debug message
- this.getLogger().debug("Initializing GUI (Swing) client ...");
+ this.getLogger().debug("Initializing GUI (Swing) client ..."); //NOI18N
// Init console instance
client = new SwingClient(this);
} else {
// Not client choosen
// Init console instance
client = new SwingClient(this);
} else {
// Not client choosen
- this.getLogger().error("No client choosen. Cannot launch.");
+ this.getLogger().error("No client choosen. Cannot launch."); //NOI18N
// The application is running at this point
this.getClient().enableIsRunning();
// The application is running at this point
this.getClient().enableIsRunning();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
@Override
public void doMainLoop () {
// Debug message
@Override
public void doMainLoop () {
// Debug message
- this.getLogger().trace("CALLED!");
+ this.getLogger().trace("CALLED!"); //NOI18N
// @TODO The application should be running now
// Output introduction
this.showIntro();
// Set current menu to main
// @TODO The application should be running now
// Output introduction
this.showIntro();
// Set current menu to main
- this.getClient().setCurrentMenu("main");
+ this.getClient().setCurrentMenu("main"); //NOI18N
// --- Main loop starts here ---
while (this.getClient().isRunning()) {
// --- Main loop starts here ---
while (this.getClient().isRunning()) {
// --- Main loop ends here ---
// Debug message
// --- Main loop ends here ---
// Debug message
- this.getLogger().debug("Main loop exit - shutting down ...");
+ this.getLogger().debug("Main loop exit - shutting down ..."); //NOI18N
}
/**
* Enables console client by setting propper flag
*/
private void enableConsoleClient () {
}
/**
* Enables console client by setting propper flag
*/
private void enableConsoleClient () {
- this.getLogger().debug("Enabling console client (may become optional client) ...");
+ this.getLogger().debug("Enabling console client (may become optional client) ..."); //NOI18N
this.consoleClient = true;
this.guiClient = false;
}
this.consoleClient = true;
this.guiClient = false;
}
* Enables GUI client by setting propper flag
*/
private void enableGuiClient () {
* Enables GUI client by setting propper flag
*/
private void enableGuiClient () {
- this.getLogger().debug("Enabling GUI client (may become new default client) ...");
+ this.getLogger().debug("Enabling GUI client (may become new default client) ..."); //NOI18N
this.consoleClient = false;
this.guiClient = true;
}
this.consoleClient = false;
this.guiClient = true;
}
* @param args Arguments from program launch
*/
private void parseArguments (final String[] args) {
* @param args Arguments from program launch
*/
private void parseArguments (final String[] args) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("args()={0} - CALLED!", args.length)); //NOI18N
+
- this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length));
+ this.getLogger().debug(MessageFormat.format("Parsing {0} arguments ...", args.length)); //NOI18N
for (final String arg : args) {
// Switch on it
switch (arg) {
for (final String arg : args) {
// Switch on it
switch (arg) {
+ case "-console": //NOI18N
enableConsoleClient();
break;
enableConsoleClient();
break;
enableGuiClient();
break;
}
enableGuiClient();
break;
}
* Show introduction which depends on client
*/
private void showIntro () {
* Show introduction which depends on client
*/
private void showIntro () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Let the client show it
this.getClient().showWelcome();
// Let the client show it
this.getClient().showWelcome();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param args Arguments handled to program
*/
private void start (final String args[]) {
* @param args Arguments handled to program
*/
private void start (final String args[]) {
- this.getLogger().info("Program is started.");
+ this.getLogger().info("Program is started."); //NOI18N
// Parse arguments
this.parseArguments(args);
// Parse arguments
this.parseArguments(args);
ApplicationManager.getManager(this).start();
// Good bye, but this should not be reached ...
ApplicationManager.getManager(this).start();
// Good bye, but this should not be reached ...
- this.getLogger().warn("Unusual exit reached.");
+ this.getLogger().warn("Unusual exit reached."); //NOI18N
*/
@Override
public void doShutdown () {
*/
@Override
public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Shutdown client
this.getClient().doShutdown();
// Shutdown client
this.getClient().doShutdown();
- this.getLogger().info("End of program (last line)");
+ this.getLogger().info("End of program (last line)"); //NOI18N
*/
package org.mxchange.addressbook.client;
*/
package org.mxchange.addressbook.client;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.mxchange.addressbook.BaseFrameworkSystem;
import java.util.HashMap;
import java.util.Map;
import org.mxchange.addressbook.BaseFrameworkSystem;
* Shutdown method for all clients
*/
public void doShutdown () {
* 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();
// Disable client
this.disableIsRunning();
// Shuts down contact manager
this.getContactManager().doShutdown();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* Initializes contact manager
*/
protected void initContactManager () {
* Initializes contact manager
*/
protected void initContactManager () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Debug message
this.getLogger().debug("Initializing contact manager ...");
// Debug message
this.getLogger().debug("Initializing contact manager ...");
// Debug message
this.getLogger().debug("Contact manager has been initialized.");
// Debug message
this.getLogger().debug("Contact manager has been initialized.");
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param menuType Given menu to show
*/
protected void showMenu (final String menuType) {
* @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?
Menu menu = this.getMenu(menuType);
// Is the menu set?
// Show menu
menu.show((Client) this);
// Show menu
menu.show((Client) this);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param application An instance of an Application class
*/
public ConsoleClient (final Application application) {
* @param application An instance of an Application class
*/
public ConsoleClient (final Application application) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N
// Set application instance
this.setApplication(application);
// Init scanner instance
this.scanner = new Scanner(System.in);
// Set application instance
this.setApplication(application);
// Init scanner instance
this.scanner = new Scanner(System.in);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void displayAddressBox (final Contact contact) {
*/
@Override
public void displayAddressBox (final Contact contact) {
+ // Trace message
+ this.getLogger().trace("contact=" + contact + " - CALLED!"); //NOI18N
+
+ // Is it null?
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// Simple display ...
this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getStreet(), contact.getZipCode(), contact.getCity(), contact.getCountryCode()));
// Simple display ...
this.outputMessage(MessageFormat.format("Strasse, PLZ Ort, Land: {0}\n{1} {2}\n{3}", contact.getStreet(), contact.getZipCode(), contact.getCity(), contact.getCountryCode()));
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void displayNameBox (final Contact contact) {
*/
@Override
public void displayNameBox (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+ // Is it null?
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// Get translated gender as the user may want to see "Mr.", "Mrs."
String gender = contact.getTranslatedGender();
// Get translated gender as the user may want to see "Mr.", "Mrs."
String gender = contact.getTranslatedGender();
// Company contact
this.outputMessage(MessageFormat.format("Firma: {0}\nAnsprechpartner: {1} {2} {3}", companyName, gender, contact.getSurname(), contact.getFamilyName()));
}
// Company contact
this.outputMessage(MessageFormat.format("Firma: {0}\nAnsprechpartner: {1} {2} {3}", companyName, gender, contact.getSurname(), contact.getFamilyName()));
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void displayOtherDataBox (final Contact contact) {
*/
@Override
public void displayOtherDataBox (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+ // Is it null?
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// Cellphone and such ...
this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getPhoneNumber(), contact.getFaxNumber(), contact.getCellphoneNumber(), contact.getComment()));
// Cellphone and such ...
this.outputMessage(MessageFormat.format("Telefonnumer: {0}\nFaxnummer: {1}\nHandy: {2}\nKommentar:\n{3}", contact.getPhoneNumber(), contact.getFaxNumber(), contact.getCellphoneNumber(), contact.getComment()));
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public void doChangeOwnAddressData (final Contact contact) {
}
@Override
public void doChangeOwnAddressData (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+ // Is it null?
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
// Update address data
contact.updateAddressData(street, zipCode, city, countryCode);
// Update address data
contact.updateAddressData(street, zipCode, city, countryCode);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public void doChangeOwnNameData (final Contact contact) {
}
@Override
public void doChangeOwnNameData (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+ // Is it null?
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
// Update contact instance
contact.updateNameData(gender, surname, familyName, companyName);
// Update contact instance
contact.updateNameData(gender, surname, familyName, companyName);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public void doChangeOwnOtherData (final Contact contact) {
}
@Override
public void doChangeOwnOtherData (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+ // Is it null?
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
// Make sure it is own contact
if (!contact.isOwnContact()) {
// Not own contact
// Update contact instance
contact.updateOtherData(phoneNumber, cellNumber, faxNumber, email, null, comment);
// Update contact instance
contact.updateOtherData(phoneNumber, cellNumber, faxNumber, email, null, comment);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public Contact doEnterOwnData () {
}
@Override
public Contact doEnterOwnData () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// First ask for gender
Gender gender = this.getContactManager().enterOwnGender();
// First ask for gender
Gender gender = this.getContactManager().enterOwnGender();
// Construct UserContact instance
Contact contact = new UserContact(gender, surname, familyName, companyName);
// Construct UserContact instance
Contact contact = new UserContact(gender, surname, familyName, companyName);
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+
// And return object
return contact;
}
// And return object
return contact;
}
*/
@Override
public void doShutdown () {
*/
@Override
public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Parent call
super.doShutdown();
// @TODO Add other shutdown stuff
// Parent call
super.doShutdown();
// @TODO Add other shutdown stuff
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public void doUserMenuChoice () throws UnhandledUserChoiceException {
}
@Override
public void doUserMenuChoice () throws UnhandledUserChoiceException {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Get all access keys from menu
char[] accessKeys = MenuTools.getAccessKeysFromMenuMap(this.getMenus(), this.getCurrentMenu());
// Get all access keys from menu
char[] accessKeys = MenuTools.getAccessKeysFromMenuMap(this.getMenus(), this.getCurrentMenu());
// @TODO throw own exception
throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice));
}
// @TODO throw own exception
throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice));
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public char enterChar (final char[] validChars, final String message) {
*/
@Override
public char enterChar (final char[] validChars, final String message) {
+ // Trace message
+ this.getLogger().trace(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 (validChars == null) {
+ // Is null
+ throw new NullPointerException("validChars is null");
+ } else if (validChars.length == 0) {
+ // Is not filled
+ throw new IllegalArgumentException("validChars is not filled.");
+ }
+
char input = 0;
// Sort array, else binarySearch() won't work
char input = 0;
// Sort array, else binarySearch() won't work
input = this.readChar();
}
input = this.readChar();
}
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+
// Return read char
return input;
}
// Return read char
return input;
}
*/
@Override
public Gender enterGender (final String message) {
*/
@Override
public Gender enterGender (final String message) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("message={0} - CALLED!", message)); //NOI18N
+
// Get valid chars
char[] validChars = Gender.validChars();
// Get valid chars
char[] validChars = Gender.validChars();
// Now get a Gender instance back
Gender g = Gender.fromChar(gender);
// Now get a Gender instance back
Gender g = Gender.fromChar(gender);
+ // g must not be null
+ assert(g instanceof Gender) : "g is not set.";
+
+ // Trace message
+ this.getLogger().trace("g=" + g + " - EXIT!"); //NOI18N
+
*/
@Override
public int enterInt (final int minimum, final int maximum, final String message) {
*/
@Override
public int enterInt (final int minimum, final int maximum, final String message) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("minimum={0},maximum={1},message={2} - CALLED!", minimum, maximum, message)); //NOI18N
+
// Minimum should not be below zero
assert (minimum >= 0);
assert (maximum > minimum);
// Minimum should not be below zero
assert (minimum >= 0);
assert (maximum > minimum);
input = this.readInt();
}
input = this.readInt();
}
+ // Trace message
+ this.getLogger().trace("input=" + input + " - EXIT!"); //NOI18N
+
// Return it
return input;
}
// Return it
return input;
}
*/
@Override
public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
*/
@Override
public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty) {
+ // Trace message
+ this.getLogger().trace(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);
// Check on length, e.g. country codes are excactly 2 chars long
assert (maxLength >= minLength);
input = this.readString();
}
input = this.readString();
}
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+
// Return it
return input;
}
// Return it
return input;
}
*/
@Override
public void init () {
*/
@Override
public void init () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Init contact manager here
this.initContactManager();
// Fill menu map
this.fillMenuMap();
// Init contact manager here
this.initContactManager();
// Fill menu map
this.fillMenuMap();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
@Override
public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
@Override
public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+ // Contact must not be null
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null");
+ }
+
// 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) ");
// @TODO Get rid of this ugly switch block, too
switch (choice) {
case 'n': // Name data
// 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) ");
// @TODO Get rid of this ugly switch block, too
switch (choice) {
case 'n': // Name data
- this.getContactManager().doChangeNameData(contact, this);
+ this.getContactManager().doChangeNameData(contact);
break;
case 'a': // Address data
break;
case 'a': // Address data
- this.getContactManager().doChangeAddressData(contact, this);
+ this.getContactManager().doChangeAddressData(contact);
break;
case 'o': // Other data
break;
case 'o': // Other data
- this.getContactManager().doChangeOtherData(contact, this);
+ this.getContactManager().doChangeOtherData(contact);
break;
case 'x': // Exit this menu
break;
case 'x': // Exit this menu
// @TODO throw own exception
throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice));
}
// @TODO throw own exception
throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice));
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
protected final void fillMenuMap () {
*/
@Override
protected final void fillMenuMap () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Initialize first (main) menu
Menu menu = new ConsoleMenu("main", this);
// Add it
this.getMenus().put("main", menu);
// Initialize first (main) menu
Menu menu = new ConsoleMenu("main", this);
// Add it
this.getMenus().put("main", menu);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
// Set client here
this.setClient(client);
// Set client here
this.setClient(client);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public Contact doEnterOwnData () {
}
@Override
public Contact doEnterOwnData () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Is the "add contact" window visible?
if (this.addContact.isVisible()) {
// Something bad happened
// Is the "add contact" window visible?
if (this.addContact.isVisible()) {
// Something bad happened
// Make other window visible
this.addContact.setVisible(true);
// Make other window visible
this.addContact.setVisible(true);
+ // Trace message
+ this.getLogger().trace("Returning null : EXIT!"); //NOI18N
+
// Return value is not supported
return null;
}
// Return value is not supported
return null;
}
*/
@Override
public void doShutdown () {
*/
@Override
public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// First only show shutdown status
this.updateStatus("shutdown"); //NOI18N
// First only show shutdown status
this.updateStatus("shutdown"); //NOI18N
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void enableMainWindow () {
*/
@Override
public void enableMainWindow () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Enable it again
this.frame.setEnabled(true);
// Request focus for this window
this.frame.requestFocus();
// Enable it again
this.frame.setEnabled(true);
// Request focus for this window
this.frame.requestFocus();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
// All done here
this.updateStatus("done"); //NOI18N
// All done here
this.updateStatus("done"); //NOI18N
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
// Set flag
this.isInitialized = true;
// Set flag
this.isInitialized = true;
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void shutdownApplication () {
*/
@Override
public void shutdownApplication () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// To do this, the frame must be initialized
if (!this.isInitialized()) {
// Not initalized, so bad call
this.getLogger().fatal("Bad call of shutdownApplication(). Please report this."); //NOI18N
return;
}
// To do this, the frame must be initialized
if (!this.isInitialized()) {
// Not initalized, so bad call
this.getLogger().fatal("Bad call of shutdownApplication(). Please report this."); //NOI18N
return;
}
+
+ // Call shutdown method
this.getClient().getApplication().doShutdown();
this.getClient().getApplication().doShutdown();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* Initializes "add contact" dialog
*/
private void initAddContactDialog () {
* Initializes "add contact" dialog
*/
private void initAddContactDialog () {
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+
// Instance dialog and set title
this.addContact = new JDialog();
this.addContact.setTitle(this.generateFrameTitle("dialog.addContact")); //NOI18N
// Instance dialog and set title
this.addContact = new JDialog();
this.addContact.setTitle(this.generateFrameTitle("dialog.addContact")); //NOI18N
// x)Only for developing:
/* DEBUG: */ this.addContact.setVisible(true);
// x)Only for developing:
/* DEBUG: */ this.addContact.setVisible(true);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param dialog A JDialog instance to this components to
*/
private void initAddressDataPanel (final JDialog dialog) {
* @param dialog A JDialog instance to this components to
*/
private void initAddressDataPanel (final JDialog dialog) {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Panel "address" input boxes
JPanel addressPanel = new JPanel();
addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.Y_AXIS));
// Panel "address" input boxes
JPanel addressPanel = new JPanel();
addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.Y_AXIS));
// Add panel to dialog
dialog.add(addressPanel);
// Add panel to dialog
dialog.add(addressPanel);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
// Init other windows
initOtherDialogs();
// Init other windows
initOtherDialogs();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
/**
* Initializes the menu system
*/
private void initMenuSystem () {
}
/**
* Initializes the menu system
*/
private void initMenuSystem () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Init menu bar, menu and item instances
JMenuBar menuBar = new JMenuBar();
JMenu menu;
// Init menu bar, menu and item instances
JMenuBar menuBar = new JMenuBar();
JMenu menu;
// Add menu bar -> frame
this.frame.add(menuBar, BorderLayout.NORTH);
// Add menu bar -> frame
this.frame.add(menuBar, BorderLayout.NORTH);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param dialog A JDialog instance to this components to
*/
private void initNameDataPanel (final JDialog dialog) {
* @param dialog A JDialog instance to this components to
*/
private void initNameDataPanel (final JDialog dialog) {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Panel "name" input boxes
JPanel namePanel = new JPanel();
namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.Y_AXIS));
// Panel "name" input boxes
JPanel namePanel = new JPanel();
namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.Y_AXIS));
// Finally add panel to dialog
dialog.add(namePanel);
// Finally add panel to dialog
dialog.add(namePanel);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @todo Fill this with life
*/
private void initOtherDataPanel (final JDialog dialog) {
* @todo Fill this with life
*/
private void initOtherDataPanel (final JDialog dialog) {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Panel "other" input boxes
JPanel otherPanel = new JPanel();
otherPanel.setLayout(new BoxLayout(otherPanel, BoxLayout.Y_AXIS));
// Panel "other" input boxes
JPanel otherPanel = new JPanel();
otherPanel.setLayout(new BoxLayout(otherPanel, BoxLayout.Y_AXIS));
// Finally add panel to dialog
dialog.add(otherPanel);
// Finally add panel to dialog
dialog.add(otherPanel);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
/**
* Initialize other dialogs (e.g. "Add contact")
*/
private void initOtherDialogs () {
}
/**
* Initialize other dialogs (e.g. "Add contact")
*/
private void initOtherDialogs () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Init other windows:
// 1) Add contact
initAddContactDialog();
// Init other windows:
// 1) Add contact
initAddContactDialog();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
/**
* Initializes status panel
*/
private void initStatusPanel () {
}
/**
* Initializes status panel
*/
private void initStatusPanel () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Init status label (which needs to be updated
this.statusLabel = new JLabel();
this.updateStatus("initializing"); //NOI18N
// Init status label (which needs to be updated
this.statusLabel = new JLabel();
this.updateStatus("initializing"); //NOI18N
// Add panel to frame
this.frame.add(panel, BorderLayout.SOUTH);
// Add panel to frame
this.frame.add(panel, BorderLayout.SOUTH);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
/**
* Initializes the table which will show all contacts
*/
private void initTable () {
}
/**
* Initializes the table which will show all contacts
*/
private void initTable () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Instance table model
this.dataModel = new ContactTableModel(this.getClient());
// Instance table model
this.dataModel = new ContactTableModel(this.getClient());
// Add pane to frame
this.frame.add(scroller, BorderLayout.CENTER);
// Add pane to frame
this.frame.add(scroller, BorderLayout.CENTER);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param type Status type
*/
private void updateStatus (final String type) {
* @param type Status type
*/
private void updateStatus (final String type) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("type={0} - CALLED!", type)); //NOI18N
+
// Set status message
this.statusLabel.setText(this.getBundle().getString(String.format("AddressbookFrame.statusLabel.%s.text", type))); //NOI18N
// Set status message
this.statusLabel.setText(this.getBundle().getString(String.format("AddressbookFrame.statusLabel.%s.text", type))); //NOI18N
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param application Application instance
*/
public SwingClient (final Application application) {
* @param application Application instance
*/
public SwingClient (final Application application) {
// Debug message
this.getLogger().trace("CALLED!"); //NOI18N
// Debug message
this.getLogger().trace("CALLED!"); //NOI18N
// Init frame instance
this.frame = AddressbookFrame.getSelfInstance(this);
// Init frame instance
this.frame = AddressbookFrame.getSelfInstance(this);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public Contact doEnterOwnData () {
*/
@Override
public Contact doEnterOwnData () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Deligate this call to the frame
return this.frame.doEnterOwnData();
}
// Deligate this call to the frame
return this.frame.doEnterOwnData();
}
@Override
public void showCurrentMenu () {
@Override
public void showCurrentMenu () {
//* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
// Not implemented here
//* NOISY-DEBUG: */ this.getLogger().trace("CALLED!");
// Not implemented here
*/
package org.mxchange.addressbook.contact;
*/
package org.mxchange.addressbook.contact;
+import java.text.MessageFormat;
import java.util.Objects;
import org.mxchange.addressbook.BaseFrameworkSystem;
import org.mxchange.addressbook.client.Client;
import java.util.Objects;
import org.mxchange.addressbook.BaseFrameworkSystem;
import org.mxchange.addressbook.client.Client;
* @todo Needs a lot improvements
*/
@Override
* @todo Needs a lot improvements
*/
@Override
- public boolean equals (Object object) {
+ public boolean equals (final Object object) {
// Is it same type?
if (!(object instanceof BaseContact)) {
// Not equal types
// Is it same type?
if (!(object instanceof BaseContact)) {
// Not equal types
* @return "CSV-serialized" version of the stored data
*/
public String getCsvStringFromStoreableObject () {
* @return "CSV-serialized" version of the stored data
*/
public String getCsvStringFromStoreableObject () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Get all together
String csvString = String.format(
// Get all together
String csvString = String.format(
- "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"\n",
+ "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"",
this.isOwnContact(),
this.getGender().getDatabaseValue(),
this.getSurname(),
this.isOwnContact(),
this.getGender().getDatabaseValue(),
this.getSurname(),
* @param client Client instance to use
*/
public void show (final Client client) {
* @param client Client instance to use
*/
public void show (final Client client) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
+
+ // The client must be set
+ if (client == null) {
+ // Not set
+ throw new NullPointerException("client is null");
+ }
+
// Display name "box"
client.displayNameBox((Contact) this);
// Display name "box"
client.displayNameBox((Contact) this);
* @param countryCode Country code
*/
public void updateAddressData (final String street, final long zipCode, final String city, final String countryCode) {
* @param countryCode Country code
*/
public void updateAddressData (final String street, final long zipCode, final String city, final String countryCode) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("street={0},zipCode={1},city={2},countryCode={3} - CALLED!", street, zipCode, city, countryCode)); //NOI18N
+
// Set all
if (street != null) {
this.setStreet(street);
// Set all
if (street != null) {
this.setStreet(street);
if (countryCode != null) {
this.setCountryCode(countryCode);
}
if (countryCode != null) {
this.setCountryCode(countryCode);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param companyName Company name
*/
public void updateNameData (final Gender gender, final String surname, final String familyName, final String companyName) {
* @param companyName Company name
*/
public void updateNameData (final Gender gender, final String surname, final String familyName, final String companyName) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("gender={0},surname={1},familyName={2},companyName={3} - CALLED!", gender, surname, familyName, companyName)); //NOI18N
+
// Set all
this.setGender(gender);
// Set all
this.setGender(gender);
if (companyName != null) {
this.setCompanyName(companyName);
}
if (companyName != null) {
this.setCompanyName(companyName);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param comment Comments
*/
public void updateOtherData (final String phoneNumber, final String cellphoneNumber, final String faxNumber, final String emailAddress, final String birthday, final String comment) {
* @param comment Comments
*/
public void updateOtherData (final String phoneNumber, final String cellphoneNumber, final String faxNumber, final String emailAddress, final String birthday, final String comment) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("phoneNumber={0},cellphoneNumber={1}faxNumber={2},emailAddress={3},birthday={4},comment={5} - CALLED!", phoneNumber, cellphoneNumber, faxNumber, emailAddress, birthday, comment)); //NOI18N
+
// Set all
if (phoneNumber != null) {
this.setPhoneNumber(phoneNumber);
// Set all
if (phoneNumber != null) {
this.setPhoneNumber(phoneNumber);
if (comment != null) {
this.setComment(comment);
}
if (comment != null) {
this.setComment(comment);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
package org.mxchange.addressbook.contact.user;
*/
package org.mxchange.addressbook.contact.user;
+import java.text.MessageFormat;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.contact.book.BookContact;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.contact.book.BookContact;
// Make sure all constructors are called
this();
// Make sure all constructors are called
this();
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("gender={0},surname={1},familyName={2},companyName={3} - CALLED!", gender, surname, familyName, companyName)); //NOI18N
+
// Update all data
this.updateNameData(gender, surname, familyName, companyName);
// Update all data
this.updateNameData(gender, surname, familyName, companyName);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
public Base64CsvDatabaseBackend (final String tableName) {
// Debug message
*/
public Base64CsvDatabaseBackend (final String tableName) {
// Debug message
- this.getLogger().debug(MessageFormat.format("Trying to initialize table {0} ...", tableName));
+ this.getLogger().debug(MessageFormat.format("Trying to initialize table {0} ...", tableName)); //NOI18N
// Set table name here, too
this.setTableName(tableName);
// Construct file name
// Set table name here, too
this.setTableName(tableName);
// Construct file name
- String fileName = String.format("data/table_%s.b64", tableName);
+ String fileName = String.format("data/table_%s.b64", tableName); //NOI18N
- this.getLogger().debug(MessageFormat.format("Trying to open file {0} ...", fileName));
+ this.getLogger().debug(MessageFormat.format("Trying to open file {0} ...", fileName)); //NOI18N
try {
// Try to initialize the storage (file instance)
try {
// Try to initialize the storage (file instance)
- this.storageFile = new RandomAccessFile(fileName, "rw");
+ this.storageFile = new RandomAccessFile(fileName, "rw"); //NOI18N
} catch (final FileNotFoundException ex) {
// Did not work
} catch (final FileNotFoundException ex) {
// Did not work
- this.getLogger().error(MessageFormat.format("File {0} cannot be opened: {1}", fileName, ex.toString()));
+ this.getLogger().error(MessageFormat.format("File {0} cannot be opened: {1}", fileName, ex.toString())); //NOI18N
System.exit(1);
}
// Output message
System.exit(1);
}
// Output message
- this.getLogger().debug(MessageFormat.format("Database for {0} has been initialized.", tableName));
+ this.getLogger().debug(MessageFormat.format("Database for {0} has been initialized.", tableName)); //NOI18N
*/
@Override
public Iterator<Contact> contactIterator () throws BadTokenException {
*/
@Override
public Iterator<Contact> contactIterator () 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<Contact> list = this.readContactList();
/*
* Then read the file into RAM (yes, not perfect for >1000 entries ...)
* and get a List back.
*/
List<Contact> list = this.readContactList();
+ // 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 iterator from list and return it
return list.iterator();
}
*/
@Override
public void doShutdown () {
*/
@Override
public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
try {
// Close file
this.getStorageFile().close();
try {
// Close file
this.getStorageFile().close();
this.getLogger().catching(ex);
System.exit(1);
}
this.getLogger().catching(ex);
System.exit(1);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
try {
length = this.getStorageFile().length();
try {
length = this.getStorageFile().length();
- this.getLogger().debug(MessageFormat.format("length={0}", length));
+ this.getLogger().debug(MessageFormat.format("length={0}", length)); //NOI18N
} catch (final IOException ex) {
// Length cannot be determined
this.getLogger().catching(ex);
} catch (final IOException ex) {
// Length cannot be determined
this.getLogger().catching(ex);
- this.getLogger().trace(MessageFormat.format("length={0} : EXIT!", length));
+ this.getLogger().trace(MessageFormat.format("length={0} : EXIT!", length)); //NOI18N
*/
@Override
public void rewind () {
*/
@Override
public void rewind () {
- this.getLogger().trace("CALLED!");
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
try {
// Rewind underlaying database file
try {
// Rewind underlaying database file
- this.getLogger().trace("EXIT!");
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void store (final Storeable object) throws IOException {
*/
@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");
+ }
+
// Make sure the instance is there (DataOutput flawor)
assert (this.storageFile instanceof DataOutput);
// Make sure the instance is there (DataOutput flawor)
assert (this.storageFile instanceof DataOutput);
String str = csv.getCsvStringFromStoreableObject();
// Debug message
String str = csv.getCsvStringFromStoreableObject();
// Debug message
- this.getLogger().debug(MessageFormat.format("str({0})={1}", str.length(), str));
+ this.getLogger().debug(MessageFormat.format("str({0})={1}", str.length(), str)); //NOI18N
// Encode line in BASE-64
// Encode line in BASE-64
- byte[] encoded = Base64.getEncoder().encode(str.trim().getBytes());
+ byte[] encoded = Base64.getEncoder().encode(str.getBytes());
// The string is now a valid CSV string
this.getStorageFile().write(encoded);
// The string is now a valid CSV string
this.getStorageFile().write(encoded);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param list List instance
*/
private void addContactToList (final Contact contact, final List<Contact> list) {
* @param list List instance
*/
private void addContactToList (final Contact contact, final List<Contact> list) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
// No null here
if (contact == null) {
// Throw exception
// No null here
if (contact == null) {
// Throw exception
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
} else if (list == null) {
// Throw exception
} else if (list == null) {
// Throw exception
- throw new NullPointerException("list is null");
+ throw new NullPointerException("list is null"); //NOI18N
- this.getLogger().debug(MessageFormat.format("contact={0}", contact));
+ this.getLogger().debug(MessageFormat.format("contact={0}", contact)); //NOI18N
// Is the contact read?
if (contact instanceof Contact) {
// Is the contact read?
if (contact instanceof Contact) {
boolean added = list.add(contact);
// Debug message
boolean added = list.add(contact);
// Debug message
- this.getLogger().debug(MessageFormat.format("contact={0} added={1}", contact, added));
+ this.getLogger().debug(MessageFormat.format("contact={0} added={1}", contact, added)); //NOI18N
// Has it been added?
if (!added) {
// Not added
// Has it been added?
if (!added) {
// Not added
- this.getLogger().warn("Contact object has not been added.");
+ this.getLogger().warn("Contact object has not been added."); //NOI18N
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
- this.getLogger().trace(MessageFormat.format("isEof={0} : EXIT!", isEof));
+ this.getLogger().trace(MessageFormat.format("isEof={0} : EXIT!", isEof)); //NOI18N
* @return A list with Contact instances
*/
private List<Contact> readContactList () throws BadTokenException {
* @return A list with Contact instances
*/
private List<Contact> readContactList () throws BadTokenException {
- this.getLogger().trace("CALLED!");
+ this.getLogger().trace("CALLED!"); //NOI18N
// First rewind
this.rewind();
// First rewind
this.rewind();
int lines = Math.round(this.length() / 140 + 0.5f);
// Debug message
int lines = Math.round(this.length() / 140 + 0.5f);
// Debug message
- this.getLogger().debug(MessageFormat.format("lines={0}", lines));
+ this.getLogger().debug(MessageFormat.format("lines={0}", lines)); //NOI18N
// Instance list
// @TODO The maximum length could be guessed from file size?
// Instance list
// @TODO The maximum length could be guessed from file size?
line = this.readLine();
// Debug message
line = this.readLine();
// Debug message
- this.getLogger().debug(MessageFormat.format("line={0}", line));
+ this.getLogger().debug(MessageFormat.format("line={0}", line)); //NOI18N
// Then tokenize it
// @TODO Move this into separate method
// Then tokenize it
// @TODO Move this into separate method
- tokenizer = new StringTokenizer(line, ";");
+ tokenizer = new StringTokenizer(line, ";"); //NOI18N
// Reset variables
count = 0;
// Reset variables
count = 0;
- this.getLogger().debug(MessageFormat.format("token={0}", token));
+ this.getLogger().debug(MessageFormat.format("token={0}", token)); //NOI18N
// Verify token, it must have double-quotes on each side
// Verify token, it must have double-quotes on each side
- if ((!token.startsWith("\"")) || (!token.endsWith("\""))) {
+ if ((!token.startsWith("\"")) || (!token.endsWith("\""))) { //NOI18N
// Something bad was read
// Something bad was read
- throw new BadTokenException(MessageFormat.format("Token {0} at position {1} has not double-quotes on both ends.", token, count));
+ throw new BadTokenException(MessageFormat.format("Token {0} at position {1} has not double-quotes on both ends.", token, count)); //NOI18N
}
// All fine, so remove it
String strippedToken = token.substring(1, token.length() - 1);
// Is the string's content "null"?
}
// All fine, so remove it
String strippedToken = token.substring(1, token.length() - 1);
// Is the string's content "null"?
- if (strippedToken.equals("null")) {
+ if (strippedToken.equals("null")) { //NOI18N
- this.getLogger().debug(MessageFormat.format("strippedToken={0} - NULL!", strippedToken));
+ this.getLogger().debug(MessageFormat.format("strippedToken={0} - NULL!", strippedToken)); //NOI18N
// This needs to be set to null
strippedToken = null;
}
// Debug message
// This needs to be set to null
strippedToken = null;
}
// Debug message
- this.getLogger().debug(MessageFormat.format("strippedToken={0}", strippedToken));
+ this.getLogger().debug(MessageFormat.format("strippedToken={0}", strippedToken)); //NOI18N
// Now, let's try a number check, if no null
if (strippedToken != null) {
// Now, let's try a number check, if no null
if (strippedToken != null) {
num = Long.valueOf(strippedToken);
// Debug message
num = Long.valueOf(strippedToken);
// Debug message
- this.getLogger().debug(MessageFormat.format("strippedToken={0} - NUMBER!", strippedToken));
+ this.getLogger().debug(MessageFormat.format("strippedToken={0} - NUMBER!", strippedToken)); //NOI18N
} catch (final NumberFormatException ex) {
// No number, then set default
num = null;
} catch (final NumberFormatException ex) {
// No number, then set default
num = null;
}
// Now, let's try a boolean check, if no null
}
// Now, let's try a boolean check, if no null
- if ((strippedToken != null) && (num == null) && ((strippedToken.equals("true")) || (strippedToken.equals("false")))) {
+ if ((strippedToken != null) && (num == null) && ((strippedToken.equals("true")) || (strippedToken.equals("false")))) { //NOI18N
- this.getLogger().debug(MessageFormat.format("strippedToken={0} - BOOLEAN!", strippedToken));
+ this.getLogger().debug(MessageFormat.format("strippedToken={0} - BOOLEAN!", strippedToken)); //NOI18N
// parseBoolean() is relaxed, so no exceptions
bool = Boolean.valueOf(strippedToken);
}
// Debug message
// parseBoolean() is relaxed, so no exceptions
bool = Boolean.valueOf(strippedToken);
}
// Debug message
- this.getLogger().debug(MessageFormat.format("strippedToken={0},num={1},bool={2}", strippedToken, num, bool));
+ this.getLogger().debug(MessageFormat.format("strippedToken={0},num={1},bool={2}", strippedToken, num, bool)); //NOI18N
// Now, let's try a gender check, if no null
// Now, let's try a gender check, if no null
- if ((strippedToken != null) && (num == null) && (bool == null) && ((strippedToken.equals("M")) || (strippedToken.equals("F")) || (strippedToken.equals("C")))) {
+ if ((strippedToken != null) && (num == null) && (bool == null) && ((strippedToken.equals("M")) || (strippedToken.equals("F")) || (strippedToken.equals("C")))) { //NOI18N
// Get first character
gender = Gender.fromChar(strippedToken.charAt(0));
// Debug message
// Get first character
gender = Gender.fromChar(strippedToken.charAt(0));
// Debug message
- this.getLogger().debug(MessageFormat.format("strippedToken={0},gender={1}", strippedToken, gender));
+ this.getLogger().debug(MessageFormat.format("strippedToken={0},gender={1}", strippedToken, gender)); //NOI18N
// This instance must be there
// This instance must be there
- assert (gender instanceof Gender) : "gender is not set by Gender.fromChar(" + strippedToken + ")";
+ assert (gender instanceof Gender) : "gender is not set by Gender.fromChar(" + strippedToken + ")"; //NOI18N
}
// Now it depends on the counter which position we need to check
}
// Now it depends on the counter which position we need to check
assert ((bool instanceof Boolean));
// Debug message
assert ((bool instanceof Boolean));
// Debug message
- this.getLogger().debug(MessageFormat.format("bool={0}", bool));
+ this.getLogger().debug(MessageFormat.format("bool={0}", bool)); //NOI18N
// Is it own contact?
if (true == bool) {
// Debug message
// Is it own contact?
if (true == bool) {
// Debug message
- this.getLogger().debug("Creating UserContact object ...");
+ this.getLogger().debug("Creating UserContact object ..."); //NOI18N
// Own entry
contact = new UserContact();
} else {
// Debug message
// Own entry
contact = new UserContact();
} else {
// Debug message
- this.getLogger().debug("Creating BookContact object ...");
+ this.getLogger().debug("Creating BookContact object ..."); //NOI18N
// Other contact
contact = new BookContact();
// Other contact
contact = new BookContact();
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateNameData(gender, null, null, null);
break;
case 2: // Surname
// Update data
contact.updateNameData(gender, null, null, null);
break;
case 2: // Surname
- assert (contact instanceof Contact) : "First token was not boolean";
- assert (gender instanceof Gender) : "gender instance is not set";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
+ assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N
// Update data
contact.updateNameData(gender, strippedToken, null, null);
break;
case 3: // Family name
// Update data
contact.updateNameData(gender, strippedToken, null, null);
break;
case 3: // Family name
- assert (contact instanceof Contact) : "First token was not boolean";
- assert (gender instanceof Gender) : "gender instance is not set";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
+ assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N
// Update data
contact.updateNameData(gender, null, strippedToken, null);
break;
case 4: // Company name
// Update data
contact.updateNameData(gender, null, strippedToken, null);
break;
case 4: // Company name
- assert (contact instanceof Contact) : "First token was not boolean";
- assert (gender instanceof Gender) : "gender instance is not set";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
+ assert (gender instanceof Gender) : "gender instance is not set"; //NOI18N
// Update data
contact.updateNameData(gender, null, null, strippedToken);
break;
case 5: // Street number
// Update data
contact.updateNameData(gender, null, null, strippedToken);
break;
case 5: // Street number
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateAddressData(strippedToken, 0, null, null);
break;
case 6: // ZIP code
// Update data
contact.updateAddressData(strippedToken, 0, null, null);
break;
case 6: // ZIP code
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateAddressData(null, num, null, null);
break;
case 7: // City name
// Update data
contact.updateAddressData(null, num, null, null);
break;
case 7: // City name
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateAddressData(null, 0, strippedToken, null);
break;
case 8: // Country code
// Update data
contact.updateAddressData(null, 0, strippedToken, null);
break;
case 8: // Country code
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateAddressData(null, 0, null, strippedToken);
break;
case 9: // Phone number
// Update data
contact.updateAddressData(null, 0, null, strippedToken);
break;
case 9: // Phone number
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateOtherData(strippedToken, null, null, null, null, null);
break;
case 10: // Fax number
// Update data
contact.updateOtherData(strippedToken, null, null, null, null, null);
break;
case 10: // Fax number
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateOtherData(null, strippedToken, null, null, null, null);
break;
case 11: // Cellphone number
// Update data
contact.updateOtherData(null, strippedToken, null, null, null, null);
break;
case 11: // Cellphone number
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateOtherData(null, null, strippedToken, null, null, null);
break;
case 12: // Email address
// Update data
contact.updateOtherData(null, null, strippedToken, null, null, null);
break;
case 12: // Email address
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateOtherData(null, null, null, strippedToken, null, null);
break;
case 13: // Birthday
// Update data
contact.updateOtherData(null, null, null, strippedToken, null, null);
break;
case 13: // Birthday
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateOtherData(null, null, null, null, strippedToken, null);
break;
case 14: // Birthday
// Update data
contact.updateOtherData(null, null, null, null, strippedToken, null);
break;
case 14: // Birthday
- assert (contact instanceof Contact) : "First token was not boolean";
+ assert (contact instanceof Contact) : "First token was not boolean"; //NOI18N
// Update data
contact.updateOtherData(null, null, null, null, null, strippedToken);
break;
default: // New data entry
// Update data
contact.updateOtherData(null, null, null, null, null, strippedToken);
break;
default: // New data entry
- this.getLogger().warn(MessageFormat.format("Will not handle unknown data {0} at index {1}", strippedToken, count));
+ this.getLogger().warn(MessageFormat.format("Will not handle unknown data {0} at index {1}", strippedToken, count)); //NOI18N
}
// The contact instance should be there now
}
// The contact instance should be there now
- assert (contact instanceof Contact) : "contact is not set: " + contact;
+ assert (contact instanceof Contact) : "contact is not set: " + contact; //NOI18N
// Add contact
this.addContactToList(contact, list);
}
// Return finished list
// Add contact
this.addContactToList(contact, list);
}
// Return finished list
- this.getLogger().trace(MessageFormat.format("list.size()={0} : EXIT!", list.size()));
+ this.getLogger().trace(MessageFormat.format("list.size()={0} : EXIT!", list.size())); //NOI18N
* @return Read line from file
*/
private String readLine () {
* @return Read line from file
*/
private String readLine () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Init input
String input = null;
// Init input
String input = null;
this.getLogger().catching(ex);
}
this.getLogger().catching(ex);
}
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("input={0} - EXIT!", input)); //NOI18N
+
// Return read string or null
return input;
}
// Return read string or null
return input;
}
* Initialize backend
*/
protected void initBackend () {
* Initialize backend
*/
protected void initBackend () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Instance backend
this.backend = new Base64CsvDatabaseBackend(this.getTableName());
// Instance backend
this.backend = new Base64CsvDatabaseBackend(this.getTableName());
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
package org.mxchange.addressbook.database.frontend.contact;
import java.io.IOException;
package org.mxchange.addressbook.database.frontend.contact;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Iterator;
import java.util.List;
-import org.mxchange.addressbook.exceptions.BadTokenException;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.database.backend.csv.CsvBackend;
import org.mxchange.addressbook.database.frontend.BaseDatabaseFrontend;
import org.mxchange.addressbook.database.storage.Storeable;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.database.backend.csv.CsvBackend;
import org.mxchange.addressbook.database.frontend.BaseDatabaseFrontend;
import org.mxchange.addressbook.database.storage.Storeable;
+import org.mxchange.addressbook.exceptions.BadTokenException;
import org.mxchange.addressbook.manager.contact.ContactManager;
/**
import org.mxchange.addressbook.manager.contact.ContactManager;
/**
// Call own constructor
this();
// Call own constructor
this();
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("manager={0} - CALLED!", manager)); //NOI18N
+
+ // Manager instance must not be null
+ if (manager == null) {
+ // Abort here
+ throw new NullPointerException("manager is null"); //NOI18N
+ }
+
// Set contact manager
this.setContactManager(manager);
}
// Set contact manager
this.setContactManager(manager);
}
protected ContactDatabaseFrontend () {
super();
protected ContactDatabaseFrontend () {
super();
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
- this.setTableName("contacts");
+ this.setTableName("contacts"); //NOI18N
// Initalize backend
this.initBackend();
// Initalize backend
this.initBackend();
*/
@Override
public void doShutdown () {
*/
@Override
public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Shutdown backend
this.getBackend().doShutdown();
// Shutdown backend
this.getBackend().doShutdown();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void flushAllContacts () {
*/
@Override
public void flushAllContacts () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Get full list
List<Contact> contacts = this.getContactManager().getList();
// Get full list
List<Contact> contacts = this.getContactManager().getList();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void readAllContacts () {
*/
@Override
public void readAllContacts () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Get iterator and case it
CsvBackend backend = (CsvBackend) this.getBackend();
// Get iterator and case it
CsvBackend backend = (CsvBackend) this.getBackend();
// Add contact instance to manager
this.getContactManager().addContact(contact);
}
// Add contact instance to manager
this.getContactManager().addContact(contact);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @return
*/
public static final ManageableApplication getManager (final Application application) {
* @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);
// Get manager
ManageableApplication manager = new ApplicationManager(application);
private ApplicationManager (final Application application) {
super();
private ApplicationManager (final Application application) {
super();
+ // 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 () {
// 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();
// Bootstrap application
this.getApplication().doBootstrap();
// Run the main loop
this.getApplication().doMainLoop();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
// Always call super constructor first
super();
// Always call super constructor first
super();
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("maxContacts={0},client={1} - CALLED!", maxContacts, client)); //NOI18N
+
+ // Make sure all parameters are set correctly
+ if (maxContacts <= 0) {
+ // Must not be zero or smaller
+ throw new IllegalArgumentException(MessageFormat.format("maxContacts is below or zero: {0}", maxContacts)); //NOI18N
+ } else if (client == null) {
+ // Abort here
+ throw new NullPointerException("client is null"); //NOI18N
+ }
+
// Set client instance
this.setClient(client);
// Set client instance
this.setClient(client);
*/
@Override
public void addContact (final Contact contact) {
*/
@Override
public void addContact (final Contact contact) {
- assert (this.contacts instanceof List) : "this.contacts is not initialized";
+ assert (this.contacts instanceof List) : "this.contacts is not initialized"; //NOI18N
+
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - CALLED!", contact)); //NOI18N
+
+ // Contact instance must not be null
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ }
this.contacts.add(contact);
this.contacts.add(contact);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void doAddOtherAddress () {
*/
@Override
public void doAddOtherAddress () {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
/**
* Let the user change address data
*
* @param contact Instance to change data
}
/**
* Let the user change address data
*
* @param contact Instance to change data
- * @param client Client instance to call back
- public void doChangeAddressData (final Contact contact, final Client client) {
+ public void doChangeAddressData (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+ // Contact must not be null
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ }
+
// First display it again
// First display it again
- client.displayAddressBox(contact);
+ this.getClient().displayAddressBox(contact);
// Is it own data?
if (contact.isOwnContact()) {
// Is it own data?
if (contact.isOwnContact()) {
this.getClient().doChangeOwnAddressData(contact);
} else {
// Other contact's address data to change
this.getClient().doChangeOwnAddressData(contact);
} else {
// Other contact's address data to change
- throw new UnsupportedOperationException("Changing contact entries not finished.");
+ throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
}
// Flush whole list
this.flush();
}
// Flush whole list
this.flush();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
/**
* Let the user change "name data"
*
* @param contact Instance to change data
}
/**
* Let the user change "name data"
*
* @param contact Instance to change data
- * @param client Client instance to call back
- public void doChangeNameData (final Contact contact, final Client client) {
+ public void doChangeNameData (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+ // Contact must not be null
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ }
+
// First display them again
// First display them again
- client.displayNameBox(contact);
+ this.getClient().displayNameBox(contact);
// Is this own data?
if (contact.isOwnContact()) {
// Is this own data?
if (contact.isOwnContact()) {
this.getClient().doChangeOwnNameData(contact);
} else {
// Then re-ask them ...
this.getClient().doChangeOwnNameData(contact);
} else {
// Then re-ask them ...
- throw new UnsupportedOperationException("Changing contact entries not finished.");
+ throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
}
// Flush whole list
this.flush();
}
// Flush whole list
this.flush();
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void doChangeOtherAddress () {
*/
@Override
public void doChangeOtherAddress () {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
/**
* Let the user change other data
*
* @param contact Instance to change data
}
/**
* Let the user change other data
*
* @param contact Instance to change data
- * @param client Client instance to call back
* @todo Didn't handle birthday
*/
@Override
* @todo Didn't handle birthday
*/
@Override
- public void doChangeOtherData (final Contact contact, final Client client) {
+ public void doChangeOtherData (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+ // Contact must not be null
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ }
+
// First display them again
this.getClient().displayOtherDataBox(contact);
// First display them again
this.getClient().displayOtherDataBox(contact);
this.getClient().doChangeOwnOtherData(contact);
} else {
// Then re-ask them ...
this.getClient().doChangeOwnOtherData(contact);
} else {
// Then re-ask them ...
- throw new UnsupportedOperationException("Changing contact entries not finished.");
+ throw new UnsupportedOperationException("Changing contact entries not finished."); //NOI18N
}
// Flush whole list
this.flush();
}
// Flush whole list
this.flush();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void doChangeOwnData () {
*/
@Override
public void doChangeOwnData () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
/*
* First check if the user has registered own contact, before that
* nothing can be changed.
*/
if (!this.isOwnContactAdded()) {
// Not added
/*
* First check if the user has registered own contact, before that
* nothing can be changed.
*/
if (!this.isOwnContactAdded()) {
// Not added
- this.getClient().outputMessage("Sie haben noch nicht Ihre Daten eingegeben.");
+ this.getClient().outputMessage("Sie haben noch nicht Ihre Daten eingegeben."); //NOI18N
// Skip any below code
return;
// Skip any below code
return;
} catch (final UnhandledUserChoiceException ex) {
this.getLogger().catching(ex);
}
} catch (final UnhandledUserChoiceException ex) {
this.getLogger().catching(ex);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public void doDeleteOtherAddress () {
*/
@Override
public void doDeleteOtherAddress () {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
*/
@Override
public void doEnterOwnData () {
*/
@Override
public void doEnterOwnData () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Deligate this call to the client
Contact contact = this.getClient().doEnterOwnData();
// Deligate this call to the client
Contact contact = this.getClient().doEnterOwnData();
// Add it to contact "book"
this.registerContact(contact);
}
// Add it to contact "book"
this.registerContact(contact);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
public void doListContacts () {
}
@Override
public void doListContacts () {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
@Override
public void doSearchContacts () {
}
@Override
public void doSearchContacts () {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
*/
@Override
public void doShutdown () {
*/
@Override
public void doShutdown () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Shut down the database layer
this.getContactDatabase().doShutdown();
// Shut down the database layer
this.getContactDatabase().doShutdown();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
*/
@Override
public String enterOwnCellNumber () {
*/
@Override
public String enterOwnCellNumber () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
}
return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
}
*/
@Override
public String enterOwnCity () {
*/
@Override
public String enterOwnCity () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
}
return this.getClient().enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
}
*/
@Override
public String enterOwnComment () {
*/
@Override
public String enterOwnComment () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
}
return this.getClient().enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
}
*/
@Override
public String enterOwnCompanyName () {
*/
@Override
public String enterOwnCompanyName () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
}
return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
}
*/
@Override
public String enterOwnCountryCode () {
*/
@Override
public String enterOwnCountryCode () {
+ // 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();
}
return this.getClient().enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();
}
*/
@Override
public String enterOwnEmailAddress () {
*/
@Override
public String enterOwnEmailAddress () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
}
return this.getClient().enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
}
*/
@Override
public String enterOwnFamilyName () {
*/
@Override
public String enterOwnFamilyName () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
}
return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
}
*/
@Override
public String enterOwnFaxNumber () {
*/
@Override
public String enterOwnFaxNumber () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
}
return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
}
*/
@Override
public Gender enterOwnGender () {
*/
@Override
public Gender enterOwnGender () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
}
return this.getClient().enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
}
*/
@Override
public String enterOwnPhoneNumber () {
*/
@Override
public String enterOwnPhoneNumber () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
}
return this.getClient().enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
}
*/
@Override
public String enterOwnStreet () {
*/
@Override
public String enterOwnStreet () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
}
return this.getClient().enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
}
*/
@Override
public String enterOwnSurname () {
*/
@Override
public String enterOwnSurname () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
}
return this.getClient().enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
}
*/
@Override
public int enterOwnZipCode () {
*/
@Override
public int enterOwnZipCode () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
return this.getClient().enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
}
@Override
public final int getColumnCount () {
return this.getClient().enterInt(0, 99_999, "Bitte geben Sie Ihre Postleitzahl ein: ");
}
@Override
public final int getColumnCount () {
- assert (this.columnNames instanceof List) : "this.columnNames is not initialized";
+ assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
return this.columnNames.size();
}
return this.columnNames.size();
}
*/
@Override
public String getColumnName (final int columnIndex) {
*/
@Override
public String getColumnName (final int columnIndex) {
- assert (this.columnNames instanceof List) : "this.columnNames is not initialized";
+ assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
// Get column name at index
return this.columnNames.get(columnIndex);
// Get column name at index
return this.columnNames.get(columnIndex);
*/
@Override
public List<Contact> getList () {
*/
@Override
public List<Contact> getList () {
- assert (this.contacts instanceof List) : "this.contacts is not initialized";
+ assert (this.contacts instanceof List) : "this.contacts is not initialized"; //NOI18N
return Collections.unmodifiableList(this.contacts);
}
return Collections.unmodifiableList(this.contacts);
}
@Override
public boolean isOwnContactAdded () {
// Trace message
@Override
public boolean isOwnContactAdded () {
// Trace message
- this.getLogger().trace("CALLED!");
+ this.getLogger().trace("CALLED!"); //NOI18N
- assert (this.contacts instanceof List) : "this.contacts is not initialized";
+ assert (this.contacts instanceof List) : "this.contacts is not initialized"; //NOI18N
// Default is not added
boolean isAdded = false;
// Default is not added
boolean isAdded = false;
- this.getLogger().trace(MessageFormat.format("isAdded={0} : EXIT!", isAdded));
+ this.getLogger().trace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
// Return result
return isAdded;
// Return result
return isAdded;
*/
@Override
public void registerContact (final Contact contact) {
*/
@Override
public void registerContact (final Contact contact) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} CALLED!", contact)); //NOI18N
+
+ // Contact must not be null
+ if (contact == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ }
+
// Sanity check
if (contact == null) {
// Abort here
// Sanity check
if (contact == null) {
// Abort here
- throw new NullPointerException("contact is null");
+ throw new NullPointerException("contact is null"); //NOI18N
}
// Check if contact is found
}
// Check if contact is found
- /* NOISY-DEBUG: */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getSurname(), contact.getFamilyName(), this.size()));
+ /* NOISY-DEBUG: */ this.getLogger().debug(MessageFormat.format("Adding '{0}' '{1}' at pos '{2}' ...", contact.getSurname(), contact.getFamilyName(), this.size())); //NOI18N
// Add contact to internal list
this.addContact(contact);
// Add contact to internal list
this.addContact(contact);
*/
@Override
public final int size () {
*/
@Override
public final int size () {
- assert (this.contacts instanceof List) : "this.contacts is not initialized";
+ assert (this.contacts instanceof List) : "this.contacts is not initialized"; //NOI18N
return this.contacts.size();
}
return this.contacts.size();
}
* Fills the column names array with strings from bundle
*/
private void fillColumnNamesFromBundle () {
* Fills the column names array with strings from bundle
*/
private void fillColumnNamesFromBundle () {
- assert (this.columnNames instanceof List) : "this.columnNames is not initialized";
+ assert (this.columnNames instanceof List) : "this.columnNames is not initialized"; //NOI18N
- this.getLogger().trace("CALLED!");
+ this.getLogger().trace("CALLED!"); //NOI18N
// First get an iterator from key set to iterate over
Iterator<String> iterator = this.getBundle().keySet().iterator();
// First get an iterator from key set to iterate over
Iterator<String> iterator = this.getBundle().keySet().iterator();
String key = iterator.next();
// Does the key start with ContactManager.columnName ?
String key = iterator.next();
// Does the key start with ContactManager.columnName ?
- if (key.startsWith("ContactManager.columnName")) {
+ if (key.startsWith("ContactManager.columnName")) { //NOI18N
// This is the wanted entry.
// This is the wanted entry.
- this.getLogger().debug(MessageFormat.format("key={0}", key));
+ this.getLogger().debug(MessageFormat.format("key={0}", key)); //NOI18N
// So add it
this.columnNames.add(this.getBundle().getString(key));
// So add it
this.columnNames.add(this.getBundle().getString(key));
- this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount()));
+ this.getLogger().trace(MessageFormat.format("getColumnCount()={0}: EXIT!", this.getColumnCount())); //NOI18N
}
/**
* Flushes all entries by calling database backend
*/
private void flush () {
}
/**
* Flushes all entries by calling database backend
*/
private void flush () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Flusgh all
this.getContactDatabase().flushAllContacts();
// Flusgh all
this.getContactDatabase().flushAllContacts();
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @return Contact instance or null
*/
private Contact getOwnContact () {
* @return Contact instance or null
*/
private Contact getOwnContact () {
- assert (this.contacts instanceof List) : "this.contacts is not initialized";
+ assert (this.contacts instanceof List) : "this.contacts is not initialized"; //NOI18N
+
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
// Now get it back from address book, first get an iterator
Iterator<Contact> iterator = this.contacts.iterator();
// Now get it back from address book, first get an iterator
Iterator<Contact> iterator = this.contacts.iterator();
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("contact={0} - EXIT!", contact)); //NOI18N
+
// Return instance or null
return contact;
}
// Return instance or null
return contact;
}
* @return TRUE if found, FALSE if not found
*/
private boolean isContactAlreadyAdded (final Contact checkContact) throws NullPointerException {
* @return TRUE if found, FALSE if not found
*/
private boolean isContactAlreadyAdded (final Contact checkContact) throws NullPointerException {
- assert (this.contacts instanceof List) : "this.contacts is not initialized";
+ assert (this.contacts instanceof List) : "this.contacts is not initialized"; //NOI18N
+
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("checkContact={0} - CALLED!", checkContact)); //NOI18N
+
+ // Contact instance must not be null
+ if (checkContact == null) {
+ // Abort here
+ throw new NullPointerException("checkContact is null");
+ }
// Default is not found
boolean isFound = false;
// Default is not found
boolean isFound = false;
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound)); //NOI18N
+
// Return result
return isFound;
}
// Return result
return isFound;
}
package org.mxchange.addressbook.manager.contact;
import java.util.List;
package org.mxchange.addressbook.manager.contact;
import java.util.List;
-import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.manager.Manageable;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.contact.Gender;
import org.mxchange.addressbook.manager.Manageable;
* of given Contact instance.
*
* @param contact Instance to change data
* of given Contact instance.
*
* @param contact Instance to change data
- * @param client Client instance to call back
- public void doChangeAddressData (final Contact contact, final Client client);
+ public void doChangeAddressData (final Contact contact);
/**
* The user can change name data, like gender, surname, family name and
* company name (if business contact).
*
* @param contact Instance to change data
/**
* The user can change name data, like gender, surname, family name and
* company name (if business contact).
*
* @param contact Instance to change data
- * @param client Client instance to call back
- public void doChangeNameData (final Contact contact, final Client client);
+ public void doChangeNameData (final Contact contact);
/**
* Let the user change other address
/**
* Let the user change other address
* The user can change other data, like phone numbers or comments.
*
* @param contact Instance to change data
* The user can change other data, like phone numbers or comments.
*
* @param contact Instance to change data
- * @param client Client instance to call back
- public void doChangeOtherData (final Contact contact, final Client client);
+ public void doChangeOtherData (final Contact contact);
/**
* Let the user change own data
/**
* Let the user change own data
*/
package org.mxchange.addressbook.menu;
*/
package org.mxchange.addressbook.menu;
+import java.text.MessageFormat;
import java.util.List;
import org.apache.logging.log4j.Logger;
import org.mxchange.addressbook.BaseFrameworkSystem;
import java.util.List;
import org.apache.logging.log4j.Logger;
import org.mxchange.addressbook.BaseFrameworkSystem;
// Get logger
Logger log = new AddressbookMenu().getLogger();
// Get logger
Logger log = new AddressbookMenu().getLogger();
+ // Trace call
+ log.trace(MessageFormat.format("menuList={0},menuType={1},client={2} - CALLED!", menuList, menuType, client)); //NOI18N
+
+ // Some instances must be set
+ if (menuList == null) {
+ // Abort here
+ throw new NullPointerException("menuList is null"); //NOI18N
+ } else if (client == null) {
+ // Abort here
+ throw new NullPointerException("contact is null"); //NOI18N
+ }
+
// Get list size
int size = menuList.size();
// Debug message
// Get list size
int size = menuList.size();
// Debug message
- log.debug("Adding menu for '" + menuType + "' (old size: '" + size + "') ...");
+ log.debug(MessageFormat.format("Adding menu for '{0}' (old size: '{1}') ...", menuType, size)); //NOI18N
// Depends on type
switch (menuType) {
// Depends on type
switch (menuType) {
- case "main": // Main menu
+ case "main": // Main menu //NOI18N
// Enter own data
menuList.add(client.getMenuItem('1', "Eigene Adresse anlegen"));
// Enter own data
menuList.add(client.getMenuItem('1', "Eigene Adresse anlegen"));
break;
default: // Not supported
break;
default: // Not supported
- log.error("Menu type '" + menuType + "' ont supported");
+ log.error(MessageFormat.format("Menu type '{0}' ont supported", menuType)); //NOI18N
*/
package org.mxchange.addressbook.menu;
*/
package org.mxchange.addressbook.menu;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
* @param client Client instance to call back
*/
public void show (final Client client) {
* @param client Client instance to call back
*/
public void show (final Client client) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
+
+ // Client must not be null
+ if (client == null) {
+ // Abort here
+ throw new NullPointerException("client is null"); //NOI18N
+ }
+
// Get values
Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
// Get values
Iterator<SelectableMenuItem> iterator = this.menuList.iterator();
// Show this item
item.show(client);
}
// Show this item
item.show(client);
}
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* @param client CLient to call back
*/
protected void initMenu (final String menuType, final Client client) {
* @param client CLient to call back
*/
protected void initMenu (final String menuType, final Client client) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
+
// Init menu list
this.menuList = new ArrayList<>(5);
// Init menu list
this.menuList = new ArrayList<>(5);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
while (iterator.hasNext()) {
// Get item
SelectableMenuItem item = iterator.next();
while (iterator.hasNext()) {
// Get item
SelectableMenuItem item = iterator.next();
- //* NOISY-DEBUG: */ logger.debug("item=" + item);
+ //* NOISY-DEBUG: */ logger.debug("item=" + item);
// Get access key from item and add it to the array
accessKeys[i] = item.getAccessKey();
// Get access key from item and add it to the array
accessKeys[i] = item.getAccessKey();
- //* NOISY-DEBUG: */ logger.debug("accessKeys[" + i + "]=" + accessKeys[i]);
+ //* NOISY-DEBUG: */ logger.debug("accessKeys[" + i + "]=" + accessKeys[i]);
// Increment counter
i++;
// Increment counter
i++;
*/
package org.mxchange.addressbook.menu.console;
*/
package org.mxchange.addressbook.menu.console;
+import java.text.MessageFormat;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.menu.AddressbookMenu;
import org.mxchange.addressbook.menu.BaseMenu;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.menu.AddressbookMenu;
import org.mxchange.addressbook.menu.BaseMenu;
* @param client CLient to call back
*/
public ConsoleMenu (final String menuType, final Client client) {
* @param client CLient to call back
*/
public ConsoleMenu (final String menuType, final Client client) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("menuType={0},client={1} - CALLED!", menuType, client)); //NOI18N
+
+ // Client must not be null
+ if (client == null) {
+ // Abort here
+ throw new NullPointerException("client is null");
+ }
+
+ // Init menu
this.initMenu(menuType, client);
// Add all items
this.initMenu(menuType, client);
// Add all items
*/
package org.mxchange.addressbook.menu.item.console;
*/
package org.mxchange.addressbook.menu.item.console;
+import java.text.MessageFormat;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.menu.item.BaseMenuItem;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.menu.item.BaseMenuItem;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
* @param text Text to show to user
*/
public ConsoleMenuItem (final char accessKey, final String text) {
* @param text Text to show to user
*/
public ConsoleMenuItem (final char accessKey, final String text) {
- this.accessKey = accessKey;
- this.text = text;
+ this.setAccessKey(accessKey);
+ this.setText(text);
@Override
public void show (final Client client) {
@Override
public void show (final Client client) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
+
+ // Client must not be null
+ if (client == null) {
+ // Abort here
+ throw new NullPointerException("client is null");
+ }
+
// Call-back client over menu
client.showEntry(this);
// Call-back client over menu
client.showEntry(this);
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
* Protected constructor
*/
protected BaseModel () {
* Protected constructor
*/
protected BaseModel () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
// Init listener list
this.eventListenerList = new EventListenerList();
}
// Init listener list
this.eventListenerList = new EventListenerList();
}
* @param listener Listener instance
*/
public void addListDataListener (final ListDataListener listener) {
* @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);
// 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
* @param listener Lister instance
*/
public void addTableModelListener (final TableModelListener listener) {
* @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);
// 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
* @param listener Listener instance
*/
public void removeListDataListener (final ListDataListener 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);
// 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
* @param listener Listener instance
*/
public void removeTableModelListener (final TableModelListener listener) {
* @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);
// 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
*/
package org.mxchange.addressbook.model.contact;
*/
package org.mxchange.addressbook.model.contact;
+import java.text.MessageFormat;
import javax.swing.table.TableModel;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.model.BaseModel;
import javax.swing.table.TableModel;
import org.mxchange.addressbook.client.Client;
import org.mxchange.addressbook.model.BaseModel;
// Parent super constructor
super();
// Parent super constructor
super();
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N
+
+ // Client must not be null
+ if (client == null) {
+ // Abort here
+ throw new NullPointerException("client is null"); //NOI18N
+ }
+
// Set client
this.setClient(client);
}
// Set client
this.setClient(client);
}