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

com.fasterxml.clustermate.service.msg.StreamingEntityImpl Maven / Gradle / Ivy

There is a newer version: 0.10.5
Show newest version
package com.fasterxml.clustermate.service.msg;

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

import com.fasterxml.jackson.databind.ObjectWriter;

public class StreamingEntityImpl
    implements StreamingResponseContent
{
    protected final ObjectWriter _objectWriter;
    protected final Object _entity;

    public StreamingEntityImpl(ObjectWriter objectWriter, Object e)
    {
        _objectWriter = objectWriter;
        _entity = e;
    }

    /**
     * Generally we do not know it: could do buffering if we really
     * cared to check it for smallish responses.
     */
    @Override
    public long getLength() {
        return -1L;
    }

    @Override
    public void writeContent(OutputStream out) throws IOException
    {
        _objectWriter.writeValue(out, _entity);
    }

    @Override
    public boolean hasFile() { return false; }

    @Override
    public boolean inline() { return true; }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy