Package org.bson
Class BsonBinaryWriter
- java.lang.Object
-
- org.bson.AbstractBsonWriter
-
- org.bson.BsonBinaryWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,BsonWriter
public class BsonBinaryWriter extends AbstractBsonWriter
A BsonWriter implementation that writes to a binary stream of data. This is the most commonly used implementation.- Since:
- 3.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.bson.AbstractBsonWriter
AbstractBsonWriter.State
-
-
Constructor Summary
Constructors Constructor Description BsonBinaryWriter(BsonWriterSettings settings, BsonBinaryWriterSettings binaryWriterSettings, BsonOutput bsonOutput)
Construct an instance.BsonBinaryWriter(BsonWriterSettings settings, BsonBinaryWriterSettings binaryWriterSettings, BsonOutput bsonOutput, FieldNameValidator validator)
Construct an instance.BsonBinaryWriter(BsonOutput bsonOutput)
Construct an instance.BsonBinaryWriter(BsonOutput bsonOutput, FieldNameValidator validator)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
doWriteBoolean(boolean value)
void
doWriteNull()
void
doWriteObjectId(ObjectId value)
void
doWriteRegularExpression(BsonRegularExpression value)
void
doWriteString(java.lang.String value)
void
doWriteSymbol(java.lang.String value)
void
doWriteTimestamp(BsonTimestamp value)
void
doWriteUndefined()
void
flush()
Flushes any pending data to the output destination.BsonBinaryWriterSettings
getBinaryWriterSettings()
BsonOutput
getBsonOutput()
Gets the BSON output backing this instance.void
mark()
Create a snapshot of this writer's context at a point in time.void
pipe(BsonReader reader)
Reads a single document from a BsonReader and writes it to this.void
pipe(BsonReader reader, java.util.List<BsonElement> extraElements)
Reads a single document from the given BsonReader and writes it to this, appending the given extra elements to the document.void
popMaxDocumentSize()
Reset the maximum document size to its previous value.void
pushMaxDocumentSize(int maxDocumentSize)
Sets a maximum size for documents from this point.void
reset()
Resets this writer to the lastmark()
saved.-
Methods inherited from class org.bson.AbstractBsonWriter
writeBinaryData, writeBinaryData, writeBoolean, writeBoolean, writeDateTime, writeDateTime, writeDBPointer, writeDBPointer, writeDecimal128, writeDecimal128, writeDouble, writeDouble, writeEndArray, writeEndDocument, writeInt32, writeInt32, writeInt64, writeInt64, writeJavaScript, writeJavaScript, writeJavaScriptWithScope, writeJavaScriptWithScope, writeMaxKey, writeMaxKey, writeMinKey, writeMinKey, writeName, writeNull, writeNull, writeObjectId, writeObjectId, writeRegularExpression, writeRegularExpression, writeStartArray, writeStartArray, writeStartDocument, writeStartDocument, writeString, writeString, writeSymbol, writeSymbol, writeTimestamp, writeTimestamp, writeUndefined, writeUndefined
-
-
-
-
Constructor Detail
-
BsonBinaryWriter
public BsonBinaryWriter(BsonOutput bsonOutput, FieldNameValidator validator)
Construct an instance.- Parameters:
bsonOutput
- the output to write tovalidator
- the field name validator to apply
-
BsonBinaryWriter
public BsonBinaryWriter(BsonOutput bsonOutput)
Construct an instance.- Parameters:
bsonOutput
- the output to write to
-
BsonBinaryWriter
public BsonBinaryWriter(BsonWriterSettings settings, BsonBinaryWriterSettings binaryWriterSettings, BsonOutput bsonOutput)
Construct an instance.- Parameters:
settings
- the generic BsonWriter settingsbinaryWriterSettings
- the settings specific to a BsonBinaryWriterbsonOutput
- the output to write to
-
BsonBinaryWriter
public BsonBinaryWriter(BsonWriterSettings settings, BsonBinaryWriterSettings binaryWriterSettings, BsonOutput bsonOutput, FieldNameValidator validator)
Construct an instance.- Parameters:
settings
- the generic BsonWriter settingsbinaryWriterSettings
- the settings specific to a BsonBinaryWriterbsonOutput
- the output to write tovalidator
- the field name validator to apply
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classAbstractBsonWriter
-
getBsonOutput
public BsonOutput getBsonOutput()
Gets the BSON output backing this instance.- Returns:
- the BSON output
-
getBinaryWriterSettings
public BsonBinaryWriterSettings getBinaryWriterSettings()
- Returns:
- the BsonBinaryWriterSettings
- Since:
- 3.6
-
flush
public void flush()
Description copied from interface:BsonWriter
Flushes any pending data to the output destination.
-
doWriteBoolean
public void doWriteBoolean(boolean value)
-
doWriteNull
public void doWriteNull()
-
doWriteObjectId
public void doWriteObjectId(ObjectId value)
-
doWriteRegularExpression
public void doWriteRegularExpression(BsonRegularExpression value)
-
doWriteString
public void doWriteString(java.lang.String value)
-
doWriteSymbol
public void doWriteSymbol(java.lang.String value)
-
doWriteTimestamp
public void doWriteTimestamp(BsonTimestamp value)
-
doWriteUndefined
public void doWriteUndefined()
-
pipe
public void pipe(BsonReader reader)
Description copied from interface:BsonWriter
Reads a single document from a BsonReader and writes it to this.- Specified by:
pipe
in interfaceBsonWriter
- Overrides:
pipe
in classAbstractBsonWriter
- Parameters:
reader
- The source.
-
pipe
public void pipe(BsonReader reader, java.util.List<BsonElement> extraElements)
Description copied from class:AbstractBsonWriter
Reads a single document from the given BsonReader and writes it to this, appending the given extra elements to the document.- Overrides:
pipe
in classAbstractBsonWriter
- Parameters:
reader
- the source of the documentextraElements
- the extra elements to append to the document
-
pushMaxDocumentSize
public void pushMaxDocumentSize(int maxDocumentSize)
Sets a maximum size for documents from this point.- Parameters:
maxDocumentSize
- the maximum document size.
-
popMaxDocumentSize
public void popMaxDocumentSize()
Reset the maximum document size to its previous value.
-
mark
public void mark()
Create a snapshot of this writer's context at a point in time.
-
-