2 * Copyright (C) 2015 Roland Häder
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.database.frontend.contact;
19 import java.io.IOException;
20 import java.lang.reflect.InvocationTargetException;
21 import java.sql.SQLException;
22 import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
23 import org.mxchange.jcore.contact.Contact;
24 import org.mxchange.jcore.database.frontend.DatabaseFrontend;
25 import org.mxchange.jcore.exceptions.BadTokenException;
26 import org.mxchange.jcore.exceptions.CorruptedDatabaseFileException;
29 * An interface for addressbook contact database frontends
31 * @author Roland Häder
33 public interface AddressbookContactFrontend extends DatabaseFrontend {
36 * Adds given contact instance to database
38 * @param contact Contact instance to add
39 * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added
41 public void addContact (final Contact contact) throws ContactAlreadyAddedException;
44 * Some "getter" for total contacts count
46 * @return Total contacts count
47 * @throws java.sql.SQLException If any SQL error occurs
49 public int getContactsCount () throws SQLException;
52 * Checks if given Contact is found
54 * @param contact Contact instance to check
55 * @return Whether the given Contact instance is found
56 * @throws java.sql.SQLException If an SQL error occurs
57 * @throws java.io.IOException If an IO error occurs
58 * @throws org.mxchange.jcore.exceptions.BadTokenException Continued throw
59 * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If the database file is damaged
60 * @throws java.lang.NoSuchMethodException If a method cannot be found
61 * @throws java.lang.IllegalAccessException If a method is not accessible
62 * @throws java.lang.reflect.InvocationTargetException Any other problems?
64 public boolean isContactFound (final Contact contact) throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
67 * Some "getter" for own contact instance
69 * @return Own contact instance
71 public Contact getOwnContact ();
74 * Checks whether own contact is found
76 * @return Whether own contact is found
77 * @throws java.sql.SQLException If any SQL error occurs
78 * @throws java.io.IOException If an IO error occurs
79 * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
80 * @throws org.mxchange.jcore.exceptions.CorruptedDatabaseFileException If the database file is damaged
81 * @throws java.lang.NoSuchMethodException If a method cannot be found
82 * @throws java.lang.IllegalAccessException If a method is not accessible
83 * @throws java.lang.reflect.InvocationTargetException Any other problems?
85 public boolean isOwnContactFound () throws SQLException, IOException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
88 * Reads a single row and parses it to a contact instance
90 * @param rowIndex Row index (also how much to skip)
91 * @return Contact instance
93 public Contact readSingleContact (final int rowIndex);