de.unikassel.android.sdcframework.persistence.facade
Interface DatabaseAdapter

Package class diagram package DatabaseAdapter
All Known Implementing Classes:
DatabaseAdapterImpl

public interface DatabaseAdapter


Method Summary
 void close()
          Method to close the database
 long deleteSamplesOrdered(long count, boolean deleteLowestPriorityFirst)
          Method to delete a given count of the oldest samples.
 long getMaximumDatabaseSize()
          Getter for the maximum database size
 long getRecordCount()
          Method to get the current record count
 void insertSamples(Collection<DatabaseSample> samples)
          Method to insert a sample collection into the database
 DatabaseAdapter open()
          Method to open the database for write access
 DatabaseAdapter openForRead()
          Method to open the database for read access
 boolean removeSamplesHighestPrioFirst(long count, Collection<DatabaseSample> sampleCollection)
          Method to remove the next "count" samples which will be selected ordered by ascending priority and ascending time stamp from the database and stored in a given sample collection.
 boolean removeSamplesLowestPrioFirst(long count, Collection<DatabaseSample> sampleCollection)
          Method to remove the next "count" samples which will be selected ordered by descending priority and ascending time stamps from the database and stored in a given sample collection.
 boolean removeSamplesOldestTimeStampFirst(long count, Collection<DatabaseSample> sampleCollection)
          Method to remove the next "count" samples which will be selected ordered by ascending time stamps from the database and stored in a given sample collection.
 long setMaximumDatabaseSize(long size)
          Setter for the maximum database size
 

Method Detail

open

DatabaseAdapter open()
                     throws SQLiteException
Method to open the database for write access

Returns:
this database adapter
Throws:
SQLiteException - if unable to open the database

openForRead

DatabaseAdapter openForRead()
                            throws SQLiteException
Method to open the database for read access

Returns:
this database adapter
Throws:
SQLiteException - if unable to open the database

close

void close()
Method to close the database


insertSamples

void insertSamples(Collection<DatabaseSample> samples)
                   throws Exception
Method to insert a sample collection into the database

Parameters:
samples - the sample collection to insert
Throws:
Exception

getRecordCount

long getRecordCount()
Method to get the current record count

Returns:
the current count of records stored

deleteSamplesOrdered

long deleteSamplesOrdered(long count,
                          boolean deleteLowestPriorityFirst)
Method to delete a given count of the oldest samples.

Parameters:
count - the count of records to delete
deleteLowestPriorityFirst - if true the sample for deletion will be selected first by lowest priority, second oldest time stamp
Returns:
the count of deleted records

removeSamplesHighestPrioFirst

boolean removeSamplesHighestPrioFirst(long count,
                                      Collection<DatabaseSample> sampleCollection)
Method to remove the next "count" samples which will be selected ordered by ascending priority and ascending time stamp from the database and stored in a given sample collection.
This method is used to select samples for transmission.
Here the oldest samples with the highest priority will be selected first.

Parameters:
count - the sample count to remove
sampleCollection - the sample collection to store removed samples in
Returns:
true if successful, false otherwise

removeSamplesLowestPrioFirst

boolean removeSamplesLowestPrioFirst(long count,
                                     Collection<DatabaseSample> sampleCollection)
Method to remove the next "count" samples which will be selected ordered by descending priority and ascending time stamps from the database and stored in a given sample collection.
This method is used to select samples for deletion in case of exceeding database size.
Here the oldest samples with the lowest priority will be selected first.

Parameters:
count - the sample count to remove
sampleCollection - the sample collection to store removed samples in
Returns:
true if successful, false otherwise

removeSamplesOldestTimeStampFirst

boolean removeSamplesOldestTimeStampFirst(long count,
                                          Collection<DatabaseSample> sampleCollection)
Method to remove the next "count" samples which will be selected ordered by ascending time stamps from the database and stored in a given sample collection.
This method is used to select samples for deletion in case of exceeding database size.
Here, independent of the sample priority, the oldest samples will be selected first.

Parameters:
count - the sample count to remove
sampleCollection - the sample collection to store removed samples in
Returns:
true if successful, false otherwise

setMaximumDatabaseSize

long setMaximumDatabaseSize(long size)
Setter for the maximum database size

Parameters:
size - the maximum database size
Returns:
the new maximum database size

getMaximumDatabaseSize

long getMaximumDatabaseSize()
Getter for the maximum database size

Returns:
the maximum database size