本文整理匯總了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;
}