Java 类org.bson.io.BsonOutput 实例源码

项目:bson-codecs-jsr310    文件:CodecsTests.java   
private <T> void encodeValue(BsonOutput output, Codec<T> codec, T value) {
    try (BsonBinaryWriter writer = new BsonBinaryWriter(output)) {

        writer.writeStartDocument();
        writer.writeName("value");

        codec.encode(writer, value, EncoderContext.builder().build());

        writer.writeEndDocument();
        writer.close();
    }
}
项目:BsonMapper    文件:DefaultBsonMapper.java   
@Override
public BsonOutput writeToBsonOutput(Object object) {
    if (object == null) {
        return null;
    }
    BsonOutput bsonOutput = new BasicOutputBuffer();
    BsonWriter bsonBinaryWriter = new BsonBinaryWriter(new BsonWriterSettings(bsonMapperConfig.getMaxMapperLayerNum()),
            new BsonBinaryWriterSettings(bsonMapperConfig.getMaxDocumentSizeForBsonWriter()), bsonOutput);
    BsonValueConverterRepertory.getBsonDocumentConverter().encode(bsonBinaryWriter, object);
    return bsonOutput;
}
项目:BsonMapper    文件:BsonMapper.java   
BsonOutput writeToBsonOutput(Object object);