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.menu.item.SelectableMenuItem;
25 * An interface for application clients
27 * @author Roland Haeder
29 public interface Client extends FrameworkInterface {
32 * Displays a "box" for the address
34 * @param contact Contact to show address from
36 public void displayAddressBox (final Contact contact);
39 * The user changes own name data
42 public void doChangeOwnNameData (final Contact contact);
45 * The user changes own address data
47 * @param contact Contact instance to change
49 public void doChangeOwnAddressData (final Contact contact);
52 * The user changes own other data
54 * @param contact Constact instance to change
56 public void doChangeOwnOtherData (final Contact contact);
59 * Allows the user to enter own data
61 * @return Finished Contact instance
63 public Contact doEnterOwnData ();
66 * Shuts down the client and therefore whole application
68 public void doShutdown ();
71 * Displays a message to the user
73 * @param message Message to show to the user
75 public void outputMessage (final String message);
78 * Displays a "box" for the name
80 * @param contact Contact to show name from
82 public void displayNameBox (final Contact contact);
85 * Displays a "box" for other data
87 * @param contact Contact to show other data from
89 public void displayOtherDataBox (final Contact contact);
92 * Let the user choose what to change on the address: [n]ame, [a]ddress,
95 * @param contact Contact instance to let the user change data
96 * @throws UnhandledUserChoiceException If choice is not supported
98 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
101 * Asks the user for a choice and proceeds accordingly
103 * @throws UnhandledUserChoiceException If choice is not supported
105 public void doUserMenuChoice () throws UnhandledUserChoiceException ;
108 * Enables isRunning attribute which singals that the client is running
110 public void enableIsRunning();
113 * Asks the the user to enter a single character which must match validChars
115 * @param validChars Valid chars that are accepted
116 * @param message Message to user
117 * @return Allowed character
119 public char enterChar (final char[] validChars, final String message);
122 * Reads a string of minimum and maximum length from the user. An empty
123 * string should be generally not allowed, but might be okay for e.g.
126 * @param minLength Minimum length of the string to read
127 * @param maxLength Maximum length of the string to read
128 * @param message Message to user
129 * @param allowEmpty Whether empty strings are allowed
130 * @return Entered string by user or null if empty string is allowed
132 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
135 * Reads an integer (int) from the user
137 * @param minimum Minimum allowed number
138 * @param maximum Maximum allowed number
139 * @param message Message to user
140 * @return Entered string by user or null if empty string is allowed
142 public int enterInt (final int minimum, final int maximum, final String message);
145 * Setter for current menu choice
147 * @param currentMenu Current menu choice
149 public void setCurrentMenu (final String currentMenu);
152 * Some "Getter" for menu item
154 * @param accessKey Key to press to access this menu
155 * @param text Text to show to user
158 public SelectableMenuItem getMenuItem (final char accessKey, final String text);
161 * Determines whether the client is still active by checking some
164 * @return Whether the client is still active
166 public boolean isRunning();
169 * Shows given menu entry in client
171 * @param item Menu item to show
173 public void showEntry (final SelectableMenuItem item);
176 * Shows introduction to user
178 public void showWelcome();
181 * Shows current menu selection to the user
183 public void showCurrentMenu();
186 * Inizializes this client