Berkeley DB
version 4.4.20

Class SerialBinding

  extended bycom.sleepycat.bind.serial.SerialBase
      extended bycom.sleepycat.bind.serial.SerialBinding
All Implemented Interfaces:

public class SerialBinding
extends SerialBase
implements EntryBinding

A concrete EntryBinding that treats a key or data entry as a serialized object.

This binding stores objects in serialized object format. The deserialized objects are returned by the binding, and their Class must implement the Serializable interface.

Constructor Summary
SerialBinding(ClassCatalog classCatalog, Class baseClass)
          Creates a serial binding.
Method Summary
 Object entryToObject(DatabaseEntry entry)
          Deserialize an object from an entry buffer.
 Class getBaseClass()
          Returns the base class for this binding.
 ClassLoader getClassLoader()
          Returns the class loader to be used during deserialization, or null if a default class loader should be used.
 void objectToEntry(Object object, DatabaseEntry entry)
          Serialize an object into an entry buffer.
Methods inherited from class com.sleepycat.bind.serial.SerialBase
getSerialBufferSize, getSerialOutput, setSerialBufferSize
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SerialBinding(ClassCatalog classCatalog,
                     Class baseClass)
Creates a serial binding.

classCatalog - is the catalog to hold shared class information and for a database should be a StoredClassCatalog.
baseClass - is the base class for serialized objects stored using this binding -- all objects using this binding must be an instance of this class.
Method Detail


public final Class getBaseClass()
Returns the base class for this binding.

the base class for this binding.


public ClassLoader getClassLoader()
Returns the class loader to be used during deserialization, or null if a default class loader should be used. The default implementation of this method returns null.

This method may be overriden to return a dynamically determined class loader. For example, Thread.currentThread().getContextClassLoader() could be called to use the context class loader for the curren thread. Or getBaseClass().getClassLoader() could be called to use the class loader for the base class, assuming that a base class has been specified.

If this method returns null, a default class loader will be used as determined by the method.


public Object entryToObject(DatabaseEntry entry)
Deserialize an object from an entry buffer. May only be called for data that was serialized using objectToEntry(java.lang.Object, com.sleepycat.db.DatabaseEntry), since the fixed serialization header is assumed to not be included in the input data. SerialInput is used to deserialize the object.

Specified by:
entryToObject in interface EntryBinding
entry - is the input serialized entry.
the output deserialized object.


public void objectToEntry(Object object,
                          DatabaseEntry entry)
Serialize an object into an entry buffer. The fixed serialization header is not included in the output data to save space, and therefore to deserialize the data the complementary entryToObject(com.sleepycat.db.DatabaseEntry) method must be used. SerialOutput is used to serialize the object.

Note that this method sets the DatabaseEntry offset property to a non-zero value and the size property to a value less than the length of the byte array.

Specified by:
objectToEntry in interface EntryBinding
object - is the input deserialized object.
entry - is the output serialized entry.
IllegalArgumentException - if the object is not an instance of the base class for this binding.

Berkeley DB
version 4.4.20

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.