de.unikassel.android.sdcframework.persistence
Class DatabaseManagerImpl

Package class diagram package DatabaseManagerImpl
java.lang.Object
  extended by de.unikassel.android.sdcframework.persistence.DatabaseManagerImpl
All Implemented Interfaces:
DatabaseManager

public final class DatabaseManagerImpl
extends Object
implements DatabaseManager

Implementation of a central database manager.


Field Summary
private  DatabaseAdapterImpl dbAdapter
          The internal database adapter
 
Constructor Summary
DatabaseManagerImpl(Context applicationContext, long maxDBSize, String dbName)
          Constructor
DatabaseManagerImpl(Context applicationContext, String dbName)
          Constructor
 
Method Summary
 long doDeleteOldestSamplesInDatabase(long count, boolean lowestPriorityFirst)
          Method to delete the oldest "count" samples in the database
This method is used to delete samples for deletion in case of database size maximum reached.
<T> T
doExecuteCommand(DatabaseCommand<T> command)
          Does execute a database command
 DatabaseAdapterImpl getDbAdapter()
          Getter for the dbAdapter
 long getMaximumDatabaseSize()
          Getter for the maximum database size in kilobytes
 long getRecordCountInDatabase()
          Getter for the current sample record count stored in database
 long setMaximumDatabaseSize(long size)
          Setter for the maximum database size in kilobytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbAdapter

private final DatabaseAdapterImpl dbAdapter
The internal database adapter

Constructor Detail

DatabaseManagerImpl

public DatabaseManagerImpl(Context applicationContext,
                           String dbName)
Constructor

Parameters:
applicationContext - the application context
dbName - the database name

DatabaseManagerImpl

public DatabaseManagerImpl(Context applicationContext,
                           long maxDBSize,
                           String dbName)
Constructor

Parameters:
applicationContext - the application context
maxDBSize - the maximum database size
dbName - the database name
Method Detail

getDbAdapter

public final DatabaseAdapterImpl getDbAdapter()
Getter for the dbAdapter

Returns:
the dbAdapter

getRecordCountInDatabase

public long getRecordCountInDatabase()
Description copied from interface: DatabaseManager
Getter for the current sample record count stored in database

Specified by:
getRecordCountInDatabase in interface DatabaseManager
Returns:
the current sample record count in the database

setMaximumDatabaseSize

public long setMaximumDatabaseSize(long size)
Description copied from interface: DatabaseManager
Setter for the maximum database size in kilobytes

Specified by:
setMaximumDatabaseSize in interface DatabaseManager
Parameters:
size - the maximum database size
Returns:
the new maximum database size

getMaximumDatabaseSize

public long getMaximumDatabaseSize()
Description copied from interface: DatabaseManager
Getter for the maximum database size in kilobytes

Specified by:
getMaximumDatabaseSize in interface DatabaseManager
Returns:
the new maximum database size

doDeleteOldestSamplesInDatabase

public long doDeleteOldestSamplesInDatabase(long count,
                                            boolean lowestPriorityFirst)
Description copied from interface: DatabaseManager
Method to delete the oldest "count" samples in the database
This method is used to delete samples for deletion in case of database size maximum reached.
Depending on the flag lowestPriorityFirst the oldest samples will be selected priority independent or not.

Specified by:
doDeleteOldestSamplesInDatabase in interface DatabaseManager
Parameters:
count - the sample count to delete in database
lowestPriorityFirst - if true the samples will be selected ordered by priority and time stamp, otherwise just by time stamp
Returns:
the count of samples deleted in database

doExecuteCommand

public <T> T doExecuteCommand(DatabaseCommand<T> command)
                   throws SQLiteFullException
Description copied from interface: DatabaseManager
Does execute a database command

Specified by:
doExecuteCommand in interface DatabaseManager
Type Parameters:
T - the result type of the command
Parameters:
command - the command to execute
Returns:
true if successful, false if a database full exception occurred
Throws:
SQLiteFullException - if command execution fails due to database is full