• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BasicOutputBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.bson.io.BasicOutputBuffer的典型用法代码示例。如果您正苦于以下问题:Java BasicOutputBuffer类的具体用法?Java BasicOutputBuffer怎么用?Java BasicOutputBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BasicOutputBuffer类属于org.bson.io包,在下文中一共展示了BasicOutputBuffer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeReadCompare

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
@SuppressWarnings("resource")
protected <T> void writeReadCompare(T source, Codec<T> codec) {
	BasicOutputBuffer bsonOutput = new BasicOutputBuffer();
	BsonBinaryWriter writer = new BsonBinaryWriter(bsonOutput);
	writer.writeStartDocument();
	writer.writeName("name");
	codec.encode(writer, source, EncoderContext.builder().build());
	writer.writeEndDocument();
	writer.close();

	BsonBinaryReader reader = new BsonBinaryReader(
			ByteBuffer.wrap(bsonOutput.toByteArray()));
	reader.readStartDocument();
	assertThat(reader.readName()).isEqualTo("name");
	T readNow = codec.decode(reader, DecoderContext.builder().build());

	assertThat(readNow).isEqualTo(source);
}
 
开发者ID:ralscha,项目名称:bsoncodec,代码行数:19,代码来源:AbstractTest.java


示例2: testCodec

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
private <T> void testCodec(Codec<T> codec, T value) {
    try (BasicOutputBuffer output = new BasicOutputBuffer()) {

        encodeValue(output, codec, value);

        T decoded = decodeValue(
                wrap(output.toByteArray()),
                codec
        );

        assertEquals(value, decoded);
    }
}
 
开发者ID:cbartosiak,项目名称:bson-codecs-jsr310,代码行数:14,代码来源:CodecsTests.java


示例3: writeToBsonOutput

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
@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;
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:12,代码来源:DefaultBsonMapper.java


示例4: testByteIOEncode

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
@Test
public void testByteIOEncode() throws Exception {
    BasicOutputBuffer bsonOutput = new BasicOutputBuffer();
    BsonWriter bsonWriter = new BsonBinaryWriter(bsonOutput);
    BsonValueConverterRepertory.getBsonDocumentConverter().encode(bsonWriter, getObject());
    BsonReader bsonReader = new BsonBinaryReader(new ByteBufferBsonInput(bsonOutput.getByteBuffers().get(0)));
    BsonTest bsonTest = BsonValueConverterRepertory.getBsonDocumentConverter().decode(bsonReader, BsonTest.class, BsonMapperConfig.DEFALUT);
    System.out.println(bsonTest);
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:10,代码来源:BsonDocumentConverterTest.java


示例5: testWriteToOutput

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
@Test
public void testWriteToOutput() throws Exception {
    BsonTest bsonObject = getBsonObject();
    BasicOutputBuffer bsonOutput = (BasicOutputBuffer) bsonMapper.writeToBsonOutput(bsonObject);
    byte[] internalBuffer = bsonOutput.getInternalBuffer();
    byte[] expectedBytes = getBsonByte();
    Assert.assertArrayEquals("bytes should be equals", expectedBytes, internalBuffer);
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:9,代码来源:BsonMapperTest.java


示例6: encode

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
public byte[] encode( BSONObject o ){
    BasicOutputBuffer buf = new BasicOutputBuffer();
    set( buf );
    putObject( o );
    done();
    return buf.toByteArray();
}
 
开发者ID:visor-vu,项目名称:chariot,代码行数:8,代码来源:BSONEncoder.java


示例7: before

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
@Before
public void before() {
    buffer = new BasicOutputBuffer();
    writer = new BsonBinaryWriter(buffer);
    writer.writeStartDocument();
    writer.writeName("test");
}
 
开发者ID:egopulse,项目名称:java-code-gen,代码行数:8,代码来源:TestCodecs.java


示例8: mongoDocumentToByteArray

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
public static byte[] mongoDocumentToByteArray(Document mongoDocument) {
	BasicOutputBuffer outputBuffer = new BasicOutputBuffer();
	BsonBinaryWriter writer = new BsonBinaryWriter(outputBuffer);
	new DocumentCodec().encode(writer, mongoDocument, EncoderContext.builder().isEncodingCollectibleDocument(true).build());
	return outputBuffer.toByteArray();
}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:7,代码来源:LumongoUtil.java


示例9: asBsonReader

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
static org.bson.BsonReader asBsonReader(JsonObject gson) throws IOException {
  BasicOutputBuffer buffer = new BasicOutputBuffer();
  BsonWriter writer = new BsonWriter(new BsonBinaryWriter(buffer));
  TypeAdapters.JSON_ELEMENT.write(writer, gson);
  return new BsonBinaryReader(ByteBuffer.wrap(buffer.toByteArray()));
}
 
开发者ID:immutables,项目名称:immutables,代码行数:7,代码来源:Jsons.java


示例10: asGsonReader

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
static JsonReader asGsonReader(BsonDocument bson) {
  BasicOutputBuffer output = new BasicOutputBuffer();
  new BsonDocumentCodec().encode(new BsonBinaryWriter(output), bson, EncoderContext.builder().build());
  return new BsonReader(new BsonBinaryReader(ByteBuffer.wrap(output.toByteArray())));
}
 
开发者ID:immutables,项目名称:immutables,代码行数:6,代码来源:Jsons.java


示例11: encodeMongoTest

import org.bson.io.BasicOutputBuffer; //导入依赖的package包/类
@Benchmark
public Object encodeMongoTest() throws Exception {
    BasicOutputBuffer out = new BasicOutputBuffer(512);
    new BsonDocumentCodec().encode(new BsonBinaryWriter(out), doc1, EncoderContext.builder().build());
    return out.getByteBuffers();
}
 
开发者ID:bckfnn,项目名称:vertx-native-mongo,代码行数:7,代码来源:EncoderPerfTest.java



注:本文中的org.bson.io.BasicOutputBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RMContainerState类代码示例发布时间:2022-05-22
下一篇:
Java XMLX509Digest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap