Package org.bson
Interface BSONEncoder
- All Known Implementing Classes:
- BasicBSONEncoder
public interface BSONEncoder
A BSONEncoder is a class which can be used to turn documents into byte arrays. The BSONEncoder walks down through the
 object graph and writes corresponding byte sequences into underlying OutputBuffer.
This class is a part of legacy API. Please check Encoder for a new one.
- 
Method SummaryModifier and TypeMethodDescriptionvoiddone()Free the resources.byte[]encode(BSONObject document) Encode a document into byte array.intputObject(BSONObject document) Encoder and write a document into underlying buffer.voidset(OutputBuffer buffer) Sets the buffer to wrich the result of encoding will be written.
- 
Method Details- 
encodeEncode 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.- Parameters:
- document- the document to be encoded
- Returns:
- a byte sequence
 
- 
putObjectEncoder and write a document into underlying buffer.- Parameters:
- document- the document to be encoded
- Returns:
- number of bytes written
 
- 
donevoid done()Free the resources.
- 
setSets the buffer to wrich the result of encoding will be written.- Parameters:
- buffer- the buffer to be used to write a byte sequences to
 
 
-