1 19 package gcc.rmi.iiop; 20 21 import gcc.*; 22 import gcc.util.*; 23 import java.io.*; 24 25 public class SimpleObjectOutputStream extends ObjectOutputStream 26 { 27 public static ObjectOutputStream getInstance() 28 { 29 return getInstance(CdrOutputStream.getInstance()); 30 } 31 32 public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) 33 { 34 ObjectOutputStream output = null; 35 try 36 { 37 output = new SimpleObjectOutputStream(); 38 } 39 catch( Exception ex ) 40 { 41 throw new SystemException(ex); 42 } 43 44 output.init(cdrOutput); 45 return output; 46 } 47 48 52 56 public SimpleObjectOutputStream() throws IOException 57 { 58 super(); 59 } 60 61 public void $reset() 62 { 63 _cdrOutput.reset(); 64 } 65 66 public void recycle() 67 { 68 $reset(); 69 } 70 71 public void writeObject(ValueType type, Object value) 72 { 73 ObjectHelper h = type.helper; 74 if (h != null) 75 { 76 h.write(this, value); 77 return; 78 } 79 byte[] bytes = JavaObject.toByteArray(value); 80 if (bytes == null) bytes = ArrayUtil.EMPTY_BYTE_ARRAY; 81 _cdrOutput.write_octet_sequence(bytes); 82 } 83 84 88 protected void init(CdrOutputStream cdrOutput) 89 { 90 super.init(cdrOutput); 91 } 92 } 93 | Popular Tags |