]> git.mxchange.org Git - jcore.git/blobdiff - src/org/mxchange/jcore/database/frontend/DatabaseFrontend.java
Introduced getTotalRows() to DatabaseBackend implementations + added getIdName()...
[jcore.git] / src / org / mxchange / jcore / database / frontend / DatabaseFrontend.java
index 528621596b26d535bef519bbddb544d5249a2ef8..59e59fbf5289055be60a53061e53d41424998af1 100644 (file)
 package org.mxchange.jcore.database.frontend;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.Map;
 import org.mxchange.jcore.FrameworkInterface;
 import org.mxchange.jcore.database.result.Result;
 import org.mxchange.jcore.database.storage.Storeable;
-import org.mxchange.jcore.exceptions.BadTokenException;
 
 /**
  * A generic interface for database frontends
@@ -30,6 +31,15 @@ import org.mxchange.jcore.exceptions.BadTokenException;
  * @author Roland Haeder
  */
 public interface DatabaseFrontend extends FrameworkInterface {
+       /**
+        * Depending on column, an empty value may be converted to null
+        *
+        * @param key Key to check
+        * @param value Value to check
+        * @return Possible previous value or null
+        */
+       public Object emptyStringToNull (final String key, final Object value);
+
        /**
         * Gets a Result back from given ResultSet instance
         *
@@ -39,16 +49,6 @@ public interface DatabaseFrontend extends FrameworkInterface {
         */
        public Result<? extends Storeable> getResultFromSet (final ResultSet resultSet) throws SQLException;
 
-       /**
-        * Parses given line from database backend into a Storeable instance. Please
-        * note that not all backends need this.
-        *
-        * @param line Line from database backend
-        * @return A Storeable instance
-        * @throws org.mxchange.jcore.exceptions.BadTokenException If a token was badly formatted
-        */
-       public Storeable parseLineToStoreable (final String line) throws BadTokenException;
-
        /**
         * Name of used database table, handled over to backend
         *
@@ -62,4 +62,25 @@ public interface DatabaseFrontend extends FrameworkInterface {
         * @throws java.io.IOException If any IO error occurs
         */
        public void doShutdown () throws SQLException, IOException;
+
+       /**
+        * Converts the given map into a Storeable instance, depending on which class implements it. All
+        * keys are being interpreted as class fields/attributes and their respective setters are being searched for. As
+        * this method may fail to find one or access it, this method throws some exception.
+        *
+        * @param map Map instance to convert to Storeable
+        * @return An instance of a Storeable implementation
+        * @throws IllegalArgumentException Some implementations may throw this
+        * @throws java.lang.NoSuchMethodException If the invoked method was not found
+        * @throws java.lang.IllegalAccessException If the method cannot be accessed
+        * @throws java.lang.reflect.InvocationTargetException Any other problems?
+        */
+       public Storeable toStoreable (final Map<String, String> map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException;
+
+       /**
+        * Some getter for name of id column
+        *
+        * @return Name of id column
+        */
+       public String getIdName ();
 }