1 19 20 package org.apache.cayenne.remote.hessian; 21 22 import java.io.IOException ; 23 import java.lang.reflect.Field ; 24 25 import org.apache.cayenne.CayenneRuntimeException; 26 import org.apache.cayenne.DataRow; 27 28 import com.caucho.hessian.io.AbstractHessianInput; 29 import com.caucho.hessian.io.AbstractMapDeserializer; 30 31 37 class DataRowDeserializer extends AbstractMapDeserializer { 38 39 protected Field versionField; 40 41 DataRowDeserializer() { 42 try { 43 versionField = DataRow.class.getDeclaredField("version"); 44 } 45 catch (Exception e) { 46 throw new CayenneRuntimeException( 47 "Error building deserializer for DataRow", 48 e); 49 } 50 51 versionField.setAccessible(true); 52 } 53 54 public Class getType() { 55 return DataRow.class; 56 } 57 58 public Object readMap(AbstractHessianInput in) throws IOException { 59 60 int size = in.readInt(); 61 DataRow row = new DataRow(size); 62 try { 63 versionField.set(row, new Long (in.readLong())); 64 } 65 catch (Exception e) { 66 throw new IOException ("Error reading 'version' field"); 67 } 68 69 row.setReplacesVersion(in.readLong()); 70 in.addRef(row); 71 72 while (!in.isEnd()) { 73 row.put(in.readObject(), in.readObject()); 74 } 75 76 in.readEnd(); 77 78 return row; 79 } 80 } 81 | Popular Tags |