X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=Addressbook%2Fsrc%2Forg%2Fmxchange%2Faddressbook%2Fdatabase%2Fbackend%2FDatabaseBackend.java;h=9a66e94f1f14b2006cf2fa7aac3e26c3fd6f503d;hb=3fc961ed434b91c90884c0d9914a7e93defc7e4a;hp=0d83acaf4a88d168e3fa25e038b2f84cd2b3dc1c;hpb=a9386126082a82d662e37cec79c3d449d89d25cf;p=jaddressbook-share-lib.git diff --git a/Addressbook/src/org/mxchange/addressbook/database/backend/DatabaseBackend.java b/Addressbook/src/org/mxchange/addressbook/database/backend/DatabaseBackend.java index 0d83aca..9a66e94 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/backend/DatabaseBackend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/backend/DatabaseBackend.java @@ -1,42 +1,91 @@ -/* - * Copyright (C) 2015 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.addressbook.database.backend; - -import java.io.IOException; -import org.mxchange.addressbook.FrameworkInterface; -import org.mxchange.addressbook.database.storage.Storeable; - -/** - * A generic interface for database frontends - * - * @author Roland Haeder - */ -public interface DatabaseBackend extends FrameworkInterface { - - /** - * Rewinds backend - */ - public void rewind (); - - /** - * Stores an object in the database. - * - * @param object Object to store in database - * @throws java.io.IOException From inner class - */ - public void store (final Storeable object) throws IOException; -} +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.database.backend; + +import java.io.IOException; +import java.sql.SQLException; +import java.util.Iterator; +import org.mxchange.addressbook.FrameworkInterface; +import org.mxchange.addressbook.contact.Contact; +import org.mxchange.addressbook.database.storage.Storeable; +import org.mxchange.addressbook.exceptions.BadTokenException; + +/** + * A generic interface for database frontends + * + * @author Roland Haeder + */ +public interface DatabaseBackend extends FrameworkInterface { + + /** + * Tries a connection to the database + * + * @throws java.sql.SQLException If the connection attempt fails + */ + public void connectToDatabase () throws SQLException; + + /** + * Shuts down this backend + */ + public void doShutdown (); + + /** + * Some "getter" for total table row count + * + * @return Total row count + */ + public int getTotalCount (); + + /** + * Checks whether at least one row is found with given boolean value. + * + * @param columnName Column to check for boolean value + * @param bool Boolean value to check + * @return Whether boolean value is found and returns at least one row + */ + public boolean isRowFound (final String columnName, final boolean bool); + + /** + * Rewinds backend + */ + public void rewind (); + + /** + * Get length of underlaying file + * + * @return Length of underlaying file + */ + public long length (); + + /** + * Stores an object in the database. + * + * @param object Object to store in database + * @throws java.io.IOException From inner class + */ + public void store (final Storeable object) throws IOException; + + /** + * Gets an iterator for contacts + * + * @return Iterator for contacts + * @throws org.mxchange.addressbook.exceptions.BadTokenException If the CSV token is badly formulated + * @deprecated The method is to much "contact" specific + */ + @Deprecated + public Iterator contactIterator () throws BadTokenException; +}