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

io.avaje.json.stream.JsonOutput Maven / Gradle / Ivy

There is a newer version: 3.0-RC2
Show newest version
package io.avaje.json.stream;

import io.helidon.webserver.http.ServerResponse;

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

/**
 * Output that can be aware of server content chunking.
 * 

* Typically, for HTTP servers that can send output using fixed length or chunked. */ public interface JsonOutput extends Closeable { /** * Create as a simple wrapper for OutputStream. */ static JsonOutput of(OutputStream outputStream) { return new DJsonOutput(outputStream); } /** * Create for Nima ServerResponse. */ static JsonOutput of(ServerResponse nimaServerResponse) { return new NimaJsonOutput(nimaServerResponse); } /** * Write the content to the underlying output stream. */ void write(byte[] content, int offset, int length) throws IOException; /** * Write the last content to the underlying output stream. *

* Given that this is known to be the last content written an implementation can make * use of this to optimise for sending as fixed length content. */ default void writeLast(byte[] content, int offset, int length) throws IOException { write(content, offset, length); } /** * Flush the underlying OutputStream. */ void flush() throws IOException; /** * Return the underlying OutputStream. *

* This is used for Jsonb adapters (Jackson) that can't support writeLast() semantics. */ OutputStream unwrapOutputStream(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy