Class ByteArrayInstanceWriter
java.lang.Object
io.helidon.http.media.ByteArrayInstanceWriter
- All Implemented Interfaces:
InstanceWriter
InstanceWriter for bytes already materialized in memory.-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the byte array is always available.If we can determine the number of bytes to be written to the stream, provide the information here.static ByteArrayInstanceWritercreate(byte[] instanceBytes) Create a new instance writer for bytes already materialized in memory.byte[]Get the instance as byte array.voidwrite(OutputStream stream) Write the instance to the output stream.
-
Method Details
-
create
Create a new instance writer for bytes already materialized in memory.- Parameters:
instanceBytes- bytes to write- Returns:
- byte array instance writer
-
contentLength
Description copied from interface:InstanceWriterIf we can determine the number of bytes to be written to the stream, provide the information here. The returned number must be a valid content length (content-length >= 0)- Specified by:
contentLengthin interfaceInstanceWriter- Returns:
- number of bytes or empty if not possible (or too expensive) to find out
-
alwaysInMemory
public boolean alwaysInMemory()Description copied from interface:InstanceWriterWhether the byte array is always available. If trueInstanceWriter.instanceBytes()will ALWAYS be called.- Specified by:
alwaysInMemoryin interfaceInstanceWriter- Returns:
- whether the bytes will always be materialized in memory
-
write
Description copied from interface:InstanceWriterWrite the instance to the output stream. This method is NEVER called ifInstanceWriter.alwaysInMemory()istrue, otherwise this method is ALWAYS called ifInstanceWriter.contentLength()returns empty. This method MAY be called ifInstanceWriter.contentLength()returns a value.- Specified by:
writein interfaceInstanceWriter- Parameters:
stream- to write to
-
instanceBytes
public byte[] instanceBytes()Description copied from interface:InstanceWriterGet the instance as byte array. This method is always called ifInstanceWriter.alwaysInMemory()returnstrue. This method is NEVER called ifInstanceWriter.contentLength()returns empty. This method MAY be called ifInstanceWriter.contentLength()returns a value.- Specified by:
instanceBytesin interfaceInstanceWriter- Returns:
- bytes of the instance
-