Package org.bson
Interface BsonWriter
- 
- All Known Implementing Classes:
- AbstractBsonWriter,- BsonBinaryWriter,- BsonDocumentWriter,- JsonWriter
 
 public interface BsonWriterAn interface for writing a logical BSON document using a push-oriented API.- Since:
- 3.0
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidflush()Flushes any pending data to the output destination.voidpipe(BsonReader reader)Reads a single document from a BsonReader and writes it to this.voidwriteBinaryData(String name, BsonBinary binary)Writes a BSON Binary data element to the writer.voidwriteBinaryData(BsonBinary binary)Writes a BSON Binary data element to the writer.voidwriteBoolean(boolean value)Writes a BSON Boolean to the writer.voidwriteBoolean(String name, boolean value)Writes a BSON Boolean element to the writer.voidwriteDateTime(long value)Writes a BSON DateTime to the writer.voidwriteDateTime(String name, long value)Writes a BSON DateTime element to the writer.voidwriteDBPointer(String name, BsonDbPointer value)Writes a BSON DBPointer element to the writer.voidwriteDBPointer(BsonDbPointer value)Writes a BSON DBPointer to the writer.voidwriteDecimal128(String name, Decimal128 value)Writes a BSON Decimal128 element to the writer.voidwriteDecimal128(Decimal128 value)Writes a BSON Decimal128 to the writer.voidwriteDouble(double value)Writes a BSON Double to the writer.voidwriteDouble(String name, double value)Writes a BSON Double element to the writer.voidwriteEndArray()Writes the end of a BSON array to the writer.voidwriteEndDocument()Writes the end of a BSON document to the writer.voidwriteInt32(int value)Writes a BSON Int32 to the writer.voidwriteInt32(String name, int value)Writes a BSON Int32 element to the writer.voidwriteInt64(long value)Writes a BSON Int64 to the writer.voidwriteInt64(String name, long value)Writes a BSON Int64 element to the writer.voidwriteJavaScript(String code)Writes a BSON JavaScript to the writer.voidwriteJavaScript(String name, String code)Writes a BSON JavaScript element to the writer.voidwriteJavaScriptWithScope(String code)Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).voidwriteJavaScriptWithScope(String name, String code)Writes a BSON JavaScript element to the writer (call WriteStartDocument to start writing the scope).voidwriteMaxKey()Writes a BSON MaxKey to the writer.voidwriteMaxKey(String name)Writes a BSON MaxKey element to the writer.voidwriteMinKey()Writes a BSON MinKey to the writer.voidwriteMinKey(String name)Writes a BSON MinKey element to the writer.voidwriteName(String name)Writes the name of an element to the writer.voidwriteNull()Writes a BSON null to the writer.voidwriteNull(String name)Writes a BSON null element to the writer.voidwriteObjectId(String name, ObjectId objectId)Writes a BSON ObjectId element to the writer.voidwriteObjectId(ObjectId objectId)Writes a BSON ObjectId to the writer.voidwriteRegularExpression(String name, BsonRegularExpression regularExpression)Writes a BSON regular expression element to the writer.voidwriteRegularExpression(BsonRegularExpression regularExpression)Writes a BSON regular expression to the writer.voidwriteStartArray()Writes the start of a BSON array to the writer.voidwriteStartArray(String name)Writes the start of a BSON array element to the writer.voidwriteStartDocument()Writes the start of a BSON document to the writer.voidwriteStartDocument(String name)Writes the start of a BSON document element to the writer.voidwriteString(String value)Writes a BSON String to the writer.voidwriteString(String name, String value)Writes a BSON String element to the writer.voidwriteSymbol(String value)Writes a BSON Symbol to the writer.voidwriteSymbol(String name, String value)Writes a BSON Symbol element to the writer.voidwriteTimestamp(String name, BsonTimestamp value)Writes a BSON Timestamp element to the writer.voidwriteTimestamp(BsonTimestamp value)Writes a BSON Timestamp to the writer.voidwriteUndefined()Writes a BSON undefined to the writer.voidwriteUndefined(String name)Writes a BSON undefined element to the writer.
 
