]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java
Added a lot database stuff, which needs heavy rewrite
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / database / frontend / contact / ContactDatabaseFrontend.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.database.frontend.contact;\r
18 \r
19 import java.io.IOException;\r
20 import org.mxchange.addressbook.contact.Contact;\r
21 import org.mxchange.addressbook.database.storage.Storeable;\r
22 import org.mxchange.addressbook.database.frontend.BaseDatabaseFrontend;\r
23 \r
24 /**\r
25  * Stores and retrieves Contact instances\r
26  *\r
27  * @author Roland Haeder\r
28  */\r
29 public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements ContactWrapper {\r
30     /**\r
31      * Basic constrcutor\r
32      */\r
33     public ContactDatabaseFrontend () {\r
34         super();\r
35 \r
36         // Set "table" name\r
37         this.setTableName("contacts");\r
38 \r
39         // Initalize backend\r
40         this.initBackend();\r
41     }\r
42 \r
43     @Override\r
44     public void addContact (final Contact contact) {\r
45         try {\r
46             // Try to cast the object and handle it over to the backend\r
47             this.getBackend().store((Storeable) contact);\r
48         } catch (final IOException ex) {\r
49             this.getLogger().error("Cannot write contact to storage: " + ex.getMessage());\r
50             System.exit(1);\r
51         }\r
52     }\r
53 }\r