2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.client;
19 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
20 import org.mxchange.jcontacts.contact.Contact;
21 import org.mxchange.jcontacts.contact.gender.Gender;
22 import org.mxchange.jcore.client.Client;
23 import org.mxchange.jcore.exceptions.MenuInitializationException;
24 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
27 * A special client interface for addressbook applications.
29 * @author Roland Haeder<roland@mxchange.org>
31 public interface AddressbookClient extends Client {
34 * Displays a "box" for the address
36 * @param contact Contact to show address from
38 void displayAddressBox (final Contact contact);
41 * Displays a "box" for the name
43 * @param contact Contact to show name from
45 void displayNameBox (final Contact contact);
48 * Displays a "box" for other data
50 * @param contact Contact to show other data from
52 void displayOtherDataBox (final Contact contact);
55 * Shows given contact instamce
57 * @param contact Contact instance
59 void show (final Contact contact);
62 * The user changes own address data
64 * @param contact Contact instance to change
66 void doChangeOwnAddressData (final Contact contact);
69 * The user changes own name data
73 void doChangeOwnNameData (final Contact contact);
76 * The user changes own other data
78 * @param contact Constact instance to change
80 void doChangeOwnOtherData (final Contact contact);
83 * Allows the user to enter own data
85 * @return Finished Contact instance
87 Contact doEnterOwnData ();
90 * Asks the user for a choice and proceeds accordingly
92 * @throws UnhandledUserChoiceException If choice is not supported
93 * @throws org.mxchange.jcore.exceptions.MenuInitializationException If the
94 * menu cannot be initialized
96 void doUserMenuChoice () throws UnhandledUserChoiceException, MenuInitializationException;
99 * Asks the the user to enter a single character which must match validChars
101 * @param validChars Valid chars that are accepted
102 * @param message Message to user
104 * @return Allowed character
106 char enterChar (final char[] validChars, final String message);
109 * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
111 * @param message Message to output
113 * @return Gender enum
115 Gender enterGender (final String message);
118 * Reads an integer (int) from the user
120 * @param minimum Minimum allowed number
121 * @param maximum Maximum allowed number
122 * @param message Message to user
124 * @return Entered string by user or null if empty string is allowed
126 int enterInt (final int minimum, final int maximum, final String message);
129 * Reads a string of minimum and maximum length from the user. An empty
130 * string should be generally not allowed, but might be okay for e.g.
133 * @param minLength Minimum length of the string to read
134 * @param maxLength Maximum length of the string to read
135 * @param message Message to user
136 * @param allowEmpty Whether empty strings are allowed
138 * @return Entered string by user or null if empty string is allowed
140 String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
143 * Setter for current menu choice
145 * @param currentMenu Current menu choice
147 void setCurrentMenu (final String currentMenu);
150 * Some "Getter" for menu item
152 * @param accessKey Key to press to access this menu
153 * @param text Text to show to user
157 SelectableMenuItem getMenuItem (final char accessKey, final String text);
160 * Shows current menu selection to the user
162 void showCurrentMenu ();
165 * Shows given menu entry in client
167 * @param item Menu item to show
169 void showEntry (final SelectableMenuItem item);
172 * Let the user choose what to change on the address: [n]ame, [a]ddress,
175 * @param contact Contact instance to let the user change data
177 * @throws UnhandledUserChoiceException If choice is not supported
179 void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;