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

de.tsl2.nano.replication.serializer.SerializeJAXB Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show newest version
package de.tsl2.nano.replication.serializer;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import javax.xml.bind.JAXB;


public class SerializeJAXB implements Serializer {
    public static final String KEY = "JAXB";
    @Override
    public String getKey() {
        return KEY;
    }
    @Override
    public String getExtension() {
        return "jaxb.xml";
    }
    @Override
    public ByteArrayOutputStream serialize(Object obj) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        JAXB.marshal(obj, out);
        return out;
    }
    @Override
    public  T deserialize(InputStream stream, Class type) {
        return JAXB.unmarshal(stream, type);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy