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.contact.Contact;
20 import org.mxchange.addressbook.contact.Gender;
21 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
22 import org.mxchange.jcore.client.Client;
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 * 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 * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
70 * @param message Message to output
73 public Gender enterGender (final String message);
76 * Displays a "box" for the name
78 * @param contact Contact to show name from
80 public void displayNameBox (final Contact contact);
83 * Displays a "box" for other data
85 * @param contact Contact to show other data from
87 public void displayOtherDataBox (final Contact contact);
90 * Let the user choose what to change on the address: [n]ame, [a]ddress,
93 * @param contact Contact instance to let the user change data
94 * @throws UnhandledUserChoiceException If choice is not supported
96 public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
99 * Asks the user for a choice and proceeds accordingly
101 * @throws UnhandledUserChoiceException If choice is not supported
103 public void doUserMenuChoice () throws UnhandledUserChoiceException;
106 * Asks the the user to enter a single character which must match validChars
108 * @param validChars Valid chars that are accepted
109 * @param message Message to user
110 * @return Allowed character
112 public char enterChar (final char[] validChars, final String message);
115 * Reads a string of minimum and maximum length from the user. An empty
116 * string should be generally not allowed, but might be okay for e.g.
119 * @param minLength Minimum length of the string to read
120 * @param maxLength Maximum length of the string to read
121 * @param message Message to user
122 * @param allowEmpty Whether empty strings are allowed
123 * @return Entered string by user or null if empty string is allowed
125 public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
128 * Reads an integer (int) from the user
130 * @param minimum Minimum allowed number
131 * @param maximum Maximum allowed number
132 * @param message Message to user
133 * @return Entered string by user or null if empty string is allowed
135 public int enterInt (final int minimum, final int maximum, final String message);
138 * Setter for current menu choice
140 * @param currentMenu Current menu choice
142 public void setCurrentMenu (final String currentMenu);
145 * Some "Getter" for menu item
147 * @param accessKey Key to press to access this menu
148 * @param text Text to show to user
151 public SelectableMenuItem getMenuItem (final char accessKey, final String text);
154 * Shows given menu entry in client
156 * @param item Menu item to show
158 public void showEntry (final SelectableMenuItem item);
161 * Shows current menu selection to the user
163 public void showCurrentMenu ();