00001
00002
00003
00004
00005
00006
00007
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
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
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 }