本文整理汇总了Java中org.bson.conversions.Bson.toBsonDocument方法的典型用法代码示例。如果您正苦于以下问题:Java Bson.toBsonDocument方法的具体用法?Java Bson.toBsonDocument怎么用?Java Bson.toBsonDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.conversions.Bson
的用法示例。
在下文中一共展示了Bson.toBsonDocument方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.bson.conversions.Bson; //导入方法依赖的package包/类
private BsonDocument parse(String where) {
Bson bson = sqlParser.get(Bson.class, where);
return bson.toBsonDocument(
BsonDocument.class,
CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
示例2: toBsonDocument
import org.bson.conversions.Bson; //导入方法依赖的package包/类
private BsonDocument toBsonDocument(Bson bson) {
return bson.toBsonDocument(
BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
示例3: toBsonDocument
import org.bson.conversions.Bson; //导入方法依赖的package包/类
private BsonDocument toBsonDocument(Bson bson) {
return bson.toBsonDocument(
BsonDocument.class,
CodecRegistries.fromProviders(new BsonValueCodecProvider(), new ValueCodecProvider()));
}
示例4: parse
import org.bson.conversions.Bson; //导入方法依赖的package包/类
private BsonDocument parse(String select) {
Bson bson = sqlParser.get(Bson.class, select);
return bson.toBsonDocument(
BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
示例5: parse
import org.bson.conversions.Bson; //导入方法依赖的package包/类
private BsonDocument parse(String orderBy) {
Bson bson = sqlParser.get(Bson.class, orderBy);
return bson.toBsonDocument(
BsonDocument.class, CodecRegistries.fromProviders(new BsonValueCodecProvider()));
}
示例6: getqueryFromRequestOperatorComparison
import org.bson.conversions.Bson; //导入方法依赖的package包/类
public String getqueryFromRequestOperatorComparison(FeatureConstraint featureConstraint) {
FeatureConstraintType featureConstraintType =
featureConstraint.getFeatureConstraintType();
FeatureConstraintOperator featureConstraintOperator = featureConstraint.getFeatureConstraintOperator();
AthenaField name = featureConstraint.getFeatureName();
List<TargetAthenaValue> value = featureConstraint.getDataRequestObjectValueList();
Bson obj = null;
String target = null;
if (featureConstraintType == FeatureConstraintType.FEATURE) {
target = AthenaFeatureField.FEATURE + "." + name.getValue();
} else if (featureConstraintType == FeatureConstraintType.INDEX) {
target = name.getValue();
} else {
log.warn("not supported type :{}", featureConstraintType.toString());
return null;
}
if (!(value.size() > 0)) {
log.warn("list size is not bigger than 0 :{}", value.size());
return null;
}
for (int i = 0; i < value.size(); i++) {
switch (featureConstraintOperator.getValue()) {
case FeatureConstraintOperator.COMPARISON_EQ:
obj = eq(target, value.get(i).getTargetAthenaValue());
break;
case FeatureConstraintOperator.COMPARISON_GT:
obj = gt(target, value.get(i).getTargetAthenaValue());
break;
case FeatureConstraintOperator.COMPARISON_GTE:
obj = gte(target, value.get(i).getTargetAthenaValue());
break;
case FeatureConstraintOperator.COMPARISON_LT:
obj = lt(target, value.get(i).getTargetAthenaValue());
break;
case FeatureConstraintOperator.COMPARISON_LTE:
obj = lte(target, value.get(i).getTargetAthenaValue());
break;
case FeatureConstraintOperator.COMPARISON_NE:
obj = ne(target, value.get(i).getTargetAthenaValue());
break;
default:
log.warn("not supported comparsion type");
return null;
}
}
BsonDocument matchQueryDocument =
obj.toBsonDocument(BsonDocument.class, MongoClient.getDefaultCodecRegistry());
String modifiedQuery = matchQueryDocument.toString();
if (Objects.equals(featureConstraintOperator.getValue(), FeatureConstraintOperator.COMPARISON_EQ)) {
String[] splited = modifiedQuery.split(":");
modifiedQuery = splited[0] + ": { \"$eq\" :" + splited[1] + ":" + splited[2] + " }";
}
return modifiedQuery;
}