public void writeObject()

in hessian-lite/src/main/java/com/alibaba/com/caucho/hessian/io/CollectionSerializer.java [77:116]


    public void writeObject(Object obj, AbstractHessianOutput out)
            throws IOException {
        if (out.addRef(obj))
            return;

        Collection list = (Collection) obj;

        Class cl = obj.getClass();
        boolean hasEnd;

        if (cl.equals(ArrayList.class)
                || !Serializable.class.isAssignableFrom(cl)) {
            hasEnd = out.writeListBegin(list.size(), null);
        } else if (!_sendJavaType) {
            hasEnd = false;

            // hessian/3a19
            for (; cl != null; cl = cl.getSuperclass()) {
                if (cl.getName().startsWith("java.")) {
                    hasEnd = out.writeListBegin(list.size(), cl.getName());
                    break;
                }
            }

            if (cl == null)
                hasEnd = out.writeListBegin(list.size(), null);
        } else {
            hasEnd = out.writeListBegin(list.size(), obj.getClass().getName());
        }

        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            Object value = iter.next();

            out.writeObject(value);
        }

        if (hasEnd)
            out.writeListEnd();
    }