|
||||||||||
| 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>
org.bson.BasicBSONObject
public class BasicBSONObject
A simple implementation of DBObject.
A DBObject can be created as follows, using this class:
DBObject obj = new BasicBSONObject(); 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 | |
|---|---|
BasicBSONObject()
Creates an empty object. |
|
BasicBSONObject(int size)
|
|
BasicBSONObject(Map m)
Creates a DBObject from a map. |
|
BasicBSONObject(String key,
Object value)
Convenience CTOR |
|
| Method Summary | |
|---|---|
BasicBSONObject |
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 |
boolean |
getBoolean(String key)
Returns the value of a field as a boolean. |
boolean |
getBoolean(String key,
boolean def)
Returns the value of a field as a boolean |
Date |
getDate(String field)
Returns the date or null if not set. |
Date |
getDate(String field,
Date def)
Returns the date or def if not set. |
double |
getDouble(String key)
Returns the value of a field as a double. |
double |
getDouble(String key,
double def)
Returns the value of a field as an double. |
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. |
long |
getLong(String key,
long def)
Returns the value of a field as an long. |
ObjectId |
getObjectId(String field)
Returns the object id or null if not set. |
ObjectId |
getObjectId(String field,
ObjectId def)
Returns the object id or def if not set. |
String |
getString(String key)
Returns the value of a field as a string |
String |
getString(String key,
String def)
Returns the value of a field as a string |
Object |
put(String key,
Object val)
Add a key/value pair to this object |
void |
putAll(BSONObject o)
Sets all key/value pairs from an object into this object |
void |
putAll(Map m)
Sets all key/value pairs from a map into this object |
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 org.bson.BSONObject |
|---|
keySet |
| Methods inherited from interface java.util.Map |
|---|
containsKey, entrySet, hashCode, isEmpty, keySet, remove, size, values |
| Constructor Detail |
|---|
public BasicBSONObject()
public BasicBSONObject(int size)
public BasicBSONObject(String key,
Object value)
key - key under which to storevalue - value to storpublic BasicBSONObject(Map m)
m - map to convert| Method Detail |
|---|
public Map toMap()
toMap in interface BSONObjectpublic Object removeField(String key)
removeField in interface BSONObjectkey - the field name to remove
public boolean containsField(String field)
containsField in interface BSONObjectfield - field name
@Deprecated public boolean containsKey(String key)
BSONObject
containsKey in interface BSONObjectpublic Object get(String key)
get in interface BSONObjectkey - 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 long getLong(String key,
long def)
long.
key - the field to look fordef - the default to return
public double getDouble(String key)
double.
key - the field to return
public double getDouble(String key,
double def)
double.
key - the field to look fordef - the default to return
public String getString(String key)
key - the field to look up
public String getString(String key,
String def)
key - the field to look updef - the default to return
public boolean getBoolean(String key)
key - the field to look up
public boolean getBoolean(String key,
boolean def)
key - the field to look updef - the default value in case the field is not found
public ObjectId getObjectId(String field)
field - The field to return
public ObjectId getObjectId(String field,
ObjectId def)
field - The field to returndef - the default value in case the field is not found
public Date getDate(String field)
field - The field to return
public Date getDate(String field,
Date def)
field - The field to returndef - the default value in case the field is not found
public Object put(String key,
Object val)
put in interface Map<String,Object>put in interface BSONObjectput in class HashMap<String,Object>key - the field nameval - the field value
val parameterpublic void putAll(Map m)
BSONObject
putAll in interface Map<String,Object>putAll in interface BSONObjectputAll in class HashMap<String,Object>m - the mappublic void putAll(BSONObject o)
BSONObject
putAll in interface BSONObjecto - the object
public BasicBSONObject append(String key,
Object val)
key - the field nameval - the field value
thispublic String toString()
toString in class AbstractMap<String,Object>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 | |||||||||