org.openbandy.io.db
Class DatabaseSerializerImpl

java.lang.Object
  extended by org.openbandy.io.db.DatabaseSerializerImpl
All Implemented Interfaces:
DatabaseSerializer, Serializer, StorageSerializer

public class DatabaseSerializerImpl
extends java.lang.Object
implements DatabaseSerializer

The Database Serializer provides a service to load and store serializable objects to respectively from a JDBC compliant database. Thus, in order to store a Serializable object, the DatabaseSerializerImpl creates a new DatabaseValueContainer object and passes it to the object that needs to be serialized, i.e., stored in the database. This object will fill the container as described in 3.2.2. Subsequently, the DatabaseSerializerImpl tests, if the given object already exists in the database, using the DatabaseStorageís existsInStorage() method described below. Accordingly, it will either create an INSERT or an UPDATE statement from the container object, using the SqlStatement class. Finally, the DatabaseSerializerImpl invokes the DatabaseConnection instance, it got from the DatabaseStorage, to execute this statement. In all cases, the DatabaseSerializerImpl will update the Serializable objectís numeric identifier to the actual values used in the database. To load an object from the database, the DatabaseSerializerImpl must create the corresponding SELECT statement, again using the SqlStatement class. The resulting ResultSet is subsequently encapsulated in a DatabaseValueContainer object, which will be passed to the serializable object for deserialization. Every object gets stored in the database in its own table, whereas must hold: classname = tablename attributename = fieldname

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

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

Field Summary
 
Fields inherited from interface org.openbandy.io.Serializer
MODE_DATABASE, MODE_DEFAULT, MODE_RMS, MODE_STREAM
 
Constructor Summary
DatabaseSerializerImpl()
           
 
Method Summary
 void deserializeObject(Serializable serializable, SerializationBuffer serializationBuffer)
          TODO comment!
 Storage getStorage()
          TODO describe purpose an usage
 boolean load(Serializable serializable, int id)
          Load an object that has been serialized before, refernced by the object's ID.
 void serializeObject(Serializable serializable, SerializationBuffer serializationBuffer)
          TODO comment!
 void store(Serializable serializable)
          TODO describe purpose an usage
 void updateReferences(ObjectEntry objectEntry)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseSerializerImpl

public DatabaseSerializerImpl()
Method Detail

getStorage

public Storage getStorage()
Description copied from interface: StorageSerializer
TODO describe purpose an usage

Specified by:
getStorage in interface StorageSerializer
Returns:

store

public void store(Serializable serializable)
Description copied from interface: StorageSerializer
TODO describe purpose an usage

Specified by:
store in interface StorageSerializer

load

public boolean load(Serializable serializable,
                    int id)
Load an object that has been serialized before, refernced by the object's ID.

Specified by:
load in interface StorageSerializer

serializeObject

public void serializeObject(Serializable serializable,
                            SerializationBuffer serializationBuffer)
Description copied from interface: Serializer
TODO comment!

Specified by:
serializeObject in interface Serializer

deserializeObject

public void deserializeObject(Serializable serializable,
                              SerializationBuffer serializationBuffer)
Description copied from interface: Serializer
TODO comment!

Specified by:
deserializeObject in interface Serializer

updateReferences

public void updateReferences(ObjectEntry objectEntry)