- 
- 
- 
Method Detail- 
flushvoid flush() Flushes any pending data to the output destination.
 - 
writeBinaryDatavoid writeBinaryData(BsonBinary binary) Writes a BSON Binary data element to the writer.- Parameters:
- binary- The Binary data.
 
 - 
writeBinaryDatavoid writeBinaryData(String name, BsonBinary binary) Writes a BSON Binary data element to the writer.- Parameters:
- name- The name of the element.
- binary- The Binary data value.
 
 - 
writeBooleanvoid writeBoolean(boolean value) Writes a BSON Boolean to the writer.- Parameters:
- value- The Boolean value.
 
 - 
writeBooleanvoid writeBoolean(String name, boolean value) Writes a BSON Boolean element to the writer.- Parameters:
- name- The name of the element.
- value- The Boolean value.
 
 - 
writeDateTimevoid writeDateTime(long value) Writes a BSON DateTime to the writer.- Parameters:
- value- The number of milliseconds since the Unix epoch.
 
 - 
writeDateTimevoid writeDateTime(String name, long value) Writes a BSON DateTime element to the writer.- Parameters:
- name- The name of the element.
- value- The number of milliseconds since the Unix epoch.
 
 - 
writeDBPointervoid writeDBPointer(BsonDbPointer value) Writes a BSON DBPointer to the writer.- Parameters:
- value- The DBPointer to write
 
 - 
writeDBPointervoid writeDBPointer(String name, BsonDbPointer value) Writes a BSON DBPointer element to the writer.- Parameters:
- name- The name of the element.
- value- The DBPointer to write
 
 - 
writeDoublevoid writeDouble(double value) Writes a BSON Double to the writer.- Parameters:
- value- The Double value.
 
 - 
writeDoublevoid writeDouble(String name, double value) Writes a BSON Double element to the writer.- Parameters:
- name- The name of the element.
- value- The Double value.
 
 - 
writeEndArrayvoid writeEndArray() Writes the end of a BSON array to the writer.
 - 
writeEndDocumentvoid writeEndDocument() Writes the end of a BSON document to the writer.
 - 
writeInt32void writeInt32(int value) Writes a BSON Int32 to the writer.- Parameters:
- value- The Int32 value.
 
 - 
writeInt32void writeInt32(String name, int value) Writes a BSON Int32 element to the writer.- Parameters:
- name- The name of the element.
- value- The Int32 value.
 
 - 
writeInt64void writeInt64(long value) Writes a BSON Int64 to the writer.- Parameters:
- value- The Int64 value.
 
 - 
writeInt64void writeInt64(String name, long value) Writes a BSON Int64 element to the writer.- Parameters:
- name- The name of the element.
- value- The Int64 value.
 
 - 
writeDecimal128void writeDecimal128(Decimal128 value) Writes a BSON Decimal128 to the writer.- Parameters:
- value- The Decimal128 value.
- Since:
- 3.4
 
 - 
writeDecimal128void writeDecimal128(String name, Decimal128 value) Writes a BSON Decimal128 element to the writer.- Parameters:
- name- The name of the element.
- value- The Decimal128 value.
- Since:
- 3.4
 
 - 
writeJavaScriptvoid writeJavaScript(String code) Writes a BSON JavaScript to the writer.- Parameters:
- code- The JavaScript code.
 
 - 
writeJavaScriptvoid writeJavaScript(String name, String code) Writes a BSON JavaScript element to the writer.- Parameters:
- name- The name of the element.
- code- The JavaScript code.
 
 - 
writeJavaScriptWithScopevoid writeJavaScriptWithScope(String code) Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).- Parameters:
- code- The JavaScript code.
 
 - 
