]> git.mxchange.org Git - jaddressbook-lib.git/blob - Addressbook/src/org/mxchange/addressbook/client/Client.java
6e28668d605a3f9d332ac9812123b752a94d6a69
[jaddressbook-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.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      * @param contact 
41      */
42     public void doChangeOwnNameData (final Contact contact);
43
44     /**
45      * The user changes own address data
46      *
47      * @param contact Contact instance to change
48      */
49     public void doChangeOwnAddressData (final Contact contact);
50
51     /**
52      * The user changes own other data
53      * 
54      * @param contact Constact instance to change
55      */
56     public void doChangeOwnOtherData (final Contact contact);
57
58     /**
59      * Allows the user to enter own data
60      * 
61      * @return Finished Contact instance
62      */
63     public Contact doEnterOwnData ();
64
65     /**
66      * Shuts down the client and therefore whole application
67      */
68     public void doShutdown ();
69
70     /**
71      * Displays a message to the user
72      *
73      * @param message Message to show to the user
74      */
75     public void outputMessage (final String message);
76
77     /**
78      * Displays a "box" for the name
79      *
80      * @param contact Contact to show name from
81      */
82     public void displayNameBox (final Contact contact);
83
84     /**
85      * Displays a "box" for other data
86      *
87      * @param contact Contact to show other data from
88      */
89     public void displayOtherDataBox (final Contact contact);
90
91     /**
92      * Let the user choose what to change on the address: [n]ame, [a]ddress,
93      * [o]ther
94      * 
95      * @param contact Contact instance to let the user change data
96      * @throws UnhandledUserChoiceException If choice is not supported
97      */
98     public void userChooseChangeContactData (final Contact contact) throws UnhandledUserChoiceException;
99
100     /**
101      * Asks the user for a choice and proceeds accordingly
102      * 
103      * @throws UnhandledUserChoiceException If choice is not supported
104      */
105     public void doUserMenuChoice () throws UnhandledUserChoiceException ;
106
107     /**
108      * Enables isRunning attribute which singals that the client is running
109      */
110     public void enableIsRunning();
111
112     /**
113      * Asks the the user to enter a single character which must match validChars
114      * 
115      * @param   validChars  Valid chars that are accepted
116      * @param   message     Message to user
117      * @return  Allowed character
118      */
119     public char enterChar (final char[] validChars, final String message);
120
121     /**
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.
124      * company name.
125      * 
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
131      */
132     public String enterString (final int minLength, final int maxLength, final String message, final boolean allowEmpty);
133
134     /**
135      * Reads an integer (int) from the user
136      * 
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
141      */
142     public int enterInt (final int minimum, final int maximum, final String message);
143
144     /**
145      * Setter for current menu choice
146      * 
147      * @param currentMenu Current menu choice
148      */
149     public void setCurrentMenu (final String currentMenu);
150
151     /**
152      * Some "Getter" for menu item
153      * 
154      * @param accessKey Key to press to access this menu
155      * @param text Text to show to user
156      * @return 
157      */
158     public SelectableMenuItem getMenuItem (final char accessKey, final String text);
159
160     /**
161      * Determines whether the client is still active by checking some
162      * 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 }