Package com.mongodb

Class BasicDBObject

  • All Implemented Interfaces:
    DBObject, java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.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:
    Serialized Form
    • Constructor Detail

      • 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

        public BasicDBObject​(java.lang.String key,
                             java.lang.Object value)
        Deprecated.
        Creates an object with the given key/value
        Parameters:
        key - key under which to store
        value - value to store
      • BasicDBObject

        public BasicDBObject​(java.util.Map map)
        Deprecated.
        Creates an object from a map.
        Parameters:
        map - map to convert
    • Method Detail

      • parse

        public static BasicDBObject parse​(java.lang.String json)
        Deprecated.
        Parses a string in MongoDB Extended JSON format to a BasicDBObject.
        Parameters:
        json - the JSON string
        Returns:
        a corresponding BasicDBObject object
        See Also:
        JsonReader
      • parse

        public static BasicDBObject parse​(java.lang.String json,
                                          Decoder<BasicDBObject> decoder)
        Deprecated.
        Parses a string in MongoDB Extended JSON format to a BasicDBObject.
        Parameters:
        json - the JSON string
        decoder - the decoder to use to decode the BasicDBObject instance
        Returns:
        a corresponding BasicDBObject object
        See Also:
        JsonReader
      • append

        public BasicDBObject append​(java.lang.String key,
                                    java.lang.Object val)
        Deprecated.
        Add a key/value pair to this object
        Overrides:
        append in class BasicBSONObject
        Parameters:
        key - the field name
        val - the field value
        Returns:
        this BasicDBObject with the new values added
      • isPartialObject

        public boolean isPartialObject()
        Deprecated.
        Whether markAsPartialObject() was ever called only matters if you are going to upsert and do not want to risk losing fields.
        Specified by:
        isPartialObject in interface DBObject
        Returns:
        true if this has been marked as a partial object
      • toJson

        public java.lang.String toJson​(JsonWriterSettings writerSettings)
        Deprecated.
        Gets a JSON representation of this document

        With 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

        public java.lang.String toJson​(Encoder<BasicDBObject> encoder)
        Deprecated.
        Gets a JSON representation of this document

        With 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

        public java.lang.String toJson​(JsonWriterSettings writerSettings,
                                       Encoder<BasicDBObject> encoder)
        Deprecated.
        Gets a JSON representation of this document
        Parameters:
        writerSettings - the json writer settings to use when encoding
        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.
      • equals

        public boolean equals​(java.lang.Object o)
        Deprecated.
        Description copied from class: BasicBSONObject
        Compares two documents according to their serialized form, ignoring the order of keys.
        Specified by:
        equals in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        equals in class BasicBSONObject
        Parameters:
        o - the document to compare to, which must be an instance of BSONObject.
        Returns:
        true if the documents have the same serialized form, ignoring key order.
      • hashCode

        public int hashCode()
        Deprecated.
        Specified by:
        hashCode in interface java.util.Map<java.lang.String,​java.lang.Object>
        Overrides:
        hashCode in class BasicBSONObject
      • toString

        public java.lang.String toString()
        Deprecated.

        Returns a JSON serialization of this object

        The output will look like: {"a":1, "b":["x","y","z"]}

        Overrides:
        toString in class java.util.AbstractMap<java.lang.String,​java.lang.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 interface DBObject
      • copy

        public java.lang.Object 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​(java.lang.Class<TDocument> documentClass,
                                                       CodecRegistry codecRegistry)
        Deprecated.
        Description copied from interface: Bson
        Render the filter into a BsonDocument.
        Specified by:
        toBsonDocument in interface Bson
        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 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.
        Returns:
        the BsonDocument