-/*\r
- * Copyright (C) 2015 Roland Haeder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.addressbook.database.backend;\r
-\r
-import java.io.IOException;\r
-import org.mxchange.addressbook.FrameworkInterface;\r
-import org.mxchange.addressbook.database.storage.Storeable;\r
-\r
-/**\r
- * A generic interface for database frontends\r
- * \r
- * @author Roland Haeder\r
- */\r
-public interface DatabaseBackend extends FrameworkInterface {\r
-\r
- /**\r
- * Rewinds backend\r
- */\r
- public void rewind ();\r
-\r
- /**\r
- * Stores an object in the database.\r
- * \r
- * @param object Object to store in database\r
- * @throws java.io.IOException From inner class\r
- */\r
- public void store (final Storeable object) throws IOException;\r
-}\r
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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.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 row index from given boolean row value
+ *
+ * @param columnName Name of column
+ * @param bool Boolean value to look for
+ * @return Row index
+ */
+ public int getRowIndexFromColumn (final String columnName, final boolean bool);
+
+ /**
+ * Some "getter" for total table row count
+ *
+ * @return Total row count
+ * @throws java.sql.SQLException If an SQL error occurs
+ */
+ public int getTotalCount () throws SQLException;
+
+ /**
+ * 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
+ * @throws java.sql.SQLException If an SQL error occurs
+ */
+ public boolean isRowFound (final String columnName, final boolean bool) throws SQLException;
+
+ /**
+ * 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
+ */
+ public Iterator<? extends Storeable> iterator () throws BadTokenException;
+
+ /**
+ * Reads a single row from database.
+ *
+ * @param rowIndex Row index (or how much to skip)
+ * @return A Storeable instance
+ * @throws org.mxchange.addressbook.exceptions.BadTokenException If a token was badly formatted
+ */
+ public Storeable readRow (final int rowIndex) throws BadTokenException;
+}