1 8 9 package com.sleepycat.bind.tuple; 10 11 import com.sleepycat.je.DatabaseEntry; 12 import com.sleepycat.je.DatabaseException; 13 import com.sleepycat.je.ForeignKeyNullifier; 14 import com.sleepycat.je.SecondaryDatabase; 15 import com.sleepycat.je.SecondaryKeyCreator; 16 17 42 public abstract class TupleTupleKeyCreator extends TupleBase 43 implements SecondaryKeyCreator, ForeignKeyNullifier { 44 45 48 public TupleTupleKeyCreator() { 49 } 50 51 public boolean createSecondaryKey(SecondaryDatabase db, 53 DatabaseEntry primaryKeyEntry, 54 DatabaseEntry dataEntry, 55 DatabaseEntry indexKeyEntry) 56 throws DatabaseException { 57 58 TupleOutput output = getTupleOutput(null); 59 TupleInput primaryKeyInput = entryToInput(primaryKeyEntry); 60 TupleInput dataInput = entryToInput(dataEntry); 61 if (createSecondaryKey(primaryKeyInput, dataInput, output)) { 62 outputToEntry(output, indexKeyEntry); 63 return true; 64 } else { 65 return false; 66 } 67 } 68 69 public boolean nullifyForeignKey(SecondaryDatabase db, 71 DatabaseEntry dataEntry) 72 throws DatabaseException { 73 74 TupleOutput output = getTupleOutput(null); 75 if (nullifyForeignKey(entryToInput(dataEntry), output)) { 76 outputToEntry(output, dataEntry); 77 return true; 78 } else { 79 return false; 80 } 81 } 82 83 96 public abstract boolean createSecondaryKey(TupleInput primaryKeyInput, 97 TupleInput dataInput, 98 TupleOutput indexKeyOutput); 99 100 116 public boolean nullifyForeignKey(TupleInput dataInput, 117 TupleOutput dataOutput) { 118 119 return false; 120 } 121 } 122 | Popular Tags |