1 48 49 package com.caucho.hessian.io; 50 51 import java.io.IOException ; 52 53 56 public class ArraySerializer extends AbstractSerializer { 57 public void writeObject(Object obj, AbstractHessianOutput out) 58 throws IOException 59 { 60 if (out.addRef(obj)) 61 return; 62 63 Object []array = (Object []) obj; 64 65 boolean hasEnd = out.writeListBegin(array.length, 66 getArrayType(obj.getClass())); 67 68 for (int i = 0; i < array.length; i++) 69 out.writeObject(array[i]); 70 71 if (hasEnd) 72 out.writeListEnd(); 73 } 74 75 78 private String getArrayType(Class cl) 79 { 80 if (cl.isArray()) 81 return '[' + getArrayType(cl.getComponentType()); 82 83 String name = cl.getName(); 84 85 if (name.equals("java.lang.String")) 86 return "string"; 87 else if (name.equals("java.lang.Object")) 88 return "object"; 89 else if (name.equals("java.util.Date")) 90 return "date"; 91 else 92 return name; 93 } 94 } 95 | Popular Tags |