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

com.github.ddth.commons.serialization.FstSerDeser Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.github.ddth.commons.serialization;

import com.github.ddth.commons.utils.SerializationUtils;

/**
 * This implementation of {@link ISerDeser} use Fst library for
 * serializing/deserializing.
 * 
 * @author Thanh Nguyen 
 * @since 0.9.3
 */
public class FstSerDeser implements ISerDeser {
    /**
     * {@inheritDoc}
     */
    @Override
    public byte[] toBytes(Object obj) throws SerializationException {
        return toBytes(obj, null);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public byte[] toBytes(Object obj, ClassLoader classLoader) throws SerializationException {
        return SerializationUtils.toByteArrayFst(obj, classLoader);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public  T fromBytes(byte[] data, Class clazz) throws DeserializationException {
        return fromBytes(data, clazz, null);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public  T fromBytes(byte[] data, Class clazz, ClassLoader classLoader)
            throws DeserializationException {
        return SerializationUtils.fromByteArrayFst(data, clazz, classLoader);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy