本文整理汇总了Java中org.bson.BsonBinaryReader类的典型用法代码示例。如果您正苦于以下问题:Java BsonBinaryReader类的具体用法?Java BsonBinaryReader怎么用?Java BsonBinaryReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BsonBinaryReader类属于org.bson包,在下文中一共展示了BsonBinaryReader类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: writeReadCompare
import org.bson.BsonBinaryReader; //导入依赖的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: decodeValue
import org.bson.BsonBinaryReader; //导入依赖的package包/类
private <T> T decodeValue(ByteBuffer byteBuffer, Codec<T> codec) {
try (BsonBinaryReader reader = new BsonBinaryReader(byteBuffer)) {
reader.readStartDocument();
String name = reader.readName();
assertEquals("value", name);
return codec.decode(reader, DecoderContext.builder().build());
}
}
开发者ID:cbartosiak,项目名称:bson-codecs-jsr310,代码行数:12,代码来源:CodecsTests.java
示例3: readFrom
import org.bson.BsonBinaryReader; //导入依赖的package包/类
@Override
public <T> T readFrom(ByteBuffer byteBuffer, Class<T> targetClazz) {
if (byteBuffer == null) {
return null;
}
checkNotNull(targetClazz, NOT_NULL_MSG);
checkIsSupportClazz(targetClazz, NOT_SUPPORT_CLAZZ_MSG + targetClazz.getName());
BsonBinaryReader bsonBinaryReader = new BsonBinaryReader(byteBuffer);
return BsonValueConverterRepertory.getBsonDocumentConverter().decode(bsonBinaryReader, targetClazz, bsonMapperConfig);
}
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:11,代码来源:DefaultBsonMapper.java
示例4: testByteIOEncode
import org.bson.BsonBinaryReader; //导入依赖的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: prepareReader
import org.bson.BsonBinaryReader; //导入依赖的package包/类
private void prepareReader() {
writer.writeEndDocument();
reader = new BsonBinaryReader(new ByteBufferBsonInput(buffer.getByteBuffers().get(0)));
reader.readStartDocument();
reader.readName();
}
开发者ID:egopulse,项目名称:java-code-gen,代码行数:7,代码来源:TestCodecs.java
示例6: byteArrayToMongoDocument
import org.bson.BsonBinaryReader; //导入依赖的package包/类
public static Document byteArrayToMongoDocument(byte[] byteArray) {
BsonBinaryReader bsonReader = new BsonBinaryReader(ByteBuffer.wrap(byteArray));
return new DocumentCodec().decode(bsonReader, DecoderContext.builder().build());
}
开发者ID:lumongo,项目名称:lumongo,代码行数:5,代码来源:LumongoUtil.java
示例7: asBsonReader
import org.bson.BsonBinaryReader; //导入依赖的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
示例8: asGsonReader
import org.bson.BsonBinaryReader; //导入依赖的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
示例9: decodeMongoTest
import org.bson.BsonBinaryReader; //导入依赖的package包/类
@Benchmark
public Object decodeMongoTest() throws Exception {
BsonBinaryReader reader = new BsonBinaryReader(ByteBuffer.wrap(encoded));
return new BsonDocumentCodec().decode(reader, DecoderContext.builder().build());
}
开发者ID:bckfnn,项目名称:vertx-native-mongo,代码行数:6,代码来源:EncoderPerfTest.java
注:本文中的org.bson.BsonBinaryReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论