org.openbandy.io.storage
Class DatabaseStorage

java.lang.Object
  extended by org.openbandy.io.storage.Storage
      extended by org.openbandy.io.storage.DatabaseStorage

public class DatabaseStorage
extends Storage

The DatabaseStorage is an extension to the Storage. Thereby, it particularly implements the logic for the methods existsInStorage, deleteShallow and reset. All these methods are realized using a temporary DatabaseConnection to execute the necessary SQL statements.

(c) Copyright Philipp Bolliger 2007, ALL RIGHTS RESERVED.

Version:
1.0
Author:
Philipp Bolliger (philipp@bolliger.name)

Method Summary
static java.lang.String apostrophe(java.lang.String value)
           
static java.lang.String bracket(java.lang.String value)
           
 void closeConnection(DatabaseConnection connection)
           
 boolean deleteShallow(Serializable serializable)
          Deletes the serializable object, but not the reference objects.
 int existsInStorage(Serializable serializable)
          Return 0 if databaseSerializable does not already exist in database.
 DatabaseConnection getDatabaseConnection(java.lang.String owner)
           
static DatabaseStorage getInstance()
           
static java.lang.String getTableName(Serializable serializable)
           
static java.lang.String identifierApostroph(java.lang.String value)
           
 boolean isEmpty()
          Returns true if no object is contained within the storage.
 void reset()
          Reset the storage with all it's meta structures and caches.
 
Methods inherited from class org.openbandy.io.storage.Storage
closeAllConnections, delete, removeConnection, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DatabaseStorage getInstance()

getDatabaseConnection

public DatabaseConnection getDatabaseConnection(java.lang.String owner)
Parameters:
owner - A string describing the user of the connection.
Returns:
A new and open DatabaseConnection. null if not able to connect.

existsInStorage

public int existsInStorage(Serializable serializable)
Return 0 if databaseSerializable does not already exist in database. If databaseSerializable exist, this method returns the id according to databaseSerializable.getKeyName().

Specified by:
existsInStorage in class Storage
Parameters:
databaseSerializable -
Returns:

closeConnection

public void closeConnection(DatabaseConnection connection)

deleteShallow

public boolean deleteShallow(Serializable serializable)
Description copied from class: Storage
Deletes the serializable object, but not the reference objects.

Specified by:
deleteShallow in class Storage
Returns:
true if deletion was successful

reset

public void reset()
Description copied from class: Storage
Reset the storage with all it's meta structures and caches. Use carefully!

Specified by:
reset in class Storage

isEmpty

public boolean isEmpty()
Description copied from class: Storage
Returns true if no object is contained within the storage.

Specified by:
isEmpty in class Storage

identifierApostroph

public static java.lang.String identifierApostroph(java.lang.String value)

apostrophe

public static java.lang.String apostrophe(java.lang.String value)

bracket

public static java.lang.String bracket(java.lang.String value)

getTableName

public static java.lang.String getTableName(Serializable serializable)