Package com.mongodb
Class BasicDBObject
- All Implemented Interfaces:
DBObject
,Serializable
,Cloneable
,Map<String,
,Object> SequencedMap<String,
,Object> BSONObject
,Bson
- Direct Known Subclasses:
CommandResult
@Deprecated(since="2021-05-27")
public class BasicDBObject
extends BasicBSONObject
implements DBObject, Bson
Deprecated.
Usage of this API is not supported in AEM as a Cloud Service.
A basic implementation of BSON object that is MongoDB specific. A
DBObject
can be created as follows, using this class:
DBObject obj = new BasicDBObject(); obj.put( "foo", "bar" );
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Creates an empty object.BasicDBObject
(int size) Deprecated.Creates an empty objectBasicDBObject
(String key, Object value) Deprecated.Creates an object with the given key/valueBasicDBObject
(Map map) Deprecated.Creates an object from a map. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Add a key/value pair to this objectcopy()
Deprecated.Creates a new instance which is a copy of this BasicDBObject.boolean
Deprecated.Compares two documents according to their serialized form, ignoring the order of keys.int
hashCode()
Deprecated.boolean
Deprecated.WhethermarkAsPartialObject()
was ever called only matters if you are going to upsert and do not want to risk losing fields.void
Deprecated.If this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.static BasicDBObject
Deprecated.Parses a string in MongoDB Extended JSON format to aBasicDBObject
.static BasicDBObject
parse
(String json, Decoder<BasicDBObject> decoder) Deprecated.Parses a string in MongoDB Extended JSON format to aBasicDBObject
.<TDocument>
BsonDocumenttoBsonDocument
(Class<TDocument> documentClass, CodecRegistry codecRegistry) Deprecated.Render the filter into a BsonDocument.toJson()
Deprecated.Gets a JSON representation of this document using theJsonMode.STRICT
output mode, and otherwise the default settings ofJsonWriterSettings.Builder
andDBObjectCodec
.toJson
(Encoder<BasicDBObject> encoder) Deprecated.Gets a JSON representation of this documenttoJson
(JsonWriterSettings writerSettings) Deprecated.Gets a JSON representation of this documenttoJson
(JsonWriterSettings writerSettings, Encoder<BasicDBObject> encoder) Deprecated.Gets a JSON representation of this documenttoString()
Deprecated.Returns a JSON serialization of this objectMethods inherited from class org.bson.BasicBSONObject
containsField, containsKey, get, getBoolean, getBoolean, getDate, getDate, getDouble, getDouble, getInt, getInt, getLong, getLong, getObjectId, getObjectId, getString, getString, putAll, putAll, removeField, toMap
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, values
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from interface org.bson.BSONObject
containsField, containsKey, get, keySet, put, putAll, putAll, removeField, toMap
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putIfAbsent, remove, remove, replace, replace, size
Methods inherited from interface java.util.SequencedMap
firstEntry, lastEntry, pollFirstEntry, pollLastEntry
-
Constructor Details
-
BasicDBObject
public BasicDBObject()Deprecated.Creates an empty object. -
BasicDBObject
public BasicDBObject(int size) Deprecated.Creates an empty object- Parameters:
size
- an estimate of number of fields that will be inserted
-
BasicDBObject
Deprecated.Creates an object with the given key/value- Parameters:
key
- key under which to storevalue
- value to store
-
BasicDBObject
Deprecated.Creates an object from a map.- Parameters:
map
- map to convert
-
-
Method Details
-
parse
Deprecated.Parses a string in MongoDB Extended JSON format to aBasicDBObject
.- Parameters:
json
- the JSON string- Returns:
- a corresponding
BasicDBObject
object - See Also:
-
parse
Deprecated.Parses a string in MongoDB Extended JSON format to aBasicDBObject
.- Parameters:
json
- the JSON stringdecoder
- the decoder to use to decode the BasicDBObject instance- Returns:
- a corresponding
BasicDBObject
object - See Also:
-
append
Deprecated.Add a key/value pair to this object- Overrides:
append
in classBasicBSONObject
- Parameters:
key
- the field nameval
- the field value- Returns:
- this BasicDBObject with the new values added
-
isPartialObject
public boolean isPartialObject()Deprecated.WhethermarkAsPartialObject()
was ever called only matters if you are going to upsert and do not want to risk losing fields.- Specified by:
isPartialObject
in interfaceDBObject
- Returns:
- true if this has been marked as a partial object
-
toJson
Deprecated.Gets a JSON representation of this document using theJsonMode.STRICT
output mode, and otherwise the default settings ofJsonWriterSettings.Builder
andDBObjectCodec
.- Returns:
- a JSON representation of this document
- Throws:
CodecConfigurationException
- if the document contains types not in the default registry- See Also:
-
toJson
Deprecated.Gets a JSON representation of this documentWith the default
DBObjectCodec
.- Parameters:
writerSettings
- the json writer settings to use when encoding- Returns:
- a JSON representation of this document
- Throws:
CodecConfigurationException
- if the document contains types not in the default registry
-
toJson
Deprecated.Gets a JSON representation of this documentWith the default
JsonWriterSettings
.- Parameters:
encoder
- the BasicDBObject codec instance to encode the document with- Returns:
- a JSON representation of this document
- Throws:
CodecConfigurationException
- if the registry does not contain a codec for the document values.
-
toJson
Deprecated.Gets a JSON representation of this document- Parameters:
writerSettings
- the json writer settings to use when encodingencoder
- the BasicDBObject codec instance to encode the document with- Returns:
- a JSON representation of this document
- Throws:
CodecConfigurationException
- if the registry does not contain a codec for the document values.
-
equals
Deprecated.Description copied from class:BasicBSONObject
Compares two documents according to their serialized form, ignoring the order of keys.- Specified by:
equals
in interfaceMap<String,
Object> - Overrides:
equals
in classBasicBSONObject
- Parameters:
o
- the document to compare to, which must be an instance ofBSONObject
.- Returns:
- true if the documents have the same serialized form, ignoring key order.
-
hashCode
public int hashCode()Deprecated. -
toString
Deprecated.Returns a JSON serialization of this object
The output will look like:
{"a":1, "b":["x","y","z"]}
- Overrides:
toString
in classAbstractMap<String,
Object> - Returns:
- JSON serialization
-
markAsPartialObject
public void markAsPartialObject()Deprecated.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 interfaceDBObject
-
copy
Deprecated.Creates a new instance which is a copy of this BasicDBObject.- Returns:
- a BasicDBObject with exactly the same values as this instance.
-
toBsonDocument
public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry) Deprecated.Description copied from interface:Bson
Render the filter into a BsonDocument.- Specified by:
toBsonDocument
in interfaceBson
- Type Parameters:
TDocument
- the type of the document class- Parameters:
documentClass
- the document class in scope for the collection. This parameter may be ignored, but it may be used to alter the structure of the returnedBsonDocument
based on some knowledge of the document class.codecRegistry
- the codec registry. This parameter may be ignored, but it may be used to look upCodec
instances for the document class or any other related class.- Returns:
- the BsonDocument
-