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 T
configuration
Configuration of the connection.protected SQLiteDataSource
dataSource
Data sources.protected static boolean
DEBUG_ENABLED
Indicates 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 boolean
close()
Close the databaseint
count()
Count number of objects in DBabstract void
createDatabase()
void
createTables()
Initialize databaseabstract boolean
databaseExists()
void
delete(ObjectID objectID)
Deletes and object from the database.abstract void
dropAllDatabases()
Drop all databases.boolean
exists(ObjectID objectID)
Check if object with ID provided exists.byte[]
get(ObjectID objectID)
Get serialized object identified by ObjectIDT
getConfiguration()
SQLiteDataSource
getDataSource()
protected abstract void
initDataSource()
boolean
isClosed()
Verify if database is closed.void
open()
Open database.void
store(ObjectID objectID, byte[] bytes)
Store the object.void
update(ObjectID objectID, byte[] newbytes)
Updates an object identified by the ID provided with the new values provided.void
vacuum()
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:DBHandler
Store the object.
-
get
public byte[] get(ObjectID objectID)
Description copied from interface:DBHandler
Get serialized object identified by ObjectID
-
exists
public boolean exists(ObjectID objectID)
Description copied from interface:DBHandler
Check if object with ID provided exists.
-
count
public int count()
Description copied from interface:DBHandler
Count number of objects in DB
-
update
public void update(ObjectID objectID, byte[] newbytes)
Description copied from interface:DBHandler
Updates an object identified by the ID provided with the new values provided.
-
delete
public void delete(ObjectID objectID)
Description copied from interface:DBHandler
Deletes and object from the database.
-
vacuum
public void vacuum()
Description copied from interface:DBHandler
Vacuum database.
-
isClosed
public boolean isClosed()
Description copied from interface:DBHandler
Verify if database is closed.
-
close
public boolean close()
Description copied from interface:DBHandler
Close the database
-
getDataSource
public SQLiteDataSource getDataSource()
-
-