public abstract class OutputBuffer extends OutputStream
BsonOutput
.Constructor and Description |
---|
OutputBuffer() |
Modifier and Type | Method and Description |
---|---|
String |
asString()
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
String |
asString(String encoding)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
void |
backpatchSize(int size)
Backpatches the size of a document or string by writing the size into the four bytes starting at getPosition() -
size.
|
protected void |
backpatchSize(int size,
int additionalOffset)
Backpatches the size of a document or string by writing the size into the four bytes starting at
getPosition() - size -
additionalOffset . |
abstract int |
getPosition()
Gets the current position in the stream.
|
String |
hex()
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
String |
md5()
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
abstract int |
pipe(OutputStream out)
Pipe the contents of this output buffer into the given output stream
|
abstract void |
seekEnd()
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
abstract void |
seekStart()
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
abstract void |
setPosition(int position)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
abstract int |
size()
Gets the output size in bytes.
|
byte[] |
toByteArray()
Gets a copy of the buffered bytes.
|
String |
toString() |
void |
truncateToPosition(int newPosition)
Truncates the buffer to the given new position, which must be greater than or equal to zero and less than or equal to the current
size of this buffer.
|
abstract void |
write(byte[] b) |
abstract void |
write(byte[] b,
int off,
int len) |
abstract void |
write(int b) |
int |
writeCString(String str)
Writes C string (null-terminated string) to underlying buffer.
|
void |
writeDouble(double x)
Writes a BSON double to the stream.
|
void |
writeInt(int x)
Writes the given integer value to the buffer.
|
void |
writeInt(int pos,
int x)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
void |
writeIntBE(int x)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
void |
writeLong(long x)
Writes the given long value to the buffer.
|
void |
writeString(String str)
Writes a BSON String to the stream.
|
close, flush
public abstract void write(byte[] b)
write
in class OutputStream
public abstract void write(byte[] b, int off, int len)
write
in class OutputStream
public abstract void write(int b)
write
in class OutputStream
public abstract int getPosition()
@Deprecated public abstract void setPosition(int position)
position
- the position to set@Deprecated public abstract void seekEnd()
@Deprecated public abstract void seekStart()
public abstract int size()
public abstract int pipe(OutputStream out) throws IOException
out
- the stream to pipe toIOException
- if the stream throws an exceptionpublic byte[] toByteArray()
pipe(java.io.OutputStream)
@Deprecated public String asString()
@Deprecated public String asString(String encoding) throws UnsupportedEncodingException
UnsupportedEncodingException
@Deprecated public String hex()
@Deprecated public String md5()
public void writeInt(int x)
x
- the value to write@Deprecated public void writeIntBE(int x)
@Deprecated public void writeInt(int pos, int x)
public void writeLong(long x)
x
- the value to writepublic void writeDouble(double x)
x
- the valuepublic void writeString(String str)
str
- the valuepublic int writeCString(String str)
str
- the stringpublic void backpatchSize(int size)
size
- the size of the document/stringprotected void backpatchSize(int size, int additionalOffset)
getPosition() - size -
additionalOffset
.size
- the size of the document/stringadditionalOffset
- the offset from the current position to write the sizepublic void truncateToPosition(int newPosition)
newPosition
- the position to truncate this buffer to