Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TupleTupleKeyCreator.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TupleTupleKeyCreator.java,v 12.2 2005/08/01 20:25:17 mark Exp $
00008  */
00009 
00010 package com.sleepycat.bind.tuple;
00011 
00012 import com.sleepycat.db.DatabaseEntry;
00013 import com.sleepycat.db.DatabaseException;
00014 import com.sleepycat.db.SecondaryDatabase;
00015 import com.sleepycat.db.SecondaryKeyCreator;
00016 
00024 public abstract class TupleTupleKeyCreator extends TupleBase
00025     implements SecondaryKeyCreator {
00026 
00030     public TupleTupleKeyCreator() {
00031     }
00032 
00033     // javadoc is inherited
00034     public boolean createSecondaryKey(SecondaryDatabase db,
00035                                       DatabaseEntry primaryKeyEntry,
00036                                       DatabaseEntry dataEntry,
00037                                       DatabaseEntry indexKeyEntry)
00038         throws DatabaseException {
00039 
00040         TupleOutput output = getTupleOutput(null);
00041         TupleInput primaryKeyInput = entryToInput(primaryKeyEntry);
00042         TupleInput dataInput = entryToInput(dataEntry);
00043         if (createSecondaryKey(primaryKeyInput, dataInput, output)) {
00044             outputToEntry(output, indexKeyEntry);
00045             return true;
00046         } else {
00047             return false;
00048         }
00049     }
00050 
00051     // javadoc is inherited
00052     public boolean nullifyForeignKey(SecondaryDatabase db,
00053                                      DatabaseEntry dataEntry)
00054         throws DatabaseException {
00055 
00056         TupleOutput output = getTupleOutput(null);
00057         if (nullifyForeignKey(entryToInput(dataEntry), output)) {
00058             outputToEntry(output, dataEntry);
00059             return true;
00060         } else {
00061             return false;
00062         }
00063     }
00064 
00078     public abstract boolean createSecondaryKey(TupleInput primaryKeyInput,
00079                                                TupleInput dataInput,
00080                                                TupleOutput indexKeyOutput);
00081 
00098     public boolean nullifyForeignKey(TupleInput dataInput,
00099                                      TupleOutput dataOutput) {
00100 
00101         return false;
00102     }
00103 }

Generated on Sun Dec 25 12:14:30 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2