messif.buckets.storage.impl
Class DatabaseStorage.BinarySerializableColumnConvertor<T>

java.lang.Object
  extended by messif.buckets.storage.impl.DatabaseStorage.BinarySerializableColumnConvertor<T>
Type Parameters:
T - the class of instances that are serialized into the database
All Implemented Interfaces:
java.io.Serializable, DatabaseStorage.ColumnConvertor<T>
Enclosing class:
DatabaseStorage<T>

public static class DatabaseStorage.BinarySerializableColumnConvertor<T>
extends java.lang.Object
implements DatabaseStorage.ColumnConvertor<T>

Column convertor that uses a database BLOB into which instances of T are binary serialized/deserialized.

See Also:
Serialized Form

Constructor Summary
DatabaseStorage.BinarySerializableColumnConvertor(java.lang.Class<? extends T> storedObjectsClass, BinarySerializator serializator)
          Creates a new instance of BinarySerializableColumnConvertor.
 
Method Summary
 T convertFromColumnValue(T value, java.lang.Object column)
          Returns an instance of object from the database column value.
 java.lang.Object convertToColumnValue(T instance)
          Returns a value that can be stored in a database column for the given instance.
 boolean isColumnCompatible(IndexComparator<?,?> indexComparator)
          Returns true if the instance created by this convertor is compatible with the given index comparator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseStorage.BinarySerializableColumnConvertor

public DatabaseStorage.BinarySerializableColumnConvertor(java.lang.Class<? extends T> storedObjectsClass,
                                                         BinarySerializator serializator)
Creates a new instance of BinarySerializableColumnConvertor.

Parameters:
storedObjectsClass - the class of instances that are serialized by this column convertor
serializator - the serializator that is used for storing/restoring the data into the database
Method Detail

convertToColumnValue

public java.lang.Object convertToColumnValue(T instance)
                                      throws BucketStorageException
Description copied from interface: DatabaseStorage.ColumnConvertor
Returns a value that can be stored in a database column for the given instance.

Specified by:
convertToColumnValue in interface DatabaseStorage.ColumnConvertor<T>
Parameters:
instance - the object instance from which to create a database value
Returns:
a database value
Throws:
BucketStorageException - if the value cannot be converted

convertFromColumnValue

public T convertFromColumnValue(T value,
                                java.lang.Object column)
                         throws BucketStorageException
Description copied from interface: DatabaseStorage.ColumnConvertor
Returns an instance of object from the database column value. A value created by previous columns is provided in value, which can be either replaced by a new value, modified by this method or left intact.

Specified by:
convertFromColumnValue in interface DatabaseStorage.ColumnConvertor<T>
Parameters:
value - the instance created by previous column convertors
column - the value of the column to convert
Returns:
an instance created from the column value
Throws:
BucketStorageException - if the value cannot be converted

isColumnCompatible

public boolean isColumnCompatible(IndexComparator<?,?> indexComparator)
Description copied from interface: DatabaseStorage.ColumnConvertor
Returns true if the instance created by this convertor is compatible with the given index comparator.

Specified by:
isColumnCompatible in interface DatabaseStorage.ColumnConvertor<T>
Parameters:
indexComparator - the index comparator that is checked for compatibility
Returns:
true if this column convertor works with compatible instances