public interface MessageBufferOutput
extends java.io.Closeable, java.io.Flushable
| Modifier and Type | Method and Description |
|---|---|
void |
add(byte[] buffer,
int offset,
int length)
Writes an external payload data.
|
MessageBuffer |
next(int minimumSize)
Allocates the next buffer to write.
|
void |
write(byte[] buffer,
int offset,
int length)
Writes an external payload data.
|
void |
writeBuffer(int length)
Writes the previously allocated buffer.
|
MessageBuffer next(int minimumSize) throws java.io.IOException
This method should return a MessageBuffer instance that has specified size of capacity at least.
When this method is called twice, the previously returned buffer is no longer used. This method may be called
twice without call of writeBuffer(int) in between. In this case, the buffer should be
discarded without flushing it to the output.
minimumSize - the mimium required buffer size to allocatejava.io.IOExceptionvoid writeBuffer(int length)
throws java.io.IOException
This method should write the buffer previously returned from next(int) method until specified number of
bytes. Once the buffer is written, the buffer is no longer used.
This method is not always called for each next(int) call. In this case, the buffer should be discarded
without flushing it to the output when the next next(int) is called.
length - the number of bytes to writejava.io.IOExceptionvoid write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
buffer - the data to writeoffset - the start offset in the datalength - the number of bytes to writejava.io.IOExceptionvoid add(byte[] buffer,
int offset,
int length)
throws java.io.IOException
Unlike write(byte[], int, int) method, the buffer is given - this MessageBufferOutput implementation
gets ownership of the buffer and may modify contents of the buffer. Contents of this buffer won't be modified
by the caller.
buffer - the data to addoffset - the start offset in the datalength - the number of bytes to addjava.io.IOException