*/
public static final String APP_VERSION = "0.0"; //NOI18N
+ /**
+ * 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
+ }
+
/**
* Console client is enabled by default
*/
this.init();
}
- /**
- * 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
private void parseArguments (final String[] args) {
// Trace message
this.getLogger().logTrace(MessageFormat.format("args()={0} - CALLED!", args.length)); //NOI18N
-
// Debug message
this.getLogger().logDebug(MessageFormat.format("Parsing {0} arguments ...", args.length)); //NOI18N
-
for (final String arg : args) {
// Switch on it
switch (arg) {
- case "-console": //NOI18N
- enableConsoleClient();
+ case "-console":
+ //NOI18N
+ this.enableConsoleClient();
break;
-
- case "-gui": //NOI18N
- enableGuiClient();
+ case "-gui":
+ //NOI18N
+ this.enableGuiClient();
break;
}
}
this.getLogger().logException(exception);
}
+
}
* <p>
* @param contact Contact to show address from
*/
- public void displayAddressBox (final Contact contact);
+ void displayAddressBox (final Contact contact);
/**
* Displays a "box" for the name
* <p>
* @param contact Contact to show name from
*/
- public void displayNameBox (final Contact contact);
+ void displayNameBox (final Contact contact);
/**
* Displays a "box" for other data
* <p>
* @param contact Contact to show other data from
*/
- public void displayOtherDataBox (final Contact contact);
+ void displayOtherDataBox (final Contact contact);
/**
* Shows given contact instamce
* <p>
* @param contact Contact instance
*/
- public void show (final Contact contact);
+ void show (final Contact contact);
/**
* The user changes own address data
* <p>
* @param contact Contact instance to change
*/
- public void doChangeOwnAddressData (final Contact contact);
+ void doChangeOwnAddressData (final Contact contact);
/**
* The user changes own name data
* <p>
* @param contact
*/
- public void doChangeOwnNameData (final Contact contact);
+ void doChangeOwnNameData (final Contact contact);
/**
* The user changes own other data
* <p>
* @param contact Constact instance to change
*/
- public void doChangeOwnOtherData (final Contact contact);
+ void doChangeOwnOtherData (final Contact contact);
/**
* Allows the user to enter own data
* <p>
* @return Finished Contact instance
*/
- public Contact doEnterOwnData ();
+ Contact doEnterOwnData ();
/**
* Asks the user for a choice and proceeds accordingly
* @throws org.mxchange.jcore.exceptions.MenuInitializationException If the
* menu cannot be initialized
*/
- public void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
+ void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
/**
* Asks the the user to enter a single character which must match validChars
* <p>
* @return Allowed character
*/
- public char enterChar (final char[] validChars, final String message);
+ char enterChar (final char[] validChars, final String message);
/**
* Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
* <p>
* @return Gender enum
*/
- public Gender enterGender (final String message);
+ Gender enterGender (final String message);
/**
* Reads an integer (int) from the user
* <p>
* @return Entered string by user or null if empty string is allowed
*/
- public int enterInt (final int minimum, final int maximum, final String message);
+ int enterInt (final int minimum, final int maximum, final String message);
/**
* Reads a string of minimum and maximum length from the user. An empty
* <p>
* @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);
+ String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
/**
* Setter for current menu choice
* <p>
* @param currentMenu Current menu choice
*/
- public void setCurrentMenu (final String currentMenu);
+ void setCurrentMenu (final String currentMenu);
/**
* Some "Getter" for menu item
* <p>
* @return
*/
- public SelectableMenuItem getMenuItem (final char accessKey, final String text);
+ SelectableMenuItem getMenuItem (final char accessKey, final String text);
/**
* Shows current menu selection to the user
*/
- public void showCurrentMenu ();
+ void showCurrentMenu ();
/**
* Shows given menu entry in client
* <p>
* @param item Menu item to show
*/
- public void showEntry (final SelectableMenuItem item);
+ void showEntry (final SelectableMenuItem item);
/**
* Let the user choose what to change on the address: [n]ame, [a]ddress,
* <p>
* @throws UnhandledUserChoiceException If choice is not supported
*/
- public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
+ void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
}
import java.sql.SQLException;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.naming.Context;
* <p>
* @return the currentMenu
*/
- public final String getCurrentMenu () {
+ public String getCurrentMenu () {
return this.currentMenu;
}
@Override
- public final void setCurrentMenu (final String currentMenu) {
+ public void setCurrentMenu (final String currentMenu) {
this.currentMenu = currentMenu;
}
* <p>
* @return Map of all menus
*/
- protected final Map<String, Menu> getMenus () {
- return this.menus;
+ protected Map<String, Menu> getMenus () {
+ return Collections.unmodifiableMap(this.menus);
}
/**
}
@Override
- protected final void fillMenuMap () {
+ protected void fillMenuMap () {
// Trace message
this.getLogger().logTrace("CALLED!"); //NOI18N
* <p>
* @return Returns a singelton instance of this frame
*/
- public static final ClientFrame getSelfInstance (final Client client) {
+ public static ClientFrame getSelfInstance (final Client client) {
// Is it set?
if (!(self instanceof ClientFrame)) {
// Create new instance
* @return Field isInitialized
*/
@Override
- public final boolean isInitialized () {
+ public boolean isInitialized () {
return this.initialized;
}
// Init 3 panels:
// 1) "name" panel
- initNameDataPanel(this.addContact);
+ this.initNameDataPanel(this.addContact);
// 2) "address" panel
- initAddressDataPanel(this.addContact);
+ this.initAddressDataPanel(this.addContact);
// 3) "other" panel
- initOtherDataPanel(this.addContact);
+ this.initOtherDataPanel(this.addContact);
// 4) "Add" and "Cancel" buttons, combined they are unique for this dialog
- initAddCancelButtons();
+ this.initAddCancelButtons();
// x)Only for developing:
/*
// Init other windows:
// 1) Add contact
- initAddContactDialog();
+ this.initAddContactDialog();
// Trace message
this.getLogger().logTrace("EXIT!"); //NOI18N
* Fills menu map with swing menus
*/
@Override
- protected final void fillMenuMap () {
+ protected void fillMenuMap () {
// Nothing to fill here as the Swing frame is handling this all
throw new UnsupportedOperationException("Not implemented."); //NOI18N
}
* @throws org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException If
* the contact is already added
*/
- public void addContact (final Contact contact) throws ContactAlreadyAddedException;
+ void addContact (final Contact contact) throws ContactAlreadyAddedException;
/**
* Let the user add a new other address
*/
- public void doAddOtherAddress ();
+ void doAddOtherAddress ();
/**
* The user can change address data, like street, ZIP code, city and country
* <p>
* @param contact Instance to change data
*/
- public void doChangeAddressData (final Contact contact);
+ void doChangeAddressData (final Contact contact);
/**
* The user can change name data, like gender, surname, family name and
* <p>
* @param contact Instance to change data
*/
- public void doChangeNameData (final Contact contact);
+ void doChangeNameData (final Contact contact);
/**
* Let the user change other address
*/
- public void doChangeOtherAddress ();
+ void doChangeOtherAddress ();
/**
* The user can change other data, like phone numbers or comments.
* <p>
* @param contact Instance to change data
*/
- public void doChangeOtherData (final Contact contact);
+ void doChangeOtherData (final Contact contact);
/**
* Let the user change own data
* <p>
*/
- public void doChangeOwnData ();
+ void doChangeOwnData ();
/**
* Let the user delete other address
*/
- public void doDeleteOtherAddress ();
+ void doDeleteOtherAddress ();
/**
* Asks user for own data
* <p>
* @throws org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException If
* own contact is already added
- * @throws java.io.IOException If an IO error was found
*/
- public void doEnterOwnData () throws ContactAlreadyAddedException;
+ void doEnterOwnData () throws ContactAlreadyAddedException;
/**
* List all contacts
*/
- public void doListContacts ();
+ void doListContacts ();
/**
* Searches address book for a contact
*/
- public void doSearchContacts ();
+ void doSearchContacts ();
/**
* Allows the user to enter own cellphone number.
* <p>
* @return Cellphone number
*/
- public DialableCellphoneNumber enterOwnCellNumber ();
+ DialableCellphoneNumber enterOwnCellNumber ();
/**
* Allows the user to enter own city name.
* <p>
* @return City name
*/
- public String enterOwnCity ();
+ String enterOwnCity ();
/**
* Allows the user to enter comment for own entry.
* <p>
* @return Comment
*/
- public String enterOwnComment ();
+ String enterOwnComment ();
/**
* Allows the user to enter own company name.
* <p>
* @return Company name
*/
- public String enterOwnCompanyName ();
+ String enterOwnCompanyName ();
/**
* Allows the user to enter own country code.
* <p>
* @return Country code
*/
- public Country enterOwnCountryCode ();
+ Country enterOwnCountryCode ();
/**
* Allows the user to enter own email address.
* <p>
* @return Email address
*/
- public String enterOwnEmailAddress ();
+ String enterOwnEmailAddress ();
/**
* Allows the user to enter own family name.
* <p>
* @return Family name
*/
- public String enterOwnFamilyName ();
+ String enterOwnFamilyName ();
/**
* Allows the user to enter own fax number.
* <p>
* @return Fax number
*/
- public DialableFaxNumber enterOwnFaxNumber ();
+ DialableFaxNumber enterOwnFaxNumber ();
/**
* Allows the user to enter own surname.
* <p>
* @return Surname
*/
- public String enterOwnFirstName ();
+ String enterOwnFirstName ();
/**
* Allows the user to enter own gender.
* <p>
* @return Gender
*/
- public Gender enterOwnGender ();
+ Gender enterOwnGender ();
/**
* Allows the user to enter own phone number.
* <p>
* @return Phone number
*/
- public DialableLandLineNumber enterOwnPhoneNumber ();
+ DialableLandLineNumber enterOwnPhoneNumber ();
/**
* Allows the user to enter own street and house number.
* <p>
* @return Street and house number
*/
- public String enterOwnStreet ();
+ String enterOwnStreet ();
/**
* Allows the user to enter own ZIP code.
* <p>
* @return ZIP code
*/
- public int enterOwnZipCode ();
+ int enterOwnZipCode ();
/**
* Getter for column count
* <p>
* @return Column count TODO: This is needed for TableModel in Swing
*/
- public int getColumnCount ();
+ int getColumnCount ();
/**
* Getter for column name at given index.
* <p>
* @return Database column name TODO: This is needed for TableModel in Swing
*/
- public String getColumnName (final int columnIndex);
+ String getColumnName (final int columnIndex);
/**
* Getter for translated column name at given index.
* @return Human-readable column name TODO: This is needed for TableModel in
* Swing
*/
- public String getTranslatedColumnName (final int columnIndex);
+ String getTranslatedColumnName (final int columnIndex);
/**
* Somewhat "getter" for value from given row and column index
* <p>
* @return Value from given row/column
*/
- public Object getValueFromRowColumn (final int rowIndex, final int columnIndex);
+ Object getValueFromRowColumn (final int rowIndex, final int columnIndex);
/**
* Checks whether own contact is already added by checking all entries for
* <p>
* @throws java.io.IOException If an IO error occurs
*/
- public boolean isOwnContactAdded () throws IOException;
+ boolean isOwnContactAdded () throws IOException;
/**
* Adds given contact to address book
* <p>
* @param contact Contact being added TODO Add check for book size
*/
- public void registerContact (final Contact contact);
+ void registerContact (final Contact contact);
}
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.mxchange.addressbook.BaseAddressbookSystem;
* <p>
* @return menuList List of menu entries
*/
- protected final List<SelectableMenuItem> getMenuList () {
- return this.menuList;
+ protected List<SelectableMenuItem> getMenuList () {
+ return Collections.unmodifiableList(this.menuList);
}
/**
* <p>
* @return
*/
- public int getMenuItemsCount ();
+ int getMenuItemsCount ();
/**
* "Getter" for an iterator on all menu items of the current menu
* <p>
* @return Iterator on all menu items
*/
- public Iterator<SelectableMenuItem> getMenuItemsIterator ();
+ Iterator<SelectableMenuItem> getMenuItemsIterator ();
/**
* Shows this menu
* <p>
* @param client Client instance
*/
- public void show (final Client client);
+ void show (final Client client);
}
* <p>
* @return the accessKey
*/
- public char getAccessKey ();
+ char getAccessKey ();
/**
* Text to user
* <p>
* @return the text
*/
- public String getText ();
+ String getText ();
/**
* Shows this menu item
* <p>
* @param client Client instance
*/
- public void show (final Client client);
+ void show (final Client client);
}
}
@Override
- public final char getAccessKey () {
+ public char getAccessKey () {
return this.accessKey;
}
+ /**
+ * Access key
+ * <p>
+ * @param accessKey the accessKey to set
+ */
+ private void setAccessKey (final char accessKey) {
+ this.accessKey = accessKey;
+ }
+
@Override
public String getText () {
return this.text;
}
+ /**
+ * Text to user
+ * <p>
+ * @param text the text to set
+ */
+ private void setText (final 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;
- }
-
}