Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * See the file LICENSE for redistribution information.
   * Copyright (c) 2000, 2010 Oracle and/or its affiliates.  All rights reserved.
  package com.sleepycat.bind.serial;
A abstract key creator that uses a serial key and a serial data entry. This class takes care of serializing and deserializing the key and data entry automatically. The following abstract method must be implemented by a concrete subclass to create the index key using these objects

If 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.

Mark Hayes
See also:
Class Evolution
 public abstract class SerialSerialKeyCreator<PK,D,SK>
     implements SecondaryKeyCreatorForeignKeyNullifier {
     protected SerialBinding<PK> primaryKeyBinding;
     protected SerialBinding<D> dataBinding;
     protected SerialBinding<SK> indexKeyBinding;

Creates a serial-serial key creator.

classCatalog is the catalog to hold shared class information and for a database should be a StoredClassCatalog.
primaryKeyClass is the primary key base class.
dataClass is the data base class.
indexKeyClass is the index key base class.
     public SerialSerialKeyCreator(ClassCatalog classCatalog,
                                   Class<PK> primaryKeyClass,
                                   Class<D> dataClass,
                                   Class<SK> indexKeyClass) {
         this(new SerialBinding<PK>(classCatalogprimaryKeyClass),
              new SerialBinding<D>(classCatalogdataClass),
              new SerialBinding<SK>(classCatalogindexKeyClass));

Creates a serial-serial entity binding.

primaryKeyBinding is the primary key binding.
dataBinding is the data binding.
indexKeyBinding is the index key binding.
     public SerialSerialKeyCreator(SerialBinding<PK> primaryKeyBinding,
                                   SerialBinding<D> dataBinding,
                                   SerialBinding<SK> indexKeyBinding) {
         this. = primaryKeyBinding;
         this. = dataBinding;
         this. = indexKeyBinding;
     // javadoc is inherited
     public boolean createSecondaryKey(SecondaryDatabase db,
                                       DatabaseEntry primaryKeyEntry,
                                       DatabaseEntry dataEntry,
                                       DatabaseEntry indexKeyEntry) {
         PK primaryKeyInput =
         D dataInput = .entryToObject(dataEntry);
         SK indexKey = createSecondaryKey(primaryKeyInputdataInput);
         if (indexKey != null) {
             return true;
         } else {
             return false;
    // javadoc is inherited
    public boolean nullifyForeignKey(SecondaryDatabase db,
                                     DatabaseEntry dataEntry) {
        D data = .entryToObject(dataEntry);
        data = nullifyForeignKey(data);
        if (data != null) {
            return true;
        } else {
            return false;

Creates the index key object from primary key and data objects.

primaryKey is the deserialized source primary key entry, or null if no primary key entry is used to construct the index key.
data is the deserialized source data entry, or null if no data entry is used to construct the index key.
the destination index key object, or null to indicate that the key is not present.
    public abstract SK createSecondaryKey(PK primaryKey, D data);

Clears the index key in a data object.

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

data is the source and destination data object.
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.
    public D nullifyForeignKey(D data) {
        return null;
New to GrepCode? Check out our FAQ X