Berkeley DB
version 4.2.52

com.sleepycat.bdb.bind.tuple
Class TupleBinding

java.lang.Object
  |
  +--com.sleepycat.bdb.bind.tuple.TupleBinding
All Implemented Interfaces:
DataBinding
Direct Known Subclasses:
TupleMarshalledBinding

public abstract class TupleBinding
extends Object
implements DataBinding

An abstract tuple binding for tuple keys or values. This class takes care of converting the data to/from TupleInput and TupleOutput objects. Its two abstract methods must be implemented by a concrete subclass to convert between tuples and key or value objects.

For keys or values which are Java primitive classes (String, Integer, etc) getPrimitiveBinding(java.lang.Class, com.sleepycat.bdb.bind.tuple.TupleFormat) may be used to return a builtin tuple binding. A custom tuple binding for these types is not needed.


Constructor Summary
TupleBinding(TupleFormat format)
          Creates a tuple binding.
 
Method Summary
 Object dataToObject(DataBuffer data)
          Converts a data buffer into an Object.
abstract  Object dataToObject(TupleInput input)
          Constructs a key or value object from TupleInput data.
 DataFormat getDataFormat()
          Returns the format used for the data of this binding.
static TupleBinding getPrimitiveBinding(Class cls, TupleFormat format)
          Creates a tuple binding for a primitive Java class.
 void objectToData(Object object, DataBuffer data)
          Converts an Object into a data buffer.
abstract  void objectToData(Object object, TupleOutput output)
          Converts a key or value object to a tuple data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TupleBinding

public TupleBinding(TupleFormat format)
Creates a tuple 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 abstract Object dataToObject(TupleInput input)
                             throws IOException
Constructs a key or value object from TupleInput data.

Parameters:
input - is the tuple key or value data.
Returns:
the key or value object constructed from the data.
IOException

objectToData

public abstract void objectToData(Object object,
                                  TupleOutput output)
                           throws IOException
Converts a key or value object to a tuple data.

Parameters:
object - is the key or value object.
output - is the tuple data to which the key or value should be written.
IOException

getPrimitiveBinding

public static TupleBinding getPrimitiveBinding(Class cls,
                                               TupleFormat format)
Creates a tuple binding for a primitive Java class. The following Java classes are supported.

Parameters:
cls - is the primitive Java class.
format - is the tuple format for the new binding.
Returns:
a new building for the primitive class or null if the cls parameter is not one of the supported classes.

Berkeley DB
version 4.2.52

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