Example usage for com.mongodb BasicDBObject get

List of usage examples for com.mongodb BasicDBObject get

Introduction

In this page you can find the example usage for com.mongodb BasicDBObject get.

Prototype

public Object get(final String key) 

Source Link

Document

Gets a value from this object

Usage

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static String readId(BasicDBObject dbObject, String fieldName) {
    Object value = dbObject.get(fieldName);
    return value != null ? value.toString() : null;
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

@SuppressWarnings("unchecked")
public static Map<String, Object> readObjectMap(BasicDBObject dbObject, String fieldName) {
    return (Map<String, Object>) dbObject.get(fieldName);
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static String readString(BasicDBObject dbObject, String fieldName) {
    return (String) dbObject.get(fieldName);
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static WorkflowId readWorkflowId(BasicDBObject dbObject, String fieldName) {
    Object oid = dbObject.get(fieldName);
    return oid != null ? new WorkflowId(oid.toString()) : null;
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static WorkflowInstanceId readWorkflowInstanceId(BasicDBObject dbObject, String fieldName) {
    Object oid = dbObject.get(fieldName);
    return oid != null ? new WorkflowInstanceId(oid.toString()) : null;
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static Long readLong(BasicDBObject dbObject, String fieldName) {
    Object object = dbObject.get(fieldName);
    if (object == null) {
        return null;
    }//w  w w .j  a va2 s .  com
    if (object instanceof Long) {
        return (Long) object;
    }
    return ((Number) object).longValue();
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static Boolean readBoolean(BasicDBObject dbObject, String fieldName) {
    return (Boolean) dbObject.get(fieldName);
}

From source file:com.effektif.mongo.MongoHelper.java

License:Apache License

public static LocalDateTime readTime(BasicDBObject dbObject, String fieldName) {
    Object object = dbObject.get(fieldName);
    if (object == null) {
        return null;
    }//from w  ww. j  a v  a 2  s. c  o  m
    if (object instanceof Date) {
        return new LocalDateTime((Date) object);
    }
    throw new RuntimeException("date conversion problem: " + object + " (" + object.getClass().getName() + ")");
}

From source file:com.effektif.mongo.MongoReaderHelper.java

License:Apache License

@SuppressWarnings("unchecked")
protected static List<BasicDBObject> getList(BasicDBObject dbScope, String fieldName) {
    return (List<BasicDBObject>) dbScope.get(fieldName);
}

From source file:com.effektif.mongo.MongoReaderHelper.java

License:Apache License

@SuppressWarnings("unchecked")
protected static Map<String, Object> getMap(BasicDBObject dbObject, String fieldName) {
    return (Map<String, Object>) dbObject.get(fieldName);
}