1 48 49 package com.caucho.hessian.io; 50 51 import java.io.IOException ; 52 import java.util.Iterator ; 53 54 57 public class IteratorSerializer extends AbstractSerializer { 58 private static IteratorSerializer _serializer; 59 60 public static IteratorSerializer create() 61 { 62 if (_serializer == null) 63 _serializer = new IteratorSerializer(); 64 65 return _serializer; 66 } 67 68 public void writeObject(Object obj, AbstractHessianOutput out) 69 throws IOException 70 { 71 Iterator iter = (Iterator ) obj; 72 73 boolean hasEnd = out.writeListBegin(-1, null); 74 75 while (iter.hasNext()) { 76 Object value = iter.next(); 77 78 out.writeObject(value); 79 } 80 81 if (hasEnd) 82 out.writeListEnd(); 83 } 84 } 85 | Popular Tags |