Berkeley DB
version 4.2.52

com.sleepycat.bdb.bind.serial
Class SerialFormat

java.lang.Object
  |
  +--com.sleepycat.bdb.bind.serial.SerialFormat
All Implemented Interfaces:
DataFormat

public class SerialFormat
extends Object
implements DataFormat

The format for serialized data. In addition to identifying a serial format this class provides utility methods for use by bindings.


Constructor Summary
SerialFormat(ClassCatalog classCatalog, Class baseClass)
          Creates a serial format.
 
Method Summary
 Object dataToObject(DataBuffer data)
          Utility method for use by bindings to deserialize an object.
 Class getBaseClass()
          Returns the base class for this format.
 void objectToData(Object object, DataBuffer data)
          Utility method for use by bindings to serialize an object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialFormat

public SerialFormat(ClassCatalog classCatalog,
                    Class baseClass)
Creates a serial format.

Parameters:
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 format -- all objects using this format must be an instance of this class.
Method Detail

getBaseClass

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

Returns:
the base class for this format.

dataToObject

public final Object dataToObject(DataBuffer data)
                          throws IOException
Utility method for use by bindings to deserialize an object. May only be called for data that was serialized using objectToData(java.lang.Object, com.sleepycat.bdb.bind.DataBuffer), since the fixed serialization header is assumed to not be included in the input data. SerialInput is used to deserialize the object. If a deserialized object is cached in the buffer's data formation property, it is returned directly.

Parameters:
data - is the input serialized data.
Returns:
the output deserialized object.
IOException

objectToData

public final void objectToData(Object object,
                               DataBuffer data)
                        throws IOException
Utility method for use by bindings to serialize an object. The fixed serialization header is not included in the output data to save space, and therefore to deserialize the data the complementary dataToObject(com.sleepycat.bdb.bind.DataBuffer) method must be used. SerialOutput is used to serialize the object. The deserialized object is cached in the buffer's data formation property.

Parameters:
object - is the input deserialized object.
data - is the output serialized data.
Throws:
IllegalArgumentException - if the object is not an instance of the base class for this format.
IOException

Berkeley DB
version 4.2.52

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