public class OutputStreamBufferOutput extends java.lang.Object implements MessageBufferOutput
OutputStream.| Constructor and Description |
|---|
OutputStreamBufferOutput(java.io.OutputStream out) |
OutputStreamBufferOutput(java.io.OutputStream out,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(byte[] buffer,
int offset,
int length)
Writes an external payload data.
|
void |
close() |
void |
flush() |
MessageBuffer |
next(int minimumSize)
Allocates the next buffer to write.
|
java.io.OutputStream |
reset(java.io.OutputStream out)
Reset Stream.
|
void |
write(byte[] buffer,
int offset,
int length)
Writes an external payload data.
|
void |
writeBuffer(int length)
Writes the previously allocated buffer.
|
public OutputStreamBufferOutput(java.io.OutputStream out)
public OutputStreamBufferOutput(java.io.OutputStream out,
int bufferSize)
public java.io.OutputStream reset(java.io.OutputStream out)
throws java.io.IOException
out - new streamjava.io.IOExceptionpublic MessageBuffer next(int minimumSize) throws java.io.IOException
MessageBufferOutputThis 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 MessageBufferOutput.writeBuffer(int) in between. In this case, the buffer should be
discarded without flushing it to the output.
next in interface MessageBufferOutputminimumSize - the mimium required buffer size to allocatejava.io.IOExceptionpublic void writeBuffer(int length)
throws java.io.IOException
MessageBufferOutput
This method should write the buffer previously returned from MessageBufferOutput.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 MessageBufferOutput.next(int) call. In this case, the buffer should be discarded
without flushing it to the output when the next MessageBufferOutput.next(int) is called.
writeBuffer in interface MessageBufferOutputlength - the number of bytes to writejava.io.IOExceptionpublic void write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
MessageBufferOutputwrite in interface MessageBufferOutputbuffer - the data to writeoffset - the start offset in the datalength - the number of bytes to writejava.io.IOExceptionpublic void add(byte[] buffer,
int offset,
int length)
throws java.io.IOException
MessageBufferOutput
Unlike MessageBufferOutput.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.
add in interface MessageBufferOutputbuffer - the data to addoffset - the start offset in the datalength - the number of bytes to addjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushablejava.io.IOException