Berkeley DB
version 4.2.52

com.sleepycat.bdb.bind.serial
Class SerialBinding

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

public class SerialBinding
extends Object
implements DataBinding

A concrete serial binding for keys or values. This binding stores objects in serial data format. If this class is used "as is" the deserialized objects are returned by the binding, and these objects must be serializable.

The class may also be extended to override the dataToObject(Object) and objectToData(Object) methods in order to map between the deserialized objects and other objects. In that case the objects returned by the binding do not have to be serializable. Note that both methods must be overridden.


Constructor Summary
SerialBinding(SerialFormat format)
          Creates a serial binding.
 
Method Summary
 Object dataToObject(DataBuffer data)
          Converts a data buffer into an Object.
 Object dataToObject(Object data)
          Can be overridden to convert the deserialized data object to another object.
 DataFormat getDataFormat()
          Returns the format used for the data of this binding.
 Object objectToData(Object object)
          Can be overridden to convert the object to a deserialized data object.
 void objectToData(Object object, DataBuffer data)
          Converts an Object into a data buffer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialBinding

public SerialBinding(SerialFormat format)
Creates a serial binding.

Parameters:
format - is the format of the new binding.
Method Detail

dataToObject

public Object dataToObject(DataBuffer data)
                    throws IOException
Description copied from interface: DataBinding
Converts a data buffer into an Object.

Specified by:
dataToObject in interface DataBinding
Parameters:
data - is the source data buffer.
Returns:
the resulting Object.
IOException

objectToData

public void objectToData(Object object,
                         DataBuffer data)
                  throws IOException
Description copied from interface: DataBinding
Converts an Object into a data buffer.

Specified by:
objectToData in interface DataBinding
Parameters:
object - is the source Object.
data - is the destination data buffer.
IOException

getDataFormat

public DataFormat getDataFormat()
Description copied from interface: DataBinding
Returns the format used for the data of this binding.

Specified by:
getDataFormat in interface DataBinding
Returns:
the data format.

dataToObject

public Object dataToObject(Object data)
                    throws IOException
Can be overridden to convert the deserialized data object to another object. This method is called by dataToObject(DataBuffer) after deserializing the data. The default implemention simply returns the data parameter.

Parameters:
data - is the deserialized data object (will always be serializable).
Returns:
the resulting object.
IOException

objectToData

public Object objectToData(Object object)
                    throws IOException
Can be overridden to convert the object to a deserialized data object. This method is called by objectToData(Object,DataBuffer) before serializing the object. The default implemention simply returns the object parameter.

Parameters:
object - is the source object.
Returns:
the resulting deserialized object (must be serializable)..
IOException

Berkeley DB
version 4.2.52

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