• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DocumentCodecProvider类的典型用法和代码示例

java 1次浏览

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

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

示例1: doInitialize

点赞 2

import org.bson.codecs.DocumentCodecProvider; //导入依赖的package包/类
@Override
protected boolean doInitialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
		throws ResourceInitializationException {
	// Work whether it's a list of DB Objects or a single
	if ("{}".equals(fongoData) || "[]".equals(fongoData) || Strings.isNullOrEmpty(fongoData)) {
		return true;
	}

	if (fongoData.trim().startsWith("[")) {
		CodecRegistry codecRegistry = CodecRegistries.fromProviders(Arrays.asList(new ValueCodecProvider(), new BsonValueCodecProvider(), new DocumentCodecProvider()));
		JsonReader reader = new JsonReader(fongoData);
		BsonArrayCodec arrayReader = new BsonArrayCodec(codecRegistry);
		
		BsonArray docArray = arrayReader.decode(reader, DecoderContext.builder().build());
		
		for(BsonValue doc : docArray.getValues()){
			fongo.getDatabase(BALEEN).getCollection(fongoCollection).insertOne(Document.parse(doc.asDocument().toJson()));
		}		
	} else if (fongoData.trim().startsWith("{")) {
		Document data = Document.parse(fongoData);
		fongo.getDatabase(BALEEN).getCollection(fongoCollection).insertOne(data);
	} else {
		getMonitor().error("Unsupported type");
		throw new ResourceInitializationException();
	}

	return true;
}
 

开发者ID:dstl,
项目名称:baleen,
代码行数:29,
代码来源:SharedFongoResource.java

示例2: createCodecRegistry

点赞 2

import org.bson.codecs.DocumentCodecProvider; //导入依赖的package包/类
private static CodecRegistry createCodecRegistry() {
    CodecRegistry common = CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(new ValueCodecProvider(), new DocumentCodecProvider(), new BsonValueCodecProvider()),
            CodecRegistries.fromCodecs(new BlockVector2DCodec(), new BlockVectorCodec(), new DefaultDomainCodec())
    );
    return CodecRegistries.fromRegistries(
            common,
            CodecRegistries.fromCodecs(new ProcessingProtectedRegionCodec(common))
    );
}
 

开发者ID:maxikg,
项目名称:mongowg,
代码行数:11,
代码来源:MongoWGPlugin.java

示例3: prepare

点赞 2

import org.bson.codecs.DocumentCodecProvider; //导入依赖的package包/类
@Before
public void prepare() {
    CodecRegistry codecRegistry = CodecRegistries.fromRegistries(
            CodecRegistries.fromProviders(new ValueCodecProvider(), new DocumentCodecProvider()),
            CodecRegistries.fromCodecs(new BlockVector2DCodec(), new BlockVectorCodec(), new DefaultDomainCodec())
    );
    codec = new ProcessingProtectedRegionCodec(codecRegistry);
}
 

开发者ID:maxikg,
项目名称:mongowg,
代码行数:9,
代码来源:ProcessingProtectedRegionCodecTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)