]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/BaseFrameworkSystem.java
Added a lot database stuff, which needs heavy rewrite
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / BaseFrameworkSystem.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\r
4  * This program is free software: you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation, either version 3 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * This program is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License\r
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
16  */\r
17 package org.mxchange.addressbook;\r
18 \r
19 import org.apache.logging.log4j.LogManager;\r
20 import org.apache.logging.log4j.Logger;\r
21 import org.mxchange.addressbook.application.Application;\r
22 import org.mxchange.addressbook.client.Client;\r
23 import org.mxchange.addressbook.manager.contact.ContactManager;\r
24 import org.mxchange.addressbook.manager.contact.ManageableContact;\r
25 \r
26 /**\r
27  * General class\r
28  *\r
29  * @author Roland Haeder\r
30  */\r
31 public class BaseFrameworkSystem {\r
32     /**\r
33      * Class' logger\r
34      */\r
35     private final Logger LOG;\r
36 \r
37     /**\r
38      * Application instance\r
39      */\r
40     private Application application;\r
41 \r
42     /**\r
43      * Client instance\r
44      */\r
45     private Client client;\r
46 \r
47     /**\r
48      * Contact manager instance\r
49      */\r
50     private ManageableContact contactManager;\r
51 \r
52     /**\r
53      * Name of used database table, handled over to backend\r
54      */\r
55     private String tableName;\r
56 \r
57     /**\r
58      * Initialize object\r
59      */\r
60     {\r
61         LOG = LogManager.getLogger(this);\r
62     }\r
63 \r
64     /**\r
65      * No instances can be created of this class\r
66      */\r
67     protected BaseFrameworkSystem () {\r
68     }\r
69 \r
70     /**\r
71      * Application instance\r
72      * \r
73      * @return the application\r
74      */\r
75     public Application getApplication () {\r
76         return this.application;\r
77     }\r
78 \r
79     /**\r
80      * Client instance\r
81      * \r
82      * @return the client\r
83      */\r
84     public Client getClient () {\r
85         return this.client;\r
86     }\r
87 \r
88     /**\r
89      * Contact manager instance\r
90      * @return the contactManager\r
91      */\r
92     public ManageableContact getContactManager () {\r
93         return this.contactManager;\r
94     }\r
95 \r
96     /**\r
97      * Contact manager instance\r
98      * @param contactManager the contactManager to set\r
99      */\r
100     protected void setContactManager (final ManageableContact contactManager) {\r
101         this.contactManager = contactManager;\r
102     }\r
103 \r
104     /**\r
105      * Client instance\r
106      * @param client the client to set\r
107      */\r
108     protected void setClient (final Client client) {\r
109         this.client = client;\r
110     }\r
111 \r
112     /**\r
113      * Application instance\r
114      *\r
115      * @param application the application to set\r
116      */\r
117     protected void setApplication(final Application application) {\r
118         this.application = application;\r
119     }\r
120 \r
121     /**\r
122      * Getter for logger\r
123      *\r
124      * @return Logger\r
125      */\r
126     protected Logger getLogger () {\r
127         return this.LOG;\r
128     }\r
129 \r
130     /**\r
131      * Name of used database table, handled over to backend\r
132      * \r
133      * @return the tableName\r
134      */\r
135     protected String getTableName () {\r
136         return this.tableName;\r
137     }\r
138 \r
139     /**\r
140      * Name of used database table, handled over to backend\r
141      * \r
142      * @param tableName the tableName to set\r
143      */\r
144     protected void setTableName (final String tableName) {\r
145         this.tableName = tableName;\r
146     }\r
147 \r
148     /**\r
149      * Initializes contact manager\r
150      * @param client Client instance\r
151      */\r
152     protected void initContactManager (final Client client) {\r
153         // Debug message\r
154         this.getLogger().debug("Initializing contact manager ...");\r
155         \r
156         // Init contact manager with console client\r
157         // @TODO Static initial amount of contacts\r
158         ManageableContact manager = new ContactManager (100, client);\r
159         \r
160         // Set it here\r
161         this.setContactManager(manager);\r
162         \r
163         // Debug message\r
164         this.getLogger().debug("Contact manager has been initialized.");\r
165     }\r
166 }\r