writeJavaScriptWithScopevoid writeJavaScriptWithScope(String name, String code) Writes a BSON JavaScript element to the writer (call WriteStartDocument to start writing the scope).- Parameters:
- name- The name of the element.
- code- The JavaScript code.
 
 - 
writeMaxKeyvoid writeMaxKey() Writes a BSON MaxKey to the writer.
 - 
writeMaxKeyvoid writeMaxKey(String name) Writes a BSON MaxKey element to the writer.- Parameters:
- name- The name of the element.
 
 - 
writeMinKeyvoid writeMinKey() Writes a BSON MinKey to the writer.
 - 
writeMinKeyvoid writeMinKey(String name) Writes a BSON MinKey element to the writer.- Parameters:
- name- The name of the element.
 
 - 
writeNamevoid writeName(String name) Writes the name of an element to the writer.- Parameters:
- name- The name of the element.
 
 - 
writeNullvoid writeNull() Writes a BSON null to the writer.
 - 
writeNullvoid writeNull(String name) Writes a BSON null element to the writer.- Parameters:
- name- The name of the element.
 
 - 
writeObjectIdvoid writeObjectId(ObjectId objectId) Writes a BSON ObjectId to the writer.- Parameters:
- objectId- The ObjectId value.
 
 - 
writeObjectIdvoid writeObjectId(String name, ObjectId objectId) Writes a BSON ObjectId element to the writer.- Parameters:
- name- The name of the element.
- objectId- The ObjectId value.
 
 - 
writeRegularExpressionvoid writeRegularExpression(BsonRegularExpression regularExpression) Writes a BSON regular expression to the writer.- Parameters:
- regularExpression- the regular expression to write.
 
 - 
writeRegularExpressionvoid writeRegularExpression(String name, BsonRegularExpression regularExpression) Writes a BSON regular expression element to the writer.- Parameters:
- name- The name of the element.
- regularExpression- The RegularExpression value.
 
 - 
writeStartArrayvoid writeStartArray() Writes the start of a BSON array to the writer.- Throws:
- BsonSerializationException- if maximum serialization depth exceeded.
 
 - 
writeStartArrayvoid writeStartArray(String name) Writes the start of a BSON array element to the writer.- Parameters:
- name- The name of the element.
 
 - 
writeStartDocumentvoid writeStartDocument() Writes the start of a BSON document to the writer.- Throws:
- BsonSerializationException- if maximum serialization depth exceeded.
 
 - 
writeStartDocumentvoid writeStartDocument(String name) Writes the start of a BSON document element to the writer.- Parameters:
- name- The name of the element.
 
 - 
writeStringvoid writeString(String value) Writes a BSON String to the writer.- Parameters:
- value- The String value.
 
 - 
writeStringvoid writeString(String name, String value) Writes a BSON String element to the writer.- Parameters:
- name- The name of the element.
- value- The String value.
 
 - 
writeSymbolvoid writeSymbol(String value) Writes a BSON Symbol to the writer.- Parameters:
- value- The symbol.
 
 - 
writeSymbolvoid writeSymbol(String name, String value) Writes a BSON Symbol element to the writer.- Parameters:
- name- The name of the element.
- value- The symbol.
 
 - 
writeTimestampvoid writeTimestamp(BsonTimestamp value) Writes a BSON Timestamp to the writer.- Parameters:
- value- The combined timestamp/increment value.
 
 - 
writeTimestampvoid writeTimestamp(String name, BsonTimestamp value) Writes a BSON Timestamp element to the writer.- Parameters:
- name- The name of the element.
- value- The combined timestamp/increment value.
 
 - 
writeUndefinedvoid writeUndefined() Writes a BSON undefined to the writer.
 - 
writeUndefinedvoid writeUndefined(String name) Writes a BSON undefined element to the writer.- Parameters:
- name- The name of the element.
 
 - 
pipevoid pipe(BsonReader reader) Reads a single document from a BsonReader and writes it to this.- Parameters:
- reader- The source.
 
 
- 
 
-