}
}
+ /**
+ * Log exception and abort program.
+ * <p>
+ * @param throwable Throwable
+ */
+ protected void abortProgramWithException (final Throwable throwable) {
+ // Log exception
+ this.logException(throwable);
+
+ // Abort here
+ System.exit(1);
+ }
+
/**
* Getter for logger instance
* <p>
protected void logException (final Throwable exception) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
-
- /**
- * Log exception and abort program.
- * <p>
- * @param throwable Throwable
- */
- protected void abortProgramWithException (final Throwable throwable) {
- // Log exception
- this.logException(throwable);
-
- // Abort here
- System.exit(1);
- }
}
}
/**
- * Bootstraps application
+ * Main method (entry point)
+ * <p>
+ * @param args the command line arguments
+ */
+ public static void main (String[] args) {
+ // Start application
+ new AddressbookApplication().start(args);
+ }
+
+ /**
+ * Getter for printable application name
+ * <p>
+ * @return A printable name
*/
+ public static String printableTitle () {
+ return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
+ }
+
@Override
public void doBootstrap () {
this.getLogger().logDebug("Initializing application ..."); //NOI18N
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Main loop of the application
- */
@Override
public void doMainLoop () throws MenuInitializationException {
// Get client and cast it
System.exit(0);
}
+ /**
+ * Enables console client by setting propper flag
+ */
+ private void enableConsoleClient () {
+ this.getLogger().logDebug("Enabling console client (may become optional client) ..."); //NOI18N
+ this.consoleClient = true;
+ this.guiClient = false;
+ }
+
+ /**
+ * Enables GUI client by setting propper flag
+ */
+ private void enableGuiClient () {
+ this.getLogger().logDebug("Enabling GUI client (may become new default client) ..."); //NOI18N
+ this.consoleClient = false;
+ this.guiClient = true;
+ }
+
/**
* Initializes this application
*/
}
}
- /**
- * Logs given exception
- *
- * @param exception Throwable
- */
- protected void logException (final Throwable exception) {
- this.getLogger().logException(exception);
- }
-
/**
* Initializes properties
*/
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
- /**
- * Log exception and abort program.
- *
- * @param throwable Throwable
- */
- protected void abortProgramWithException (final Throwable throwable) {
- // Log exception
- this.logException(throwable);
-
- // Abort here
- System.exit(1);
- }
-
- /**
- * Enables console client by setting propper flag
- */
- private void enableConsoleClient () {
- this.getLogger().logDebug("Enabling console client (may become optional client) ..."); //NOI18N
- this.consoleClient = true;
- this.guiClient = false;
- }
-
- /**
- * Enables GUI client by setting propper flag
- */
- private void enableGuiClient () {
- this.getLogger().logDebug("Enabling GUI client (may become new default client) ..."); //NOI18N
- this.consoleClient = false;
- this.guiClient = true;
- }
-
/**
* Checks whether the client shoule be console client should be launched by
* checking if -console is set.
}
/**
- * Main method (entry point)
+ * Log exception and abort program.
* <p>
- * @param args the command line arguments
+ * @param throwable Throwable
*/
- public static void main (String[] args) {
- // Start application
- new AddressbookApplication().start(args);
+ protected void abortProgramWithException (final Throwable throwable) {
+ // Log exception
+ this.logException(throwable);
+
+ // Abort here
+ System.exit(1);
}
/**
- * Getter for printable application name
+ * Getter for logger instance
* <p>
- * @return A printable name
+ * @return Logger instance
*/
- public static String printableTitle () {
- return MessageFormat.format("{0} v{1}", APP_TITLE, APP_VERSION); //NOI18N
+ protected LoggerBeanLocal getLogger () {
+ return this.logger;
}
/**
- * Getter for logger instance
- *
- * @return Logger instance
+ * Logs given exception
+ * <p>
+ * @param exception Throwable
*/
- protected LoggerBeanLocal getLogger () {
- return this.logger;
+ protected void logException (final Throwable exception) {
+ this.getLogger().logException(exception);
}
+
}
*/
package org.mxchange.addressbook.client;
-import org.mxchange.jcore.exceptions.MenuInitializationException;
import org.mxchange.addressbook.menu.item.SelectableMenuItem;
import org.mxchange.jcore.client.Client;
+import org.mxchange.jcore.exceptions.MenuInitializationException;
import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
import org.mxchange.jcore.model.contact.Contact;
import org.mxchange.jcore.model.contact.gender.Gender;
public interface AddressbookClient extends Client {
/**
- * The user changes own name data
+ * The user changes own address data
* <p>
- * @param contact
+ * @param contact Contact instance to change
*/
- public void doChangeOwnNameData (final Contact contact);
+ public void doChangeOwnAddressData (final Contact contact);
/**
- * The user changes own address data
+ * The user changes own name data
* <p>
- * @param contact Contact instance to change
+ * @param contact
*/
- public void doChangeOwnAddressData (final Contact contact);
+ public void doChangeOwnNameData (final Contact contact);
/**
* The user changes own other data
*/
public Contact doEnterOwnData ();
- /**
- * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
- * <p>
- * @param message Message to output
- * @return Gender enum
- */
- public Gender enterGender (final String message);
-
- /**
- * Let the user choose what to change on the address: [n]ame, [a]ddress,
- * [o]ther
- * <p>
- * @param contact Contact instance to let the user change data
- * @throws UnhandledUserChoiceException If choice is not supported
- */
- public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
-
/**
* Asks the user for a choice and proceeds accordingly
* <p>
public char enterChar (final char[] validChars, final String message);
/**
- * Reads a string of minimum and maximum length from the user. An empty
- * string should be generally not allowed, but might be okay for e.g.
- * company name.
+ * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
* <p>
- * @param minLength Minimum length of the string to read
- * @param maxLength Maximum length of the string to read
- * @param message Message to user
- * @param allowEmpty Whether empty strings are allowed
- * @return Entered string by user or null if empty string is allowed
+ * @param message Message to output
+ * @return Gender enum
*/
- public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
+ public Gender enterGender (final String message);
/**
* Reads an integer (int) from the user
*/
public int enterInt (final int minimum, final int maximum, final String message);
+ /**
+ * Reads a string of minimum and maximum length from the user. An empty
+ * string should be generally not allowed, but might be okay for e.g.
+ * company name.
+ * <p>
+ * @param minLength Minimum length of the string to read
+ * @param maxLength Maximum length of the string to read
+ * @param message Message to user
+ * @param allowEmpty Whether empty strings are allowed
+ * @return Entered string by user or null if empty string is allowed
+ */
+ public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
+
/**
* Setter for current menu choice
* <p>
*/
public SelectableMenuItem getMenuItem (final char accessKey, final String text);
+ /**
+ * Shows current menu selection to the user
+ */
+ public void showCurrentMenu ();
+
/**
* Shows given menu entry in client
* <p>
public void showEntry (final SelectableMenuItem item);
/**
- * Shows current menu selection to the user
+ * Let the user choose what to change on the address: [n]ame, [a]ddress,
+ * [o]ther
+ * <p>
+ * @param contact Contact instance to let the user change data
+ * @throws UnhandledUserChoiceException If choice is not supported
*/
- public void showCurrentMenu ();
+ public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
}
*/
private String currentMenu;
- /**
- * Menu system
- */
- private final Map<String, Menu> menus;
-
/**
* Logger instance
*/
@Log
private LoggerBeanLocal logger;
+ /**
+ * Menu system
+ */
+ private final Map<String, Menu> menus;
+
/**
* No instances can be created of this class
*/
return menu;
}
+ /**
+ * Logs exception and exits program
+ * <p>
+ * @param throwable Throwable
+ */
+ protected void abortProgramWithException (final Throwable throwable) {
+ // Log exception
+ this.logException(throwable);
+
+ // Abort here
+ System.exit(1);
+ }
+
/**
* Fills menu map with swing menus
*/
protected abstract void fillMenuMap ();
+ /**
+ * Getter for logger instance
+ * <p>
+ * @return Logger instance
+ */
+ protected LoggerBeanLocal getLogger () {
+ return this.logger;
+ }
+
/**
* Getter for menus map
* <p>
this.getLogger().logTrace("EXIT!"); //NOI18N
}
+ /**
+ * Logs an exception
+ * <p>
+ * @param throwable Throwable
+ */
+ protected void logException (final Throwable throwable) {
+ // Deligate to logger
+ this.getLogger().logException(throwable);
+ }
+
/**
* Shows given menu
* <p>
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
-
- /**
- * Getter for logger instance
- *
- * @return Logger instance
- */
- protected LoggerBeanLocal getLogger () {
- return this.logger;
- }
-
- /**
- * Logs an exception
- *
- * @param throwable Throwable
- */
- protected void logException (final Throwable throwable) {
- // Deligate to logger
- this.getLogger().logException(throwable);
- }
-
- /**
- * Logs exception and exits program
- *
- * @param throwable Throwable
- */
- protected void abortProgramWithException (final Throwable throwable) {
- // Log exception
- this.logException(throwable);
-
- // Abort here
- System.exit(1);
- }
}
/**
* A Swing frame for addressbook.
- *
+ * <p>
* @author Roland Haeder
*/
public class AddressbookFrame extends BaseAddressbookSystem implements ClientFrame {
/**
* A swing client
- *
+ * <p>
* @author Roland Haeder
*/
public class SwingClient extends BaseAddressbookClient implements AddressbookClient {
*/
private final List<String> columnNames;
- /**
- * Translated column name list
- */
- private final List<String> translatedColumnNames;
-
/**
* Logger instance
*/
@Log
private LoggerBeanLocal logger;
+ /**
+ * Translated column name list
+ */
+ private final List<String> translatedColumnNames;
+
/**
* Constructor which accepts maxContacts for maximum (initial) contacts and
* a client instance.
//* NOISY-DEBUG: */ this.getLogger().logDebug("client=" + client);
}
- /**
- * Adds given Contact instance to list
- * <p>
- * @param contact Contact instance to add
- */
@Override
public void addContact (final Contact contact) throws ContactAlreadyAddedException {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Let the user add a new other address
- */
@Override
public void doAddOtherAddress () {
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
- /**
- * Let the user change address data
- * <p>
- * @param contact Instance to change data
- */
@Override
public void doChangeAddressData (final Contact contact) {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Let the user change "name data"
- * <p>
- * @param contact Instance to change data
- */
@Override
public void doChangeNameData (final Contact contact) {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Let the user change other address
- */
@Override
public void doChangeOtherAddress () {
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
- /**
- * Let the user change other data
- * <p>
- * @param contact Instance to change data TODO Didn't handle birthday
- */
@Override
public void doChangeOtherData (final Contact contact) {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Allows the user to change his/her own data
- */
@Override
public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Let the user delete other address
- */
@Override
public void doDeleteOtherAddress () {
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
- /**
- * Asks user for own data
- */
@Override
public void doEnterOwnData () throws ContactAlreadyAddedException, IOException {
// Trace message
throw new UnsupportedOperationException("Not supported yet."); //NOI18N
}
- /**
- * Shuts down this contact manager
- * <p>
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
- */
@Override
public void doShutdown () throws SQLException, IOException {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
- /**
- * Asks the user for his/her cellphone number
- * <p>
- * @return User's cellphone number
- */
@Override
public String enterOwnCellNumber () {
// Trace message
return client.enterString(5, 30, "Bitte geben Sie Ihre Handynummer an: ", true);
}
- /**
- * Asks the user for his/her city's name
- * <p>
- * @return City's name of the user
- */
@Override
public String enterOwnCity () {
// Trace message
return client.enterString(3, 50, "Bitte geben Sie Ihre Wohnort ein: ", false);
}
- /**
- * Asks the user for his/her city's name
- * <p>
- * @return City's name of the user
- */
@Override
public String enterOwnComment () {
// Trace message
return client.enterString(0, 100, "Kommentar zu Ihrem Eintrag: ", true);
}
- /**
- * Asks the user for his/her company name
- * <p>
- * @return User's company name
- */
@Override
public String enterOwnCompanyName () {
// Trace message
return client.enterString(5, 50, "Bitte geben Sie Ihre Firmenbezeichnung ein: ", true);
}
- /**
- * Asks user for his/her own country code
- * <p>
- * @return User's own country code
- */
@Override
public String enterOwnCountryCode () {
// Trace message
return client.enterString(2, 2, "Bitte geben Sie den zweistelligen Ländercode von Ihrem Land ein: ", false).toUpperCase();
}
- /**
- * Asks user for his/her own country code
- * <p>
- * @return User's own country code
- */
@Override
public String enterOwnEmailAddress () {
// Trace message
return client.enterString(10, 50, "Bitte geben Sie Ihre Email-Adresse ein: ", true);
}
- /**
- * Asks the user for family name
- * <p>
- * @return Family name of the user
- */
@Override
public String enterOwnFamilyName () {
// Trace message
return client.enterString(2, 50, "Bitte geben Sie Ihren Nachnamen ein: ", false);
}
- /**
- * Asks the user for family name
- * <p>
- * @return Family name of the user
- */
@Override
public String enterOwnFaxNumber () {
// Trace message
return client.enterString(5, 30, "Bitte geben Sie Ihre Faxnummer an: ", true);
}
- /**
- * Asks the user for surname
- * <p>
- * @return Surname of the user
- */
@Override
public String enterOwnFirstName () {
// Trace message
return client.enterString(2, 50, "Bitte geben Sie Ihren Vornamen ein: ", false);
}
- /**
- * Asks the user for gender, until a valid has been entered
- * <p>
- * @return Gender of the user
- */
@Override
public Gender enterOwnGender () {
// Trace message
return client.enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
}
- /**
- * Asks the user for phone number
- * <p>
- * @return Phone number of the user
- */
@Override
public String enterOwnPhoneNumber () {
// Trace message
return client.enterString(5, 30, "Bitte geben Sie Ihre Telefonnummer an: ", true);
}
- /**
- * Asks the user for own street (including number)
- * <p>
- * @return Own street an number
- */
@Override
public String enterOwnStreet () {
// Trace message
return client.enterString(5, 50, "Bitte geben Sie Ihre Strasse und Hausnummer ein: ", false);
}
- /**
- * Asks the user for own ZIP code
- * <p>
- * @return ZIP code
- */
@Override
public int enterOwnZipCode () {
// Trace message
return value;
}
- /**
- * Checks whether own contact is already added by checking all entries for
- * isOwnContact flag
- * <p>
- * @return Whether own contact is already added
- */
@Override
public boolean isOwnContactAdded () throws IOException {
// Trace message
return isAdded;
}
- /**
- * Logs given exception
- * <p>
- * @param exception Throwable
- */
- protected void logException (final Throwable exception) {
- this.getLogger().logException(exception);
- }
-
- /**
- * Adds given contact to address book and flushes all entries to database
- * <p>
- * @param contact Contact being added TODO Add check for book size
- */
@Override
public void registerContact (final Contact contact) {
// Trace message
// Return instance or null
return contact;
}
+
+ /**
+ * Logs given exception
+ * <p>
+ * @param exception Throwable
+ */
+ protected void logException (final Throwable exception) {
+ this.getLogger().logException(exception);
+ }
}
public interface ManageableContactAddressbook extends Manageable {
/**
- * Allows the user to enter own cellphone number.
+ * Adds given Contact instance to list
* <p>
- * @return Cellphone number
+ * @param contact Contact instance to add
+ * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added
*/
- public String enterOwnCellNumber ();
+ public void addContact (final Contact contact) throws ContactAlreadyAddedException;
/**
- * Allows the user to enter own city name.
- * <p>
- * @return City name
+ * Let the user add a new other address
*/
- public String enterOwnCity ();
+ public void doAddOtherAddress ();
/**
- * Allows the user to enter comment for own entry.
+ * The user can change address data, like street, ZIP code, city and country
+ * of given Contact instance.
* <p>
- * @return Comment
+ * @param contact Instance to change data
*/
- public String enterOwnComment ();
+ public void doChangeAddressData (final Contact contact);
/**
- * Allows the user to enter own company name.
+ * The user can change name data, like gender, surname, family name and
+ * company name (if business contact).
* <p>
- * @return Company name
+ * @param contact Instance to change data
*/
- public String enterOwnCompanyName ();
+ public void doChangeNameData (final Contact contact);
/**
- * Allows the user to enter own country code.
- * <p>
- * @return Country code
+ * Let the user change other address
*/
- public String enterOwnCountryCode ();
+ public void doChangeOtherAddress ();
/**
- * Allows the user to enter own email address.
+ * The user can change other data, like phone numbers or comments.
* <p>
- * @return Email address
+ * @param contact Instance to change data
*/
- public String enterOwnEmailAddress ();
+ public void doChangeOtherData (final Contact contact);
/**
- * Allows the user to enter own family name.
+ * Let the user change own data
* <p>
- * @return Family name
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.io.IOException If an IO error occurs
+ * @throws java.lang.NoSuchMethodException If a method cannot be found
+ * @throws java.lang.IllegalAccessException If a method is not accessible
+ * @throws java.lang.reflect.InvocationTargetException Any other problems?
*/
- public String enterOwnFamilyName ();
+ public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
/**
- * Allows the user to enter own fax number.
- * <p>
- * @return Fax number
+ * Let the user delete other address
*/
- public String enterOwnFaxNumber ();
+ public void doDeleteOtherAddress ();
/**
- * Allows the user to enter own gender.
+ * Asks user for own data
* <p>
- * @return Gender
+ * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException
+ * If own contact is already added
+ * @throws java.io.IOException If an IO error was found
*/
- public Gender enterOwnGender ();
+ public void doEnterOwnData () throws ContactAlreadyAddedException, IOException;
/**
- * Allows the user to enter own phone number.
- * <p>
- * @return Phone number
+ * List all contacts
*/
- public String enterOwnPhoneNumber ();
+ public void doListContacts ();
/**
- * Allows the user to enter own street and house number.
- * <p>
- * @return Street and house number
+ * Searches address book for a contact
*/
- public String enterOwnStreet ();
+ public void doSearchContacts ();
/**
- * Allows the user to enter own surname.
+ * Allows the user to enter own cellphone number.
* <p>
- * @return Surname
+ * @return Cellphone number
*/
- public String enterOwnFirstName ();
+ public String enterOwnCellNumber ();
/**
- * Allows the user to enter own ZIP code.
+ * Allows the user to enter own city name.
* <p>
- * @return ZIP code
+ * @return City name
*/
- public int enterOwnZipCode ();
+ public String enterOwnCity ();
/**
- * List all contacts
+ * Allows the user to enter comment for own entry.
+ * <p>
+ * @return Comment
*/
- public void doListContacts ();
+ public String enterOwnComment ();
/**
- * Adds given contact to address book
+ * Allows the user to enter own company name.
* <p>
- * @param contact Contact being added TODO Add check for book size
+ * @return Company name
*/
- public void registerContact (final Contact contact);
+ public String enterOwnCompanyName ();
/**
- * Adds given Contact instance to list
+ * Allows the user to enter own country code.
* <p>
- * @param contact Contact instance to add
- * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException
- * If the contact is already added
+ * @return Country code
*/
- public void addContact (final Contact contact) throws ContactAlreadyAddedException;
+ public String enterOwnCountryCode ();
/**
- * Let the user add a new other address
+ * Allows the user to enter own email address.
+ * <p>
+ * @return Email address
*/
- public void doAddOtherAddress ();
+ public String enterOwnEmailAddress ();
/**
- * The user can change address data, like street, ZIP code, city and country
- * of given Contact instance.
+ * Allows the user to enter own family name.
* <p>
- * @param contact Instance to change data
+ * @return Family name
*/
- public void doChangeAddressData (final Contact contact);
+ public String enterOwnFamilyName ();
/**
- * The user can change name data, like gender, surname, family name and
- * company name (if business contact).
+ * Allows the user to enter own fax number.
* <p>
- * @param contact Instance to change data
+ * @return Fax number
*/
- public void doChangeNameData (final Contact contact);
+ public String enterOwnFaxNumber ();
/**
- * Let the user change other address
+ * Allows the user to enter own surname.
+ * <p>
+ * @return Surname
*/
- public void doChangeOtherAddress ();
+ public String enterOwnFirstName ();
/**
- * The user can change other data, like phone numbers or comments.
+ * Allows the user to enter own gender.
* <p>
- * @param contact Instance to change data
+ * @return Gender
*/
- public void doChangeOtherData (final Contact contact);
+ public Gender enterOwnGender ();
/**
- * Let the user change own data
+ * Allows the user to enter own phone number.
* <p>
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
- * @throws java.lang.NoSuchMethodException If a method cannot be found
- * @throws java.lang.IllegalAccessException If a method is not accessible
- * @throws java.lang.reflect.InvocationTargetException Any other problems?
+ * @return Phone number
*/
- public void doChangeOwnData () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+ public String enterOwnPhoneNumber ();
/**
- * Let the user delete other address
+ * Allows the user to enter own street and house number.
+ * <p>
+ * @return Street and house number
*/
- public void doDeleteOtherAddress ();
+ public String enterOwnStreet ();
/**
- * Asks user for own data
+ * Allows the user to enter own ZIP code.
* <p>
- * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException
- * If own contact is already added
- * @throws java.io.IOException If an IO error was found
+ * @return ZIP code
*/
- public void doEnterOwnData () throws ContactAlreadyAddedException, IOException;
+ public int enterOwnZipCode ();
/**
- * Searches address book for a contact
+ * Getter for column count
+ * <p>
+ * @return Column count TODO: This is needed for TableModel in Swing
*/
- public void doSearchContacts ();
+ public int getColumnCount ();
/**
- * Checks whether own contact is already added by checking all entries for
- * isOwnContact flag
+ * Getter for column name at given index.
* <p>
- * @return Whether own contact is already added
- * @throws java.io.IOException If an IO error occurs
+ * @param columnIndex Column index
+ * @return Database column name TODO: This is needed for TableModel in Swing
*/
- public boolean isOwnContactAdded () throws IOException;
+ public String getColumnName (final int columnIndex);
/**
* Getter for translated column name at given index.
* @param columnIndex Column index
* @return Value from given row/column
* @throws java.lang.NoSuchMethodException If the method was not found
- * @throws java.lang.IllegalAccessException If the accessed method was not
- * public
+ * @throws java.lang.IllegalAccessException If the accessed method was not public
* @throws java.lang.reflect.InvocationTargetException Something else
* happened? TODO: This is needed for TableModel in Swing
*/
public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
/**
- * Getter for column name at given index.
+ * Checks whether own contact is already added by checking all entries for
+ * isOwnContact flag
* <p>
- * @param columnIndex Column index
- * @return Database column name TODO: This is needed for TableModel in Swing
+ * @return Whether own contact is already added
+ * @throws java.io.IOException If an IO error occurs
*/
- public String getColumnName (final int columnIndex);
+ public boolean isOwnContactAdded () throws IOException;
/**
- * Getter for column count
+ * Adds given contact to address book
* <p>
- * @return Column count TODO: This is needed for TableModel in Swing
+ * @param contact Contact being added TODO Add check for book size
*/
- public int getColumnCount ();
+ public void registerContact (final Contact contact);
}
/**
* A general menu class
- *
+ * <p>
* @author Roland Haeder
*/
-public abstract class BaseMenu extends BaseAddressbookSystem {
+public abstract class BaseMenu extends BaseAddressbookSystem implements Menu {
/**
* Menu list
protected BaseMenu () {
}
- /**
- * Size of menu items
- * <p>
- * @return Count of menu items
- */
+ @Override
public int getMenuItemsCount () {
return this.menuList.size();
}
- /**
- * "Getter" for an iterator of this menu's items
- * <p>
- * @return An iterator of all menu items
- */
+ @Override
public Iterator<SelectableMenuItem> getMenuItemsIterator () {
return this.menuList.iterator();
}
- /**
- * Shows this menu
- * <p>
- * @param client Client instance to call back
- */
+ @Override
public void show (final Client client) {
// Trace message
this.getLogger().logTrace(MessageFormat.format("client={0} CALLED!", client)); //NOI18N
*/
public interface Menu {
+ /**
+ * Size of all menu items
+ * <p>
+ * @return
+ */
+ public int getMenuItemsCount ();
+
/**
* "Getter" for an iterator on all menu items of the current menu
* <p>
* @param client Client instance
*/
public void show (final Client client);
-
- /**
- * Size of all menu items
- * <p>
- * @return
- */
- public int getMenuItemsCount ();
}
/**
* Menu utilities
- *
+ * <p>
* @author Roland Haeder
*/
public class MenuTools extends BaseAddressbookSystem {
import org.mxchange.jcore.client.Client;
/**
- *
+ * A menu system for the console
+ * <p>
* @author Roland Haeder
*/
public class ConsoleMenu extends BaseMenu implements Menu {
/**
* A general menu item class
- *
+ * <p>
* @author Roland Haeder
*/
-public class BaseMenuItem extends BaseAddressbookSystem {
+public abstract class BaseMenuItem extends BaseAddressbookSystem {
}
import org.mxchange.jcore.client.Client;
/**
- *
+ * A selectable menu item intereface
+ * <p>
* @author Roland Haeder
*/
public interface SelectableMenuItem extends FrameworkInterface {
- /**
- * Shows this menu item
- * <p>
- * @param client Client instance
- */
- public void show (final Client client);
-
/**
* Access key
* <p>
* @return the text
*/
public String getText ();
+
+ /**
+ * Shows this menu item
+ * <p>
+ * @param client Client instance
+ */
+ public void show (final Client client);
}
import org.mxchange.jcore.client.Client;
/**
- *
+ * A menu item class for the console
+ * <p>
* @author Roland Haeder
*/
public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {
this.setText(text);
}
- /**
- * Access key
- * <p>
- * @return the accessKey
- */
@Override
public final char getAccessKey () {
return this.accessKey;
}
- /**
- * Access key
- * <p>
- * @param accessKey the accessKey to set
- */
- private void setAccessKey (char accessKey) {
- this.accessKey = accessKey;
- }
-
- /**
- * Text to user
- * <p>
- * @return the text
- */
@Override
public String getText () {
return this.text;
}
- /**
- * Text to user
- * <p>
- * @param text the text to set
- */
- private void setText (String text) {
- this.text = text;
- }
-
@Override
public void show (final Client client) {
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
}
+ /**
+ * Text to user
+ * <p>
+ * @param text the text to set
+ */
+ private void setText (final String text) {
+ this.text = text;
+ }
+
+ /**
+ * Access key
+ * <p>
+ * @param accessKey the accessKey to set
+ */
+ private void setAccessKey (final char accessKey) {
+ this.accessKey = accessKey;
+ }
+
}