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.util.*; 53 54 57 public class CollectionDeserializer extends AbstractListDeserializer { 58 private Class _type; 59 60 public CollectionDeserializer(Class type) 61 { 62 _type = type; 63 } 64 65 public Class getType() 66 { 67 return _type; 68 } 69 70 public Object readList(AbstractHessianInput in, int length) 71 throws IOException  72 { 73 Collection list = null; 74 75 if (_type == null) 76 list = new ArrayList(); 77 else if (! _type.isInterface()) { 78 try { 79 list = (Collection) _type.newInstance(); 80 } catch (Exception e) { 81 } 82 } 83 84 if (list != null) { 85 } 86 else if (SortedSet.class.isAssignableFrom(_type)) 87 list = new TreeSet(); 88 else if (Set.class.isAssignableFrom(_type)) 89 list = new HashSet(); 90 else if (List.class.isAssignableFrom(_type)) 91 list = new ArrayList(); 92 else if (Collection.class.isAssignableFrom(_type)) 93 list = new ArrayList(); 94 else { 95 try { 96 list = (Collection) _type.newInstance(); 97 } catch (Exception e) { 98 throw new IOExceptionWrapper(e); 99 } 100 } 101 102 in.addRef(list); 103 104 while (! in.isEnd()) 105 list.add(in.readObject()); 106 107 in.readEnd(); 108 109 return list; 110 } 111 } 112 113 114
| Popular Tags
|