本文整理汇总了Java中com.mongodb.BasicDBObject.get方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBObject.get方法的具体用法?Java BasicDBObject.get怎么用?Java BasicDBObject.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.BasicDBObject
的用法示例。
在下文中一共展示了BasicDBObject.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parserDBObject
import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
private void parserDBObject(BasicDBObject ob,String akey, String aop,Object aval){
boolean isok=false;
if (!(ob.keySet().isEmpty())) {
for (String field : ob.keySet()) {
if (akey.equals(field)){
Object val = ob.get(field);
if (val instanceof BasicDBObject) {
((BasicDBObject) val).put(aop, aval);
ob.put(field, (BasicDBObject) val);
isok=true;
break;
} else if (val instanceof BasicDBList) {
// newobj.put(field, ((BasicDBList)val).copy());
}
}
}
}
if (isok==false) {
BasicDBObject xo = new BasicDBObject();
xo.put(aop, aval);
ob.put(akey,xo);
}
}
示例2: convertWrappedVirtualObject
import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public WrappedVirtualObject convertWrappedVirtualObject(BasicDBObject source) {
Integer classId = (Integer) source.get("eClassId");
Object featuresObject = source.get("features");
EClass eclass = platformService.getEClassForCid(classId.shortValue());
WrappedVirtualObject wrappedVirtualObject = new WrappedVirtualObject(classId.shortValue(), eclass);
processFeatures((Map) featuresObject, wrappedVirtualObject);
return wrappedVirtualObject;
}
示例3: isEqual
import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public boolean isEqual(BasicDBObject other) {
BasicDBList oMembers = (BasicDBList) other.get(JSON_KEY_MEMBERS_LIST);
return ((oMembers.containsAll(Arrays.asList(this.members))
&& oMembers.size() == this.members.length)
&& this.name.equals(other.get(JSON_KEY_GROUP_NAME))
&& this.id.equals(other.getString(DB_ID)));
}
示例4: createOccasion
import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@POST
@Path("/")
@Consumes(MediaType.APPLICATION_JSON)
public Response createOccasion(JsonObject json) {
String method = "createOccasion";
logger.entering(clazz, method, json);
// Validate the JWT. At this point, anyone create an occasion if they
// have a valid JWT.
try {
validateJWT();
} catch (JWTException jwte) {
logger.exiting(clazz, method, Status.UNAUTHORIZED);
return Response.status(Status.UNAUTHORIZED)
.type(MediaType.TEXT_PLAIN)
.entity(jwte.getMessage())
.build();
}
Response response;
// make sure we received some json
if (null == json || json.toString().isEmpty()) {
response = Response.status(400).entity("Create failed. Empty payload.").build();
} else {
logger.fine("json = " + json);
Occasion occasion = new Occasion(json);
BasicDBObject dbo = occasion.toDbo();
logger.fine("dbo = " + dbo);
// new json payload should not contain an id
ObjectId id = (ObjectId) dbo.get(Occasion.OCCASION_ID_KEY);
logger.fine("id = " + id);
if (null != id && !id.toString().isEmpty()) {
logger.fine("non null id, responding 400");
response =
Response.status(400)
.entity(
"Create failed. Payload must not contain an ID. Recieved ID: \"" + id + "\"")
.build();
} else {
// store the occasion and return the ID
getCollection().insert(dbo);
ObjectId occasionId = dbo.getObjectId(Occasion.OCCASION_ID_KEY);
logger.fine("id: " + occasionId.toString());
String jsonResp =
new Occasion(occasionId, null, null, null, null, null, null, null).toString();
logger.fine(jsonResp);
response = Response.ok(jsonResp, MediaType.APPLICATION_JSON).build();
occasion.setId(occasionId);
// Schedule occasion with the orchestrator
try {
orchestrator.scheduleOccasion(occasion);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
logger.exiting(clazz, method, response.readEntity(String.class));
return response;
}
示例5: runOccasion
import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@POST
@Path("/run")
@Consumes(MediaType.APPLICATION_JSON)
public Response runOccasion(JsonObject json) {
String method = "runOccasion";
logger.entering(clazz, method, json);
// Validate the JWT. At this point, anyone create an occasion if they
// have a valid JWT.
try {
validateJWT();
} catch (JWTException jwte) {
logger.exiting(clazz, method, Status.UNAUTHORIZED);
return Response.status(Status.UNAUTHORIZED)
.type(MediaType.TEXT_PLAIN)
.entity(jwte.getMessage())
.build();
}
Response response;
// make sure we received some json
if (null == json || json.toString().isEmpty()) {
response = Response.status(400).entity("Run failed. Empty payload.").build();
} else {
logger.fine("json = " + json);
Occasion occasion = new Occasion(json);
BasicDBObject dbo = occasion.toDbo();
logger.fine("dbo = " + dbo);
// new json payload should not contain an id
ObjectId id = (ObjectId) dbo.get(Occasion.OCCASION_ID_KEY);
logger.fine("ObjectId id = " + id + " Occasion id = " + occasion.getId());
if (null == id || id.toString().isEmpty()) {
logger.fine("non null id, responding 400");
response = Response.status(400).entity("Run failed. Payload must contain an ID.").build();
} else {
// Run the occasion
OccasionResponse occasionResponse = orchestrator.runOccasion(occasion);
response = buildPostRunResponse(occasionResponse);
}
}
logger.exiting(clazz, method, response);
return response;
}
示例6: createIndex
import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
protected void createIndex(String name, BasicDBList dbList, MongoCollection<Document> collection) {
if (dbList.isEmpty() || name == null) {
return;
}
BasicDBObject index = (BasicDBObject) dbList.get(0);
IndexOptions options = new IndexOptions().name(name);
if (dbList.size() > 1) {
BasicDBObject opts = (BasicDBObject) dbList.get(1);
if (opts.get("unique") != null && opts.get("unique") instanceof Boolean) {
options = options.unique(opts.getBoolean("unique"));
}
if (opts.get("expireAfterSeconds") != null && opts.get("expireAfterSeconds") instanceof Integer) {
options = options.expireAfter(Long.valueOf(opts.getInt("expireAfterSeconds")), TimeUnit.SECONDS);
}
if (opts.get("background") != null && opts.get("background") instanceof Boolean) {
options = options.background(opts.getBoolean("background"));
}
if (opts.get("bits") != null && opts.get("bits") instanceof Integer) {
options = options.bits(opts.getInt("bits"));
}
if (opts.get("bucketSize") != null && opts.get("bucketSize") instanceof Double) {
options = options.bucketSize(opts.getDouble("bucketSize"));
}
if (opts.get("defaultLanguage") != null && opts.get("defaultLanguage") instanceof String) {
options = options.defaultLanguage(opts.getString("defaultLanguage"));
}
if (opts.get("languageOverride") != null && opts.get("languageOverride") instanceof String) {
options = options.languageOverride(opts.getString("languageOverride"));
}
if (opts.get("min") != null && opts.get("min") instanceof Double) {
options = options.min(opts.getDouble("min"));
}
if (opts.get("max") != null && opts.get("max") instanceof Double) {
options = options.max(opts.getDouble("max"));
}
if (opts.get("sparse") != null && opts.get("sparse") instanceof Boolean) {
options = options.sparse(opts.getBoolean("sparse"));
}
if (opts.get("textVersion") != null && opts.get("textVersion") instanceof Integer) {
options = options.textVersion(opts.getInt("textVersion"));
}
if (opts.get("version") != null && opts.get("version") instanceof Integer) {
options = options.version(opts.getInt("version"));
}
if (opts.get("weights") != null && opts.get("weights") instanceof Bson) {
options = options.weights((Bson) opts.get("weights"));
}
}
collection.createIndex(new Document(index), options);
}