public abstract class OutputBuffer extends OutputStream implements BsonOutput
BsonOutput.| Constructor and Description | 
|---|
| OutputBuffer() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close() | 
| abstract 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. | 
| abstract int | pipe(OutputStream out)Pipe the contents of this output buffer into the given output stream | 
| int | size()Gets the output size in bytes. | 
| byte[] | toByteArray()Gets a copy of the buffered bytes. | 
| String | toString() | 
| abstract void | truncateToPosition(int newPosition)Truncates this stream to the new position. | 
| void | write(byte[] b) | 
| void | write(byte[] bytes,
     int offset,
     int length) | 
| void | write(int value) | 
| protected abstract void | write(int position,
     int value)Write the specified byte at the specified position. | 
| void | writeBytes(byte[] bytes)Writes all the bytes in the byte array to the stream. | 
| void | writeCString(String value)Writes a BSON CString to the stream. | 
| void | writeDouble(double x)Writes a BSON double to the stream. | 
| void | writeInt(int value)Writes the given integer value to the buffer. | 
| void | writeInt32(int value)Writes a 32-bit BSON integer to the stream. | 
| void | writeInt32(int position,
          int value)Writes a 32-bit BSON integer to the stream at the given position. | 
| void | writeInt64(long value)Writes a 64-bit BSON integer to the stream. | 
| void | writeLong(long value)Writes the given long value to the buffer. | 
| void | writeObjectId(ObjectId value)Writes a BSON ObjectId to the stream. | 
| void | writeString(String str)Writes a BSON String to the stream. | 
flushclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetPosition, getSize, writeByte, writeBytespublic void write(byte[] b)
write in class OutputStreampublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface BsonOutputclose in class OutputStreampublic void write(byte[] bytes,
                  int offset,
                  int length)
write in class OutputStreampublic void writeBytes(byte[] bytes)
BsonOutputwriteBytes in interface BsonOutputbytes - the non-null byte arraypublic void writeInt32(int value)
BsonOutputwriteInt32 in interface BsonOutputvalue - the valuepublic void writeInt32(int position,
                       int value)
BsonOutputwriteInt32 in interface BsonOutputposition - the position to write the value, which must be greater than or equal to 0 and less than or equal to the current sizevalue - the valuepublic void writeInt64(long value)
BsonOutputwriteInt64 in interface BsonOutputvalue - the valuepublic void writeDouble(double x)
BsonOutputwriteDouble in interface BsonOutputx - the valuepublic void writeString(String str)
BsonOutputwriteString in interface BsonOutputstr - the valuepublic void writeCString(String value)
BsonOutputwriteCString in interface BsonOutputvalue - the valuepublic void writeObjectId(ObjectId value)
BsonOutputwriteObjectId in interface BsonOutputvalue - the valuepublic int size()
public abstract int pipe(OutputStream out) throws IOException
out - the stream to pipe toIOException - if the stream throws an exceptionpublic abstract List<ByteBuf> getByteBuffers()
Note that the byte buffers may be read-only.
public abstract void truncateToPosition(int newPosition)
BsonOutputtruncateToPosition in interface BsonOutputnewPosition - the new position, which must be greater than or equal to 0 and less than the current size.public byte[] toByteArray()
pipe(java.io.OutputStream)public void write(int value)
write in class OutputStreampublic void writeInt(int value)
value - the value to writewriteInt32(int)protected abstract void write(int position,
                              int value)
position - 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 void writeLong(long value)
value - the value to writewriteInt64(long)