use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class CommandOperationHelper method executeWrappedCommandProtocolAsync.
static <T> void executeWrappedCommandProtocolAsync(final AsyncWriteBinding binding, final String database, final BsonDocument command, final AsyncConnection connection, final CommandTransformer<BsonDocument, T> transformer, final SingleResultCallback<T> callback) {
notNull("binding", binding);
executeWrappedCommandProtocolAsync(database, command, new BsonDocumentCodec(), connection, primary(), transformer, callback);
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class CommandResultCodecProvider method addCodecs.
private void addCodecs() {
addCodec(new BsonNullCodec());
addCodec(new BsonBinaryCodec());
addCodec(new BsonBooleanCodec());
addCodec(new BsonDateTimeCodec());
addCodec(new BsonDBPointerCodec());
addCodec(new BsonDoubleCodec());
addCodec(new BsonInt32Codec());
addCodec(new BsonInt64Codec());
addCodec(new BsonDecimal128Codec());
addCodec(new BsonMinKeyCodec());
addCodec(new BsonMaxKeyCodec());
addCodec(new BsonJavaScriptCodec());
addCodec(new BsonObjectIdCodec());
addCodec(new BsonRegularExpressionCodec());
addCodec(new BsonStringCodec());
addCodec(new BsonSymbolCodec());
addCodec(new BsonTimestampCodec());
addCodec(new BsonUndefinedCodec());
addCodec(new BsonJavaScriptWithScopeCodec(new BsonDocumentCodec()));
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class BsonDocumentTest method toJsonShouldRespectDefaultJsonWriterSettings.
@Test
public void toJsonShouldRespectDefaultJsonWriterSettings() {
StringWriter writer = new StringWriter();
new BsonDocumentCodec().encode(new JsonWriter(writer), document, EncoderContext.builder().build());
assertEquals(writer.toString(), document.toJson());
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class BsonHelper method toBson.
public static ByteBuffer toBson(final BsonDocument document) {
BasicOutputBuffer bsonOutput = new BasicOutputBuffer();
new BsonDocumentCodec().encode(new BsonBinaryWriter(bsonOutput), document, EncoderContext.builder().build());
return ByteBuffer.wrap(bsonOutput.toByteArray());
}
use of org.bson.codecs.BsonDocumentCodec in project mongo-java-driver by mongodb.
the class GenericBsonDecimal128Test method encodeToHex.
private String encodeToHex(final BsonDocument decodedDocument) {
BasicOutputBuffer outputBuffer = new BasicOutputBuffer();
new BsonDocumentCodec().encode(new BsonBinaryWriter(outputBuffer), decodedDocument, EncoderContext.builder().build());
return DatatypeConverter.printHexBinary(outputBuffer.toByteArray());
}
Aggregations