1 48 49 package com.caucho.hessian.io; 50 51 import java.io.IOException ; 52 import java.util.HashMap ; 53 import java.util.Iterator ; 54 import java.util.Map ; 55 56 59 public class MapSerializer extends AbstractSerializer { 60 public void writeObject(Object obj, AbstractHessianOutput out) 61 throws IOException 62 { 63 if (out.addRef(obj)) 64 return; 65 66 Map map = (Map ) obj; 67 68 Class cl = obj.getClass(); 69 if (cl.equals(HashMap .class)) 70 out.writeMapBegin(null); 71 else 72 out.writeMapBegin(obj.getClass().getName()); 73 74 Iterator iter = map.entrySet().iterator(); 75 while (iter.hasNext()) { 76 Map.Entry entry = (Map.Entry ) iter.next(); 77 78 out.writeObject(entry.getKey()); 79 out.writeObject(entry.getValue()); 80 } 81 out.writeMapEnd(); 82 } 83 } 84 | Popular Tags |