1 8 9 package com.sleepycat.bind.tuple; 10 11 import com.sleepycat.util.RuntimeExceptionWrapper; 12 13 23 public class TupleMarshalledBinding extends TupleBinding { 24 25 private Class cls; 26 27 37 public TupleMarshalledBinding(Class cls) { 38 39 this.cls = cls; 40 41 42 if (!MarshalledTupleEntry.class.isAssignableFrom(cls)) { 43 throw new IllegalArgumentException (cls.toString() + 44 " does not implement MarshalledTupleEntry"); 45 } 46 } 47 48 public Object entryToObject(TupleInput input) { 50 51 try { 52 MarshalledTupleEntry obj = 53 (MarshalledTupleEntry) cls.newInstance(); 54 obj.unmarshalEntry(input); 55 return obj; 56 } catch (IllegalAccessException e) { 57 throw new RuntimeExceptionWrapper(e); 58 } catch (InstantiationException e) { 59 throw new RuntimeExceptionWrapper(e); 60 } 61 } 62 63 public void objectToEntry(Object object, TupleOutput output) { 65 66 MarshalledTupleEntry obj = (MarshalledTupleEntry) object; 67 obj.marshalEntry(output); 68 } 69 } 70 | Popular Tags |