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
43 public void doChangeOwnNameData (final Contact contact);
46 * The user changes own address data
48 * @param contact Contact instance to change
50 public void doChangeOwnAddressData (final Contact contact);
53 * The user changes own other data
55 * @param contact Constact instance to change
57 public void doChangeOwnOtherData (final Contact contact);
60 * Allows the user to enter own data
62 * @return Finished Contact instance
64 public Contact doEnterOwnData ();
67 * Shuts down the client and therefore whole application
69 public void doShutdown ();
72 * Displays a message to the user
74 * @param message Message to show to the user
76 public void outputMessage (final String message);
79 * Displays a "box" for the name
81 * @param contact Contact to show name from
83 public void displayNameBox (final Contact contact);
86 * Displays a "box" for other data
88 * @param contact Contact to show other data from
90 public void displayOtherDataBox (final Contact contact);
93 * Let the user choose what to change on the address: [n]ame, [a]ddress,
96 * @param contact Contact instance to let the user change data
97 * @throws UnhandledUserChoiceException If choice is not supported
99 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
102 * Asks the user for a choice and proceeds accordingly
104 * @throws UnhandledUserChoiceException If choice is not supported
106 public void doUserMenuChoice () throws UnhandledUserChoiceException;
109 * Enables isRunning attribute which singals that the client is running
111 public void enableIsRunning ();
114 * Asks the the user to enter a single character which must match validChars
116 * @param validChars Valid chars that are accepted
117 * @param message Message to user
118 * @return Allowed character
120 public char enterChar (final char[] validChars, final String message);
123 * Reads a string of minimum and maximum length from the user. An empty
124 * string should be generally not allowed, but might be okay for e.g.
127 * @param minLength Minimum length of the string to read
128 * @param maxLength Maximum length of the string to read
129 * @param message Message to user
130 * @param allowEmpty Whether empty strings are allowed
131 * @return Entered string by user or null if empty string is allowed
133 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
136 * Reads an integer (int) from the user
138 * @param minimum Minimum allowed number
139 * @param maximum Maximum allowed number
140 * @param message Message to user
141 * @return Entered string by user or null if empty string is allowed
143 public int enterInt (final int minimum, final int maximum, final String message);
146 * Setter for current menu choice
148 * @param currentMenu Current menu choice
150 public void setCurrentMenu (final String currentMenu);
153 * Some "Getter" for menu item
155 * @param accessKey Key to press to access this menu
156 * @param text Text to show to user
159 public SelectableMenuItem getMenuItem (final char accessKey, final String text);
162 * Determines whether the client is still active by checking some conditions
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