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<java.lang.String,java.lang.Object>
              extended by org.bson.BasicBSONObject
                  extended by com.mongodb.BasicDBObject
All Implemented Interfaces:
DBObject, java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>, BSONObject
Direct Known Subclasses:
CommandResult

public class BasicDBObject
extends BasicBSONObject
implements DBObject

A simple implementation of DBObject. 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
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
BasicDBObject()
          Creates an empty object.
BasicDBObject(int size)
           
BasicDBObject(java.util.Map m)
          Creates a DBObject from a map.
BasicDBObject(java.lang.String key, java.lang.Object value)
          Convenience CTOR
 
Method Summary
 BasicDBObject append(java.lang.String key, java.lang.Object val)
          Add a key/value pair to this object
 boolean isPartialObject()
          Checks if this object is ready to be saved.
 void markAsPartialObject()
          Sets that this object is incomplete and should not be saved.
 java.lang.String toString()
          Returns a JSON serialization of this object
 
Methods inherited from class org.bson.BasicBSONObject
containsField, containsKey, equals, get, 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)

BasicDBObject

public BasicDBObject(java.lang.String key,
                     java.lang.Object value)
Convenience CTOR

Parameters:
key - key under which to store
value - value to stor

BasicDBObject

public BasicDBObject(java.util.Map m)
Creates a DBObject from a map.

Parameters:
m - map to convert
Method Detail

isPartialObject

public boolean isPartialObject()
Checks if this object is ready to be saved.

Specified by:
isPartialObject in interface DBObject
Returns:
if the object is incomplete

toString

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

Overrides:
toString in class BasicBSONObject
Returns:
JSON serialization

markAsPartialObject

public void markAsPartialObject()
Sets that this object is incomplete and should not be saved.

Specified by:
markAsPartialObject in interface DBObject

append

public BasicDBObject append(java.lang.String key,
                            java.lang.Object val)
Add a key/value pair to this object

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