fr.profi.mzdb.io.reader.table.AbstractTableModelReader Maven / Gradle / Ivy
package fr.profi.mzdb.io.reader.table;
import java.util.List;
import com.almworks.sqlite4java.SQLiteConnection;
import com.almworks.sqlite4java.SQLiteException;
import fr.profi.mzdb.util.sqlite.ISQLiteRecordExtraction;
import fr.profi.mzdb.util.sqlite.SQLiteQuery;
/**
* @author bouyssie
*
*/
public abstract class AbstractTableModelReader {
protected SQLiteConnection connection;
protected ISQLiteRecordExtraction recordExtractor;
protected AbstractTableModelReader(SQLiteConnection connection) {
super();
this.connection = connection;
this.recordExtractor = buildRecordExtractor();
}
protected abstract ISQLiteRecordExtraction buildRecordExtractor();
protected T getRecord(String tableName, int id) throws SQLiteException {
return new SQLiteQuery(connection, "SELECT * FROM "+tableName+" WHERE id = ?").bind(1, id)
.extractRecord(recordExtractor);
}
protected List getRecordList(String tableName) throws SQLiteException {
return new SQLiteQuery(connection, "SELECT * FROM "+ tableName).extractRecordList(recordExtractor);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy