Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 48 49 package com.caucho.hessian.io; 50 51 import java.io.IOException ; 52 import java.io.OutputStream ; 53 import java.lang.reflect.Field ; 54 import java.lang.reflect.Method ; 55 import java.lang.reflect.Modifier ; 56 57 85 public class HessianSerializerOutput extends HessianOutput { 86 92 public HessianSerializerOutput(OutputStream os) 93 { 94 super(os); 95 } 96 97 100 public HessianSerializerOutput() 101 { 102 } 103 104 109 public void writeObjectImpl(Object obj) 110 throws IOException  111 { 112 Class cl = obj.getClass(); 113 114 try { 115 Method method = cl.getMethod("writeReplace", new Class [0]); 116 Object repl = method.invoke(obj, new Object [0]); 117 118 writeObject(repl); 119 return; 120 } catch (Exception e) { 121 } 122 123 try { 124 writeMapBegin(cl.getName()); 125 for (; cl != null; cl = cl.getSuperclass()) { 126 Field []fields = cl.getDeclaredFields(); 127 for (int i = 0; i < fields.length; i++) { 128 Field field = fields[i]; 129 130 if (Modifier.isTransient(field.getModifiers()) || 131 Modifier.isStatic(field.getModifiers())) 132 continue; 133 134 field.setAccessible(true); 136 137 writeString(field.getName()); 138 writeObject(field.get(obj)); 139 } 140 } 141 writeMapEnd(); 142 } catch (IllegalAccessException e) { 143 throw new IOExceptionWrapper(e); 144 } 145 } 146 } 147
| Popular Tags
|