Closeable, Flushable, AutoCloseable, BsonOutputpublic class BasicOutputBuffer extends OutputBuffer
| Constructor | Description |
|---|---|
BasicOutputBuffer() |
Construct an instance with a default initial byte array size.
|
BasicOutputBuffer(int initialSize) |
Construct an instance with the specified initial byte array size.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
List<ByteBuf> |
getByteBuffers() |
Get a list of byte buffers that are prepared to be read from; in other words, whose position is 0 and whose limit is the number of
bytes that should read.
|
byte[] |
getInternalBuffer() |
Gets the internal buffer.
|
int |
getPosition() |
Gets the current position in the stream.
|
int |
getSize() |
Gets the current size of the stream in number of bytes.
|
int |
pipe(OutputStream out) |
Pipe the contents of this output buffer into the given output stream
|
void |
truncateToPosition(int newPosition) |
Truncates this stream to the new position.
|
void |
write(byte[] b) |
|
protected void |
write(int absolutePosition,
int value) |
Write the specified byte at the specified position.
|
void |
writeByte(int value) |
Write a single byte to the stream.
|
void |
writeBytes(byte[] bytes,
int offset,
int length) |
Writes
length bytes from the byte array, starting at offset. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsize, toByteArray, toString, write, write, writeBytes, writeCString, writeDouble, writeInt, writeInt32, writeInt32, writeInt64, writeLong, writeObjectId, writeStringflushpublic BasicOutputBuffer()
public BasicOutputBuffer(int initialSize)
initialSize - the initial size of the byte arraypublic byte[] getInternalBuffer()
public void write(byte[] b)
write in class OutputBufferpublic void writeBytes(byte[] bytes,
int offset,
int length)
BsonOutputlength bytes from the byte array, starting at offset.bytes - the non-null byte arrayoffset - the offset to start writing fromlength - the number of bytes to writepublic void writeByte(int value)
BsonOutputvalue - the valueprotected void write(int absolutePosition,
int value)
OutputBufferwrite in class OutputBufferabsolutePosition - the position, which must be greater than equal to 0 and at least 4 less than the stream sizevalue - the value to write. The 24 high-order bits of the value are ignored.public int getPosition()
BsonOutputpublic int getSize()
BsonOutputpublic int pipe(OutputStream out) throws IOException
OutputBufferpipe in class OutputBufferout - the stream to pipe toIOException - if the stream throws an exceptionpublic void truncateToPosition(int newPosition)
BsonOutputtruncateToPosition in interface BsonOutputtruncateToPosition in class OutputBuffernewPosition - the new position, which must be greater than or equal to 0 and less than the current size.public List<ByteBuf> getByteBuffers()
OutputBufferNote that the byte buffers may be read-only.
getByteBuffers in class OutputBufferpublic void close()
close in interface AutoCloseableclose in interface BsonOutputclose in interface Closeableclose in class OutputBuffer