public class BasicDBObject extends BasicBSONObject implements DBObject, Bson
DBObject can be created as follows, using this class:
DBObject obj = new BasicDBObject(); obj.put( "foo", "bar" );
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
BasicDBObject()
Creates an empty object.
|
BasicDBObject(int size)
Creates an empty object
|
BasicDBObject(Map map)
Creates an object from a map.
|
BasicDBObject(String key,
Object value)
Creates an object with the given key/value
|
| Modifier and Type | Method and Description |
|---|---|
BasicDBObject |
append(String key,
Object val)
Add a key/value pair to this object
|
Object |
copy()
Creates a new instance which is a copy of this BasicDBObject.
|
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.
|
<TDocument> |
toBsonDocument(Class<TDocument> documentClass,
CodecRegistry codecRegistry)
Render the filter into a BsonDocument.
|
String |
toString()
Returns a JSON serialization of this object
|
containsField, containsKey, equals, get, getBoolean, getBoolean, getDate, getDate, getDouble, getDouble, getInt, getInt, getLong, getLong, getObjectId, getObjectId, getString, getString, hashCode, putAll, putAll, removeField, toMapclear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putIfAbsent, remove, remove, replace, replace, sizefinalize, getClass, notify, notifyAll, wait, wait, waitcontainsField, containsKey, get, keySet, put, putAll, putAll, removeField, toMapcompute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putIfAbsent, remove, remove, replace, replace, sizepublic BasicDBObject()
public BasicDBObject(int size)
size - an estimate of number of fields that will be insertedpublic BasicDBObject(String key, Object value)
key - key under which to storevalue - value to storepublic BasicDBObject(Map map)
map - map to convertpublic BasicDBObject append(String key, Object val)
append in class BasicBSONObjectkey - the field nameval - the field valuepublic boolean isPartialObject()
markAsPartialObject() was ever called only matters if you are going to upsert and do not want to risk losing fields.isPartialObject in interface DBObjectpublic String toString()
Returns a JSON serialization of this object
The output will look like: {"a":1, "b":["x","y","z"]}
toString in class BasicBSONObjectpublic void markAsPartialObject()
markAsPartialObject in interface DBObjectpublic Object copy()
public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry)
BsontoBsonDocument in interface BsonTDocument - the type of the document classdocumentClass - the document class in scope for the collection. This parameter may be ignored, but it may be used to alter
the structure of the returned BsonDocument based on some knowledge of the document class.codecRegistry - the codec registry. This parameter may be ignored, but it may be used to look up Codec instances for
the document class or any other related class.