1 8 9 package com.sleepycat.bind.serial; 10 11 import com.sleepycat.bind.tuple.MarshalledTupleKeyEntity; 12 import com.sleepycat.bind.tuple.TupleInput; 13 import com.sleepycat.bind.tuple.TupleOutput; 14 15 23 public class TupleSerialMarshalledKeyCreator extends TupleSerialKeyCreator { 24 25 private TupleSerialMarshalledBinding binding; 26 private String keyName; 27 28 37 public TupleSerialMarshalledKeyCreator(TupleSerialMarshalledBinding 38 binding, 39 String keyName) { 40 41 super(binding.dataBinding); 42 this.binding = binding; 43 this.keyName = keyName; 44 45 if (dataBinding == null) { 46 throw new NullPointerException ("dataBinding may not be null"); 47 } 48 } 49 50 public boolean createSecondaryKey(TupleInput primaryKeyInput, 52 Object dataInput, 53 TupleOutput indexKeyOutput) { 54 55 60 MarshalledTupleKeyEntity entity = (MarshalledTupleKeyEntity) 61 binding.entryToObject(primaryKeyInput, dataInput); 62 63 return entity.marshalSecondaryKey(keyName, indexKeyOutput); 64 } 65 66 public Object nullifyForeignKey(Object dataInput) { 68 69 MarshalledTupleKeyEntity entity = (MarshalledTupleKeyEntity) 70 binding.entryToObject(null, dataInput); 71 72 return entity.nullifyForeignKey(keyName) ? dataInput : null; 73 } 74 } 75 | Popular Tags |