*/
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
*/
public interface DatabaseFrontend extends FrameworkInterface {
/**
- * Parses given line from database backend into a Storeable instance. Please
- * note that not all backends need this.
+ * Depending on column, an empty value may be converted to null
*
- * @param line Line from database backend
- * @return A Storeable instance
- * @throws org.mxchange.jcore.exceptions.BadTokenException If a token was badly formatted
+ * @param key Key to check
+ * @param value Value to check
+ * @return Possible previous value or null
*/
- public Storeable parseLineToStoreable (final String line) throws BadTokenException;
+ public Object emptyStringToNull (final String key, final Object value);
+
+ /**
+ * Gets a Result back from given ResultSet instance
+ *
+ * @param resultSet ResultSet instance from SQL driver
+ * @return A typorized Result instance
+ * @throws java.sql.SQLException If an SQL error occurs
+ */
+ public Result<? extends Storeable> getResultFromSet (final ResultSet resultSet) throws SQLException;
+
+ /**
+ * Name of used database table, handled over to backend
+ *
+ * @return the tableName
+ */
+ public String getTableName ();
+
+ /**
+ * Shuts down the database layer
+ * @throws java.sql.SQLException If any SQL error occurs
+ * @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 ();
}