Package es.bsc.dataclay.dbhandler.sql
Class SQLHandler<T extends DBHandlerConf>
- java.lang.Object
-
- es.bsc.dataclay.dbhandler.sql.SQLHandler<T>
-
- All Implemented Interfaces:
DBHandler
- Direct Known Subclasses:
SQLiteHandler
public abstract class SQLHandler<T extends DBHandlerConf> extends Object implements DBHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected TconfigurationConfiguration of the connection.protected SQLiteDataSourcedataSourceData sources.protected static booleanDEBUG_ENABLEDIndicates if debug is enabled.
-
Constructor Summary
Constructors Constructor Description SQLHandler(T connConfig)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanclose()Close the databaseintcount()Count number of objects in DBabstract voidcreateDatabase()voidcreateTables()Initialize databaseabstract booleandatabaseExists()voiddelete(ObjectID objectID)Deletes and object from the database.abstract voiddropAllDatabases()Drop all databases.booleanexists(ObjectID objectID)Check if object with ID provided exists.byte[]get(ObjectID objectID)Get serialized object identified by ObjectIDTgetConfiguration()SQLiteDataSourcegetDataSource()protected abstract voidinitDataSource()booleanisClosed()Verify if database is closed.voidopen()Open database.voidstore(ObjectID objectID, byte[] bytes)Store the object.voidupdate(ObjectID objectID, byte[] newbytes)Updates an object identified by the ID provided with the new values provided.voidvacuum()Vacuum database.
-
-
-
Field Detail
-
DEBUG_ENABLED
protected static final boolean DEBUG_ENABLED
Indicates if debug is enabled.
-
dataSource
protected SQLiteDataSource dataSource
Data sources.
-
configuration
protected final T extends DBHandlerConf configuration
Configuration of the connection.
-
-
Constructor Detail
-
SQLHandler
public SQLHandler(T connConfig)
Constructor.- Parameters:
connConfig- Configuration.
-
-
Method Detail
-
initDataSource
protected abstract void initDataSource()
-
databaseExists
public abstract boolean databaseExists()
-
createDatabase
public abstract void createDatabase()
-
dropAllDatabases
public abstract void dropAllDatabases()
Drop all databases. FOR TESTING PURPOSES.
-
createTables
public void createTables()
Initialize database
-
getConfiguration
public T getConfiguration()
-
store
public void store(ObjectID objectID, byte[] bytes)
Description copied from interface:DBHandlerStore the object.
-
get
public byte[] get(ObjectID objectID)
Description copied from interface:DBHandlerGet serialized object identified by ObjectID
-
exists
public boolean exists(ObjectID objectID)
Description copied from interface:DBHandlerCheck if object with ID provided exists.
-
count
public int count()
Description copied from interface:DBHandlerCount number of objects in DB
-
update
public void update(ObjectID objectID, byte[] newbytes)
Description copied from interface:DBHandlerUpdates an object identified by the ID provided with the new values provided.
-
delete
public void delete(ObjectID objectID)
Description copied from interface:DBHandlerDeletes and object from the database.
-
vacuum
public void vacuum()
Description copied from interface:DBHandlerVacuum database.
-
isClosed
public boolean isClosed()
Description copied from interface:DBHandlerVerify if database is closed.
-
close
public boolean close()
Description copied from interface:DBHandlerClose the database
-
getDataSource
public SQLiteDataSource getDataSource()
-
-