]> git.mxchange.org Git - addressbook-lib.git/blob - Addressbook/src/org/mxchange/addressbook/client/Client.java
Global commit: Changed spaces to tabs, because all Java files have tabs for indenting
[addressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / client / Client.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.addressbook.client;
18
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;
23
24 /**
25  * An interface for application clients
26  *
27  * @author Roland Haeder
28  */
29 public interface Client extends FrameworkInterface {
30
31         /**
32          * Displays a "box" for the address
33          *
34          * @param contact Contact to show address from
35          */
36         public void displayAddressBox (final Contact contact);
37
38         /**
39          * The user changes own name data
40          *
41          * @param contact
42          */
43         public void doChangeOwnNameData (final Contact contact);
44
45         /**
46          * The user changes own address data
47          *
48          * @param contact Contact instance to change
49          */
50         public void doChangeOwnAddressData (final Contact contact);
51
52         /**
53          * The user changes own other data
54          *
55          * @param contact Constact instance to change
56          */
57         public void doChangeOwnOtherData (final Contact contact);
58
59         /**
60          * Allows the user to enter own data
61          *
62          * @return Finished Contact instance
63          */
64         public Contact doEnterOwnData ();
65
66         /**
67          * Shuts down the client and therefore whole application
68          */
69         public void doShutdown ();
70
71         /**
72          * Displays a message to the user
73          *
74          * @param message Message to show to the user
75          */
76         public void outputMessage (final String message);
77
78         /**
79          * Displays a "box" for the name
80          *
81          * @param contact Contact to show name from
82          */
83         public void displayNameBox (final Contact contact);
84
85         /**
86          * Displays a "box" for other data
87          *
88          * @param contact Contact to show other data from
89          */
90         public void displayOtherDataBox (final Contact contact);
91
92         /**
93          * Let the user choose what to change on the address: [n]ame, [a]ddress,
94          * [o]ther
95          *
96          * @param contact Contact instance to let the user change data
97          * @throws UnhandledUserChoiceException If choice is not supported
98          */
99         public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
100
101         /**
102          * Asks the user for a choice and proceeds accordingly
103          *
104          * @throws UnhandledUserChoiceException If choice is not supported
105          */
106         public void doUserMenuChoice () throws UnhandledUserChoiceException;
107
108         /**
109          * Enables isRunning attribute which singals that the client is running
110          */
111         public void enableIsRunning ();
112
113         /**
114          * Asks the the user to enter a single character which must match validChars
115          *
116          * @param       validChars Valid chars that are accepted
117          * @param       message Message to user
118          * @return      Allowed character
119          */
120         public char enterChar (final char[] validChars, final String message);
121
122         /**
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.
125          * company name.
126          *
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
132          */
133         public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
134
135         /**
136          * Reads an integer (int) from the user
137          *
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
142          */
143         public int enterInt (final int minimum, final int maximum, final String message);
144
145         /**
146          * Setter for current menu choice
147          *
148          * @param currentMenu Current menu choice
149          */
150         public void setCurrentMenu (final String currentMenu);
151
152         /**
153          * Some "Getter" for menu item
154          *
155          * @param accessKey Key to press to access this menu
156          * @param text Text to show to user
157          * @return
158          */
159         public SelectableMenuItem getMenuItem (final char accessKey, final String text);
160
161         /**
162          * Determines whether the client is still active by checking some conditions
163          *
164          * @return Whether the client is still active
165          */
166         public boolean isRunning ();
167
168         /**
169          * Shows given menu entry in client
170          *
171          * @param item Menu item to show
172          */
173         public void showEntry (final SelectableMenuItem item);
174
175         /**
176          * Shows introduction to user
177          */
178         public void showWelcome ();
179
180         /**
181          * Shows current menu selection to the user
182          */
183         public void showCurrentMenu ();
184
185         /**
186          * Inizializes this client
187          */
188         public void init ();
189 }