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.menu.item.SelectableMenuItem;
20 import org.mxchange.jcore.client.Client;
21 import org.mxchange.jcore.contact.Contact;
22 import org.mxchange.jcore.contact.gender.Gender;
23 import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
26 * A special client interface for addressbook applications.
28 * @author Roland Haeder
30 public interface AddressbookClient extends Client {
33 * The user changes own name data
37 public void doChangeOwnNameData (final Contact contact);
40 * The user changes own address data
42 * @param contact Contact instance to change
44 public void doChangeOwnAddressData (final Contact contact);
47 * The user changes own other data
49 * @param contact Constact instance to change
51 public void doChangeOwnOtherData (final Contact contact);
54 * Allows the user to enter own data
56 * @return Finished Contact instance
58 public Contact doEnterOwnData ();
61 * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
63 * @param message Message to output
66 public Gender enterGender (final String message);
69 * Let the user choose what to change on the address: [n]ame, [a]ddress,
72 * @param contact Contact instance to let the user change data
73 * @throws UnhandledUserChoiceException If choice is not supported
75 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
78 * Asks the user for a choice and proceeds accordingly
80 * @throws UnhandledUserChoiceException If choice is not supported
82 public void doUserMenuChoice () throws UnhandledUserChoiceException;
85 * Asks the the user to enter a single character which must match validChars
87 * @param validChars Valid chars that are accepted
88 * @param message Message to user
89 * @return Allowed character
91 public char enterChar (final char[] validChars, final String message);
94 * Reads a string of minimum and maximum length from the user. An empty
95 * string should be generally not allowed, but might be okay for e.g.
98 * @param minLength Minimum length of the string to read
99 * @param maxLength Maximum length of the string to read
100 * @param message Message to user
101 * @param allowEmpty Whether empty strings are allowed
102 * @return Entered string by user or null if empty string is allowed
104 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
107 * Reads an integer (int) from the user
109 * @param minimum Minimum allowed number
110 * @param maximum Maximum allowed number
111 * @param message Message to user
112 * @return Entered string by user or null if empty string is allowed
114 public int enterInt (final int minimum, final int maximum, final String message);
117 * Setter for current menu choice
119 * @param currentMenu Current menu choice
121 public void setCurrentMenu (final String currentMenu);
124 * Some "Getter" for menu item
126 * @param accessKey Key to press to access this menu
127 * @param text Text to show to user
130 public SelectableMenuItem getMenuItem (final char accessKey, final String text);
133 * Shows given menu entry in client
135 * @param item Menu item to show
137 public void showEntry (final SelectableMenuItem item);
140 * Shows current menu selection to the user
142 public void showCurrentMenu ();