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

org.ssf4j.jackson.JacksonSerializer Maven / Gradle / Ivy

There is a newer version: 0.4
Show newest version
package org.ssf4j.jackson;

import java.io.IOException;
import java.io.OutputStream;

import org.ssf4j.Serializer;

import com.fasterxml.jackson.databind.ObjectMapper;

public class JacksonSerializer implements Serializer {

	protected OutputStream out;
	protected ObjectMapper mapper;
	
	public JacksonSerializer(OutputStream out, ObjectMapper mapper) throws IOException {
		this.out = out;
		this.mapper = mapper != null ? mapper : new ObjectMapper();
	}
	
	@Override
	public void flush() throws IOException {
		out.flush();
	}

	@Override
	public void close() throws IOException {
		flush();
		out.close();
	}

	@Override
	public void write(T object) throws IOException {
		mapper.writeValue(out, object);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy