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

org.tinygroup.nettyremote.codec.serialization.BigDecimalSerializer Maven / Gradle / Ivy

There is a newer version: 3.4.1
Show newest version
package org.tinygroup.nettyremote.codec.serialization;

import java.io.IOException;
import java.math.BigDecimal;

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

public class BigDecimalSerializer extends AbstractSerializer {

@Override
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());

        BigDecimal bi = (BigDecimal) 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 - 2025 Weber Informatics LLC | Privacy Policy