All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickntap.tool.hessian.BigIntegerSerializer Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
package com.clickntap.tool.hessian;

import com.caucho.hessian.io.AbstractHessianOutput;
import com.caucho.hessian.io.AbstractSerializer;

import java.io.IOException;
import java.math.BigInteger;

public class BigIntegerSerializer extends AbstractSerializer {
    public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {

        if (obj == null)
            out.writeNull();
        else {
            Class cl = obj.getClass();

            if (out.addRef(obj))
                return;

            int ref = out.writeObjectBegin(cl.getName());

            BigInteger bi = (BigInteger) obj;

            if (ref < -1) {
                out.writeString("value");
                out.writeString(bi.toString());
                out.writeMapEnd();
            } else {
                if (ref == -1) {
                    out.writeInt(1);
                    out.writeString("value");
                    out.writeObjectBegin(cl.getName());
                }

                out.writeString(bi.toString());
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy