com.mongodb
Class BasicDBObject

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<String,Object>
              extended by org.bson.BasicBSONObject
                  extended by com.mongodb.BasicDBObject
All Implemented Interfaces:
DBObject, Serializable, Cloneable, Map<String,Object>, BSONObject
Direct Known Subclasses:
CommandResult

public class BasicDBObject
extends BasicBSONObject
implements DBObject

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" );
 

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
BasicDBObject()
          Creates an empty object.
BasicDBObject(int size)
          creates an empty object
BasicDBObject(Map m)
          Creates an object from a map.
BasicDBObject(String key, Object value)
          creates an object with the given key/value
 
Method Summary
 BasicDBObject append(String key, Object val)
          Add a key/value pair to this object
 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
 
Methods inherited from class org.bson.BasicBSONObject
containsField, containsKey, equals, get, getBoolean, getBoolean, getDouble, getInt, getInt, getLong, getString, put, putAll, putAll, removeField, toMap
 
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, remove, size, values
 
Methods inherited from class java.util.AbstractMap
hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.bson.BSONObject
containsField, containsKey, get, keySet, put, putAll, putAll, removeField, toMap
 
Methods inherited from interface java.util.Map
containsKey, entrySet, hashCode, isEmpty, keySet, remove, size, values
 

Constructor Detail

BasicDBObject

public BasicDBObject()
Creates an empty object.


BasicDBObject

public BasicDBObject(int size)
creates an empty object

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

BasicDBObject

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

BasicDBObject

public BasicDBObject(Map m)
Creates an object from a map.

Parameters:
m - map to convert
Method Detail

isPartialObject

public boolean isPartialObject()
Description copied from interface: DBObject
whether markAsPartialObject was ever called only matters if you are going to upsert and do not want to risk losing fields

Specified by:
isPartialObject in interface DBObject

markAsPartialObject

public void markAsPartialObject()
Description copied from interface: DBObject
if this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.

Specified by:
markAsPartialObject in interface DBObject

toString

public String toString()
Returns a JSON serialization of this object

Overrides:
toString in class BasicBSONObject
Returns:
JSON serialization

append

public BasicDBObject append(String key,
                            Object val)
Description copied from class: BasicBSONObject
Add a key/value pair to this object

Overrides:
append in class BasicBSONObject
Parameters:
key - the field name
val - the field value
Returns:
this