|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<String,Object>
com.mongodb.BasicDBObject
public class BasicDBObject
A simple implementation of DBObject
.
A DBObject
can be created as follows, using this class:
DBObject obj = new BasicDBObject(); obj.put( "foo", "bar" );
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(Map m)
Creates a DBObject from a map. |
|
BasicDBObject(String key,
Object value)
Convenience CTOR |
Method Summary | |
---|---|
BasicDBObject |
append(String key,
Object val)
Add a key/value pair to this object |
boolean |
containsField(String field)
Checks if this object contains a given field |
boolean |
containsKey(String key)
Deprecated. |
boolean |
equals(Object o)
|
Object |
get(String key)
Gets a value from this object |
int |
getInt(String key)
Returns the value of a field as an int . |
int |
getInt(String key,
int def)
Returns the value of a field as an int . |
long |
getLong(String key)
Returns the value of a field as a long . |
String |
getString(String key)
Returns the value of a field as a string |
boolean |
isPartialObject()
Checks if this object is ready to be saved. |
void |
markAsPartialObject()
Sets that this object is incomplete and should not be saved. |
Object |
put(String key,
Object val)
Add a key/value pair to this object |
void |
putAll(DBObject o)
|
void |
putAll(Map m)
|
Object |
removeField(String key)
Deletes a field from this object. |
Map |
toMap()
Converts a DBObject to a map. |
String |
toString()
Returns a JSON serialization of this object |
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 com.mongodb.DBObject |
---|
keySet |
Methods inherited from interface java.util.Map |
---|
containsKey, entrySet, hashCode, isEmpty, keySet, remove, size, values |
Constructor Detail |
---|
public BasicDBObject()
public BasicDBObject(String key, Object value)
key
- key under which to storevalue
- value to storpublic BasicDBObject(Map m)
m
- map to convertMethod Detail |
---|
public Map toMap()
toMap
in interface DBObject
public Object removeField(String key)
removeField
in interface DBObject
key
- the field name to remove
public boolean isPartialObject()
isPartialObject
in interface DBObject
public boolean containsField(String field)
containsField
in interface DBObject
field
- field name
public boolean containsKey(String key)
containsKey
in interface DBObject
public Object get(String key)
get
in interface DBObject
key
- field name
public int getInt(String key)
int
.
key
- the field to look for
public int getInt(String key, int def)
int
.
key
- the field to look fordef
- the default to return
public long getLong(String key)
long
.
key
- the field to return
public String getString(String key)
key
- the field to look up
public Object put(String key, Object val)
put
in interface DBObject
put
in interface Map<String,Object>
put
in class HashMap<String,Object>
key
- the field nameval
- the field value
val
parameterpublic void putAll(Map m)
putAll
in interface DBObject
putAll
in interface Map<String,Object>
putAll
in class HashMap<String,Object>
public void putAll(DBObject o)
putAll
in interface DBObject
public BasicDBObject append(String key, Object val)
key
- the field nameval
- the field value
val
parameterpublic String toString()
toString
in class AbstractMap<String,Object>
public void markAsPartialObject()
markAsPartialObject
in interface DBObject
public boolean equals(Object o)
equals
in interface Map<String,Object>
equals
in class AbstractMap<String,Object>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |