]> git.mxchange.org Git - jcore.git/blobdiff - src/org/mxchange/jcore/database/backend/DatabaseBackend.java
Organized members
[jcore.git] / src / org / mxchange / jcore / database / backend / DatabaseBackend.java
index c7fa70e07bd68a5e22c44f0a56a2db2824c28dc2..0dd7dac728e13fe1a1d46b9fc482683ccaa94214 100644 (file)
@@ -18,8 +18,9 @@ package org.mxchange.jcore.database.backend;
 
 import java.io.IOException;
 import java.sql.SQLException;
-import java.util.Iterator;
 import org.mxchange.jcore.FrameworkInterface;
+import org.mxchange.jcore.criteria.searchable.SearchableCritera;
+import org.mxchange.jcore.database.result.Result;
 import org.mxchange.jcore.database.storage.Storeable;
 import org.mxchange.jcore.exceptions.BadTokenException;
 
@@ -38,71 +39,22 @@ public interface DatabaseBackend extends FrameworkInterface {
        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.
+        * Run a "SELECT" statement with given criteria and always return a Result
+        * instance. The result instance then provides methods to iterate over all
+        * found entries.
         *
-        * @param object Object to store in database
-        * @throws java.io.IOException From inner class
+        * @param critera Search critera
+        * @return A result instance
+        * @throws java.io.IOException If any IO error occurs
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
         */
-       public void store (final Storeable object) throws IOException;
+       public Result<? extends Storeable> doSelectByCriteria (final SearchableCritera critera) throws IOException, BadTokenException;
 
        /**
-        * Gets an iterator for contacts
+        * Shuts down this backend
         *
-        * @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
+        * @throws java.sql.SQLException If any SQL error occurs
+        * @throws java.io.IOException If any IO error occurs
         */
-       public Storeable readRow (final int rowIndex) throws BadTokenException;
+       public void doShutdown () throws SQLException, IOException;
 }