2 * Copyright (C) 2015 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.FrameworkInterface;
20 import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
21 import org.mxchange.addressbook.contact.Contact;
22 import org.mxchange.addressbook.contact.Gender;
23 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
26 * An interface for application clients
28 * @author Roland Haeder
30 public interface Client extends FrameworkInterface {
33 * Displays a "box" for the address
35 * @param contact Contact to show address from
37 public void displayAddressBox (final Contact contact);
40 * The user changes own name data
44 public void doChangeOwnNameData (final Contact contact);
47 * The user changes own address data
49 * @param contact Contact instance to change
51 public void doChangeOwnAddressData (final Contact contact);
54 * The user changes own other data
56 * @param contact Constact instance to change
58 public void doChangeOwnOtherData (final Contact contact);
61 * Allows the user to enter own data
63 * @return Finished Contact instance
65 public Contact doEnterOwnData ();
68 * Shuts down the client and therefore whole application
70 public void doShutdown ();
73 * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
75 * @param message Message to output
78 public Gender enterGender (final String message);
81 * Displays a message to the user
83 * @param message Message to show to the user
85 public void outputMessage (final String message);
88 * Displays a "box" for the name
90 * @param contact Contact to show name from
92 public void displayNameBox (final Contact contact);
95 * Displays a "box" for other data
97 * @param contact Contact to show other data from
99 public void displayOtherDataBox (final Contact contact);
102 * Let the user choose what to change on the address: [n]ame, [a]ddress,
105 * @param contact Contact instance to let the user change data
106 * @throws UnhandledUserChoiceException If choice is not supported
108 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
111 * Asks the user for a choice and proceeds accordingly
113 * @throws UnhandledUserChoiceException If choice is not supported
115 public void doUserMenuChoice () throws UnhandledUserChoiceException;
118 * Enables isRunning attribute which singals that the client is running
120 public void enableIsRunning ();
123 * Asks the the user to enter a single character which must match validChars
125 * @param validChars Valid chars that are accepted
126 * @param message Message to user
127 * @return Allowed character
129 public char enterChar (final char[] validChars, final String message);
132 * Reads a string of minimum and maximum length from the user. An empty
133 * string should be generally not allowed, but might be okay for e.g.
136 * @param minLength Minimum length of the string to read
137 * @param maxLength Maximum length of the string to read
138 * @param message Message to user
139 * @param allowEmpty Whether empty strings are allowed
140 * @return Entered string by user or null if empty string is allowed
142 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
145 * Reads an integer (int) from the user
147 * @param minimum Minimum allowed number
148 * @param maximum Maximum allowed number
149 * @param message Message to user
150 * @return Entered string by user or null if empty string is allowed
152 public int enterInt (final int minimum, final int maximum, final String message);
155 * Setter for current menu choice
157 * @param currentMenu Current menu choice
159 public void setCurrentMenu (final String currentMenu);
162 * Some "Getter" for menu item
164 * @param accessKey Key to press to access this menu
165 * @param text Text to show to user
168 public SelectableMenuItem getMenuItem (final char accessKey, final String text);
171 * Determines whether the client is still active by checking some conditions
173 * @return Whether the client is still active
175 public boolean isRunning ();
178 * Shows given menu entry in client
180 * @param item Menu item to show
182 public void showEntry (final SelectableMenuItem item);
185 * Shows introduction to user
187 public void showWelcome ();
190 * Shows current menu selection to the user
192 public void showCurrentMenu ();
195 * Inizializes this client