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

nl.renarj.jasdb.rest.serializers.json.JsonRestResponseHandler Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package nl.renarj.jasdb.rest.serializers.json;

import nl.renarj.jasdb.rest.exceptions.RestException;
import nl.renarj.jasdb.rest.model.RestEntity;
import nl.renarj.jasdb.rest.serializers.RestResponseHandler;

import java.io.InputStream;
import java.io.OutputStream;

public class JsonRestResponseHandler implements RestResponseHandler {
	@Override
	public  T deserialize(Class dataType, InputStream inputStream) throws RestException {
        return JsonRestHandlerFactory.getRestResponseHandler(dataType).deserialize(dataType, inputStream);
	}

    @Override
    public  T deserialize(Class dataType, String data) throws RestException {
        return JsonRestHandlerFactory.getRestResponseHandler(dataType).deserialize(dataType, data);
    }

	@Override
	public void serialize(RestEntity data, OutputStream outputStream) throws RestException {
        JsonRestHandlerFactory.getRestResponseHandler(data.getClass()).serialize(data, outputStream);
	}

	@Override
	public String getMediaType() {
		return "application/json;charset=utf-8";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy