1 package com.quadcap.sql.io; 2 3 40 41 import java.io.Externalizable ; 42 import java.io.IOException ; 43 import java.io.ObjectOutput ; 44 import java.io.OutputStream ; 45 46 import java.util.Vector ; 47 48 import com.quadcap.util.Debug; 49 50 55 public class ObjectOutputStream 56 extends DataOutputStream 57 implements ObjectOutput 58 { 59 60 public ObjectOutputStream() { 61 super(null); 62 } 63 64 public ObjectOutputStream(OutputStream os) { 65 super(os); 66 } 67 68 final void writeObject(Externable ext) throws IOException { 69 Extern extern = ext.getExtern(); 70 extern.writeObject(this, ext); 71 } 72 73 public void writeObject(Object obj) throws IOException { 74 if (obj == null) { 75 write(0); 76 } else if (obj instanceof Externable) { 77 Extern extern = ((Externable)obj).getExtern(); 78 extern.writeObject(this, obj); 79 } else { 80 String className = obj.getClass().getName(); 81 Extern extern = Extern.get(className); 82 if (extern == null) { 83 throw new IOException ("Not externalizable: " + className); 84 } 85 extern.writeObject(this, obj); 86 } 87 } 88 } 89 | Popular Tags |