public class

BasicDBObject

extends BasicBSONObject
implements DBObject
java.lang.Object
   ↳ java.util.AbstractMap<K, V>
     ↳ java.util.HashMap<K, V>
       ↳ java.util.LinkedHashMap<K, V>
         ↳ org.bson.BasicBSONObject
           ↳ com.mongodb.BasicDBObject
Known Direct Subclasses

Class Overview

a basic implementation of bson object that is mongo specific. A DBObject can be created as follows, using this class:

 DBObject obj = new BasicDBObject();
 obj.put( "foo", "bar" );
 

Summary

Public Constructors
BasicDBObject()
Creates an empty object.
BasicDBObject(int size)
creates an empty object
BasicDBObject(String key, Object value)
creates an object with the given key/value
BasicDBObject(Map m)
Creates an object from a map.
Public Methods
BasicDBObject append(String key, Object val)
Add a key/value pair to this object
Object copy()
boolean isPartialObject()
whether markAsPartialObject was ever called only matters if you are going to upsert and do not want to risk losing fields
void markAsPartialObject()
if this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.
String toString()
Returns a JSON serialization of this object
[Expand]
Inherited Methods
From class org.bson.BasicBSONObject
From class java.util.LinkedHashMap
From class java.util.HashMap
From class java.util.AbstractMap
From class java.lang.Object
From interface com.mongodb.DBObject
From interface java.util.Map
From interface org.bson.BSONObject

Public Constructors

public BasicDBObject ()

Creates an empty object.

public BasicDBObject (int size)

creates an empty object

Parameters
size an estimate of number of fields that will be inserted

public BasicDBObject (String key, Object value)

creates an object with the given key/value

Parameters
key key under which to store
value value to stor

public BasicDBObject (Map m)

Creates an object from a map.

Parameters
m map to convert

Public Methods

public BasicDBObject append (String key, Object val)

Add a key/value pair to this object

Parameters
key the field name
val the field value
Returns
  • this

public Object copy ()

public boolean isPartialObject ()

whether markAsPartialObject was ever called only matters if you are going to upsert and do not want to risk losing fields

public void markAsPartialObject ()

if this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.

public String toString ()

Returns a JSON serialization of this object

Returns
  • JSON serialization