db4o 6.1

com.db4o.config
Interface ObjectMarshaller


public interface ObjectMarshaller

interface for custom marshallers. Custom marshallers can be used for tuning the performance to store and read objects. Instead of letting db4o do all the marshalling by detecting the fields on a class and by using reflection, a custom ObjectMarshaller allows the application developer to write the logic how the fields of an object are converted to a byte[] and back.

To implement a custom marshaller, write a class that implements the methods of the ObjectMarshaller interface and register it for your persistent class:
Db4o.configure().objectClass(YourClass.class).marshallWith(yourMarshaller);


Method Summary
 int marshalledFieldLength()
          return the length the marshalled fields will occupy in the slot byte[].
 void readFields(java.lang.Object obj, byte[] slot, int offset)
          implement to read the values of fields from a byte[] and to set them on an object when the object gets instantiated
 void writeFields(java.lang.Object obj, byte[] slot, int offset)
          implement to write the values of fields to a byte[] when an object gets stored.
 

Method Detail

writeFields

void writeFields(java.lang.Object obj,
                 byte[] slot,
                 int offset)
implement to write the values of fields to a byte[] when an object gets stored.

Parameters:
obj - the object that is stored
slot - the byte[] where the fields are to be written
offset - the offset position in the byte[] where the first field value can be written

readFields

void readFields(java.lang.Object obj,
                byte[] slot,
                int offset)
implement to read the values of fields from a byte[] and to set them on an object when the object gets instantiated

Parameters:
obj - the object that is instantiated
slot - the byte[] where the fields are to be read from
offset - the offset position in the byte[] where the first field value is to be read from

marshalledFieldLength

int marshalledFieldLength()
return the length the marshalled fields will occupy in the slot byte[]. You may not write beyond this offset when you store fields.

Returns:
the marshalled length of the fields.

db4o 6.1