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.sql.SQLException;
21 import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
22 import org.mxchange.jcore.contact.Contact;
23 import org.mxchange.jcore.database.frontend.DatabaseFrontend;
24 import org.mxchange.jcore.exceptions.BadTokenException;
27 * An interface for addressbook contact database frontends
29 * @author Roland Häder
31 public interface AddressbookContactFrontend extends DatabaseFrontend {
34 * Adds given contact instance to database
36 * @param contact Contact instance to add
37 * @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If the contact is already added
39 public void addContact (final Contact contact) throws ContactAlreadyAddedException;
42 * Some "getter" for total contacts count
44 * @return Total contacts count
45 * @throws java.sql.SQLException If any SQL error occurs
47 public int getContactsCount () throws SQLException;
50 * Checks if given Contact is found
52 * @param contact Contact instance to check
53 * @return Whether the given Contact instance is found
54 * @throws org.mxchange.jcore.exceptions.BadTokenException Continued throw
56 public boolean isContactFound (final Contact contact) throws BadTokenException;
59 * Some "getter" for own contact instance
61 * @return Own contact instance
63 public Contact getOwnContact ();
66 * Checks whether own contact is found
68 * @return Whether own contact is found
69 * @throws java.sql.SQLException If any SQL error occurs
70 * @throws java.io.IOException If an IO error occurs
71 * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
73 public boolean isOwnContactFound () throws SQLException, IOException, BadTokenException;
76 * Reads a single row and parses it to a contact instance
78 * @param rowIndex Row index (also how much to skip)
79 * @return Contact instance
81 public Contact readSingleContact (final int rowIndex);