com.sleepycat.bind.serial
Class TupleSerialKeyCreator

java.lang.Object
  extended by com.sleepycat.bind.tuple.TupleBase
      extended by com.sleepycat.bind.serial.TupleSerialKeyCreator
All Implemented Interfaces:
ForeignKeyNullifier, SecondaryKeyCreator
Direct Known Subclasses:
TupleSerialMarshalledKeyCreator

public abstract class TupleSerialKeyCreator
extends TupleBase
implements SecondaryKeyCreator, ForeignKeyNullifier

A abstract key creator that uses a tuple key and a serial data entry. This class takes care of serializing and deserializing the data entry, and converting the key entry to/from TupleInput and TupleOutput objects. The following abstract method must be implemented by a concrete subclass to create the index key using these objects

If ForeignKeyDeleteAction.NULLIFY was specified when opening the secondary database, the following method must be overridden to nullify the foreign index key. If NULLIFY was not specified, this method need not be overridden.

Author:
Mark Hayes

Field Summary
protected  SerialBinding dataBinding
           
 
Constructor Summary
TupleSerialKeyCreator(ClassCatalog classCatalog, Class dataClass)
          Creates a tuple-serial key creator.
TupleSerialKeyCreator(SerialBinding dataBinding)
          Creates a tuple-serial key creator.
 
Method Summary
 boolean createSecondaryKey(SecondaryDatabase db, DatabaseEntry primaryKeyEntry, DatabaseEntry dataEntry, DatabaseEntry indexKeyEntry)
          Javadoc for this public method is generated via the doc templates in the doc_src directory.
abstract  boolean createSecondaryKey(TupleInput primaryKeyInput, Object dataInput, TupleOutput indexKeyOutput)
          Creates the index key entry from primary key tuple entry and deserialized data entry.
 Object nullifyForeignKey(Object data)
          Clears the index key in the deserialized data entry.
 boolean nullifyForeignKey(SecondaryDatabase db, DatabaseEntry dataEntry)
          Javadoc for this public method is generated via the doc templates in the doc_src directory.
 
Methods inherited from class com.sleepycat.bind.tuple.TupleBase
entryToInput, getTupleBufferSize, getTupleOutput, inputToEntry, newOutput, newOutput, outputToEntry, setTupleBufferSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataBinding

protected SerialBinding dataBinding
Constructor Detail

TupleSerialKeyCreator

public TupleSerialKeyCreator(ClassCatalog classCatalog,
                             Class dataClass)
Creates a tuple-serial key creator.

Parameters:
classCatalog - is the catalog to hold shared class information and for a database should be a StoredClassCatalog.
dataClass - is the data base class.

TupleSerialKeyCreator

public TupleSerialKeyCreator(SerialBinding dataBinding)
Creates a tuple-serial key creator.

Parameters:
dataBinding - is the data binding.
Method Detail

createSecondaryKey

public boolean createSecondaryKey(SecondaryDatabase db,
                                  DatabaseEntry primaryKeyEntry,
                                  DatabaseEntry dataEntry,
                                  DatabaseEntry indexKeyEntry)
                           throws DatabaseException
Description copied from interface: SecondaryKeyCreator
Javadoc for this public method is generated via the doc templates in the doc_src directory.

Specified by:
createSecondaryKey in interface SecondaryKeyCreator
Throws:
DatabaseException

nullifyForeignKey

public boolean nullifyForeignKey(SecondaryDatabase db,
                                 DatabaseEntry dataEntry)
                          throws DatabaseException
Description copied from interface: ForeignKeyNullifier
Javadoc for this public method is generated via the doc templates in the doc_src directory.

Specified by:
nullifyForeignKey in interface ForeignKeyNullifier
Throws:
DatabaseException

createSecondaryKey

public abstract boolean createSecondaryKey(TupleInput primaryKeyInput,
                                           Object dataInput,
                                           TupleOutput indexKeyOutput)
Creates the index key entry from primary key tuple entry and deserialized data entry.

Parameters:
primaryKeyInput - is the TupleInput for the primary key entry, or null if no primary key entry is used to construct the index key.
dataInput - is the deserialized data entry, or null if no data entry is used to construct the index key.
indexKeyOutput - is the destination index key tuple. For index keys which are optionally present, no tuple entry should be output to indicate that the key is not present or null.
Returns:
true if a key was created, or false to indicate that the key is not present.

nullifyForeignKey

public Object nullifyForeignKey(Object data)
Clears the index key in the deserialized data entry.

On entry the data parameter contains the index key to be cleared. It should be changed by this method such that createSecondaryKey(com.sleepycat.je.SecondaryDatabase, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry) will return false. Other fields in the data object should remain unchanged.

Parameters:
data - is the source and destination deserialized data entry.
Returns:
the destination data object, or null to indicate that the key is not present and no change is necessary. The data returned may be the same object passed as the data parameter or a newly created object.


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.