00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 package com.sleepycat.bind.serial;
00011
00012 import com.sleepycat.bind.EntityBinding;
00013 import com.sleepycat.bind.tuple.TupleBase;
00014 import com.sleepycat.bind.tuple.TupleInput;
00015 import com.sleepycat.bind.tuple.TupleOutput;
00016 import com.sleepycat.db.DatabaseEntry;
00017
00034 public abstract class TupleSerialBinding extends TupleBase
00035 implements EntityBinding {
00036
00037 protected SerialBinding dataBinding;
00038
00047 public TupleSerialBinding(ClassCatalog classCatalog,
00048 Class baseClass) {
00049
00050 this(new SerialBinding(classCatalog, baseClass));
00051 }
00052
00058 public TupleSerialBinding(SerialBinding dataBinding) {
00059
00060 this.dataBinding = dataBinding;
00061 }
00062
00063
00064 public Object entryToObject(DatabaseEntry key, DatabaseEntry data) {
00065
00066 return entryToObject(entryToInput(key),
00067 dataBinding.entryToObject(data));
00068 }
00069
00070
00071 public void objectToKey(Object object, DatabaseEntry key) {
00072
00073 TupleOutput output = getTupleOutput(object);
00074 objectToKey(object, output);
00075 outputToEntry(output, key);
00076 }
00077
00078
00079 public void objectToData(Object object, DatabaseEntry data) {
00080
00081 object = objectToData(object);
00082 dataBinding.objectToEntry(object, data);
00083 }
00084
00095 public abstract Object entryToObject(TupleInput keyInput,
00096 Object dataInput);
00097
00106 public abstract void objectToKey(Object object, TupleOutput keyOutput);
00107
00115 public abstract Object objectToData(Object object);
00116 }