Package org.bson
Class BasicBSONEncoder
- java.lang.Object
-
- org.bson.BasicBSONEncoder
-
- All Implemented Interfaces:
BSONEncoder
- Direct Known Subclasses:
DefaultDBEncoder
public class BasicBSONEncoder extends java.lang.Object implements BSONEncoder
This is meant to be pooled or cached. There is some per instance memory for string conversion, etc...
-
-
Constructor Summary
Constructors Constructor Description BasicBSONEncoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
done()
Free the resources.byte[]
encode(BSONObject document)
Encode a document into byte array.int
putObject(BSONObject document)
Encodes aBSONObject
.void
set(OutputBuffer buffer)
Sets the buffer to wrich the result of encoding will be written.
-
-
-
Method Detail
-
encode
public byte[] encode(BSONObject document)
Description copied from interface:BSONEncoder
Encode a document into byte array. This is a shortcut method which creates a newOutputBuffer
, invokes the other 3 methods in a corresponding sequence: and returns the contents of theOutputBuffer
.- Specified by:
encode
in interfaceBSONEncoder
- Parameters:
document
- the document to be encoded- Returns:
- a byte sequence
-
done
public void done()
Description copied from interface:BSONEncoder
Free the resources.- Specified by:
done
in interfaceBSONEncoder
-
set
public void set(OutputBuffer buffer)
Description copied from interface:BSONEncoder
Sets the buffer to wrich the result of encoding will be written.- Specified by:
set
in interfaceBSONEncoder
- Parameters:
buffer
- the buffer to be used to write a byte sequences to
-
putObject
public int putObject(BSONObject document)
Encodes aBSONObject
. This is for the higher level api calls.- Specified by:
putObject
in interfaceBSONEncoder
- Parameters:
document
- the document to encode- Returns:
- the number of characters in the encoding
-
-