当前位置: 首页>>代码示例>>Java>>正文


Java BsonValueCodecProvider类代码示例

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


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

示例1: parse

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
private BsonDocument parse(String where) {
  Bson bson = sqlParser.get(Bson.class, where);

  return bson.toBsonDocument(
      BsonDocument.class,
      CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:8,代码来源:MongoWhereClauseListenerTest.java

示例2: doInitialize

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的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

示例3: createCodecRegistry

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的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

示例4: toBsonDocument

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
private BsonDocument toBsonDocument(Bson bson) {
  return bson.toBsonDocument(
      BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:5,代码来源:SelectClauseParserTest.java

示例5: toBsonDocument

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
private BsonDocument toBsonDocument(Bson bson) {
  return bson.toBsonDocument(
      BsonDocument.class,
      CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:6,代码来源:WhereClauseParserTest.java

示例6: parse

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
private BsonDocument parse(String select) {
  Bson bson = sqlParser.get(Bson.class, select);

  return bson.toBsonDocument(
      BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:7,代码来源:MongoSelectClauseListenerTest.java

示例7: parse

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
private BsonDocument parse(String orderBy) {
  Bson bson = sqlParser.get(Bson.class, orderBy);

  return bson.toBsonDocument(
      BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:7,代码来源:MongoOrderByClauseListenerTest.java

示例8: parseBsonArray

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
private static BsonArray parseBsonArray(final String json) {
    return new BsonArrayCodec(CodecRegistries.fromProviders(new BsonValueCodecProvider())).decode(new JsonReader(json), DecoderContext.builder().build());
}
 
开发者ID:thiaguten,项目名称:json-parse-helper,代码行数:4,代码来源:JsonParseHelper.java

示例9: readBsonValue

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
/**
 * Returns the value of the current reader position.
 *
 * @param reader the read to read the value from
 * @param decoderContext the context
 * @return the non-null value read from the reader
 */
public BsonValue readBsonValue(final BsonReader reader, final DecoderContext decoderContext) {
  final Class<? extends BsonValue> classForBsonType =
      BsonValueCodecProvider.getClassForBsonType(reader.getCurrentBsonType());
  final Codec<? extends BsonValue> codec = this.codecRegistry.get(classForBsonType);
  return codec.decode(reader, decoderContext);
}
 
开发者ID:lambdamatic,项目名称:lambdamatic-project,代码行数:14,代码来源:DocumentDecoder.java

示例10: createCodecRegistry

import org.bson.codecs.BsonValueCodecProvider; //导入依赖的package包/类
/**
 * creates a RootCodecRegistry with our EntityCodecProvider as sole CodecProvider
 * 
 * @param db
 * @param clazz
 * @return
 */
public static CodecRegistry createCodecRegistry( MongoDatabase db, Class<? extends Entity> clazz )
{
    return CodecRegistries.fromProviders( new EntityCodecProvider( db, clazz ), new BsonValueCodecProvider() );
}
 
开发者ID:cherimojava,项目名称:cherimodata,代码行数:12,代码来源:EntityCodecProvider.java


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