Package org.bson
Class BsonDocument
java.lang.Object
org.bson.BsonValue
org.bson.BsonDocument
- Direct Known Subclasses:
BsonDocumentWrapper
,RawBsonDocument
@Deprecated(since="2022-10-31")
public class BsonDocument
extends BsonValue
implements Map<String,BsonValue>, Cloneable, Bson, Serializable
Deprecated.
Usage of this API is not supported in AEM as a Cloud Service.
A type-safe container for a BSON document. This class should NOT be sub-classed by third parties.
- Since:
- 3.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Construct an empty document.BsonDocument
(String key, BsonValue value) Deprecated.Construct a new instance with a single key value pairBsonDocument
(List<BsonElement> bsonElements) Deprecated.Construct a new instance with the given listBsonElement
, none of which may be null. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Put the given key and value into this document, and return the document.Deprecated.Gets the first value in the documentvoid
clear()
Deprecated.clone()
Deprecated.boolean
containsKey
(Object key) Deprecated.boolean
containsValue
(Object value) Deprecated.entrySet()
Deprecated.boolean
Deprecated.Deprecated.Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonArray, or throws if not.Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonBinary, or throws if not.getBinary
(Object key, BsonBinary defaultValue) Deprecated.If the document does not contain the given key, return the given default value.getBoolean
(Object key) Deprecated.Gets the value of the key if it is a BsonBoolean, or throws if not.getBoolean
(Object key, BsonBoolean defaultValue) Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the BSON type of this value.getDateTime
(Object key) Deprecated.Gets the value of the key if it is a BsonDateTime, or throws if not.getDateTime
(Object key, BsonDateTime defaultValue) Deprecated.If the document does not contain the given key, return the given default value.getDecimal128
(Object key) Deprecated.Gets the value of the key if it is a BsonDecimal128, or throws if not.getDecimal128
(Object key, BsonDecimal128 defaultValue) Deprecated.If the document does not contain the given key, return the given default value.getDocument
(Object key) Deprecated.Gets the value of the key if it is a BsonDocument, or throws if not.getDocument
(Object key, BsonDocument defaultValue) Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonDouble, or throws if not.getDouble
(Object key, BsonDouble defaultValue) Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the first key in the document.Deprecated.Gets the value of the key if it is a BsonInt32, or throws if not.Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonInt64, or throws if not.Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonNumber, or throws if not.getNumber
(Object key, BsonNumber defaultValue) Deprecated.If the document does not contain the given key, return the given default value.getObjectId
(Object key) Deprecated.Gets the value of the key if it is a BsonObjectId, or throws if not.getObjectId
(Object key, BsonObjectId defaultValue) Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonRegularExpression, or throws if not.getRegularExpression
(Object key, BsonRegularExpression defaultValue) Deprecated.If the document does not contain the given key, return the given default value.Deprecated.Gets the value of the key if it is a BsonString, or throws if not.getString
(Object key, BsonString defaultValue) Deprecated.If the document does not contain the given key, return the given default value.getTimestamp
(Object key) Deprecated.Gets the value of the key if it is a BsonTimestamp, or throws if not.getTimestamp
(Object key, BsonTimestamp defaultValue) Deprecated.If the document does not contain the given key, return the given default value.int
hashCode()
Deprecated.boolean
Deprecated.Returns true if the value of the key is a BsonArray, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonBinary, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonBoolean, returns false if the document does not contain the key.boolean
isDateTime
(Object key) Deprecated.Returns true if the value of the key is a BsonDateTime, returns false if the document does not contain the key.boolean
isDecimal128
(Object key) Deprecated.Returns true if the value of the key is a BsonDecimal128, returns false if the document does not contain the key.boolean
isDocument
(Object key) Deprecated.Returns true if the value of the key is a BsonDocument, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonDouble, returns false if the document does not contain the key.boolean
isEmpty()
Deprecated.boolean
Deprecated.Returns true if the value of the key is a BsonInt32, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonInt64, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonNull, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonNumber, returns false if the document does not contain the key.boolean
isObjectId
(Object key) Deprecated.Returns true if the value of the key is a BsonObjectId, returns false if the document does not contain the key.boolean
Deprecated.Returns true if the value of the key is a BsonString, returns false if the document does not contain the key.boolean
isTimestamp
(Object key) Deprecated.Returns true if the value of the key is a BsonTimestamp, returns false if the document does not contain the key.keySet()
Deprecated.static BsonDocument
Deprecated.Parses a string in MongoDB Extended JSON format to aBsonDocument
Deprecated.void
Deprecated.Deprecated.int
size()
Deprecated.<C> BsonDocument
toBsonDocument
(Class<C> 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
.toJson
(JsonWriterSettings settings) Deprecated.Gets a JSON representation of this document using the givenJsonWriterSettings
.toString()
Deprecated.values()
Deprecated.Methods inherited from class org.bson.BsonValue
asArray, asBinary, asBoolean, asDateTime, asDBPointer, asDecimal128, asDocument, asDouble, asInt32, asInt64, asJavaScript, asJavaScriptWithScope, asNumber, asObjectId, asRegularExpression, asString, asSymbol, asTimestamp, isArray, isBinary, isBoolean, isDateTime, isDBPointer, isDecimal128, isDocument, isDouble, isInt32, isInt64, isJavaScript, isJavaScriptWithScope, isNull, isNumber, isObjectId, isRegularExpression, isString, isSymbol, isTimestamp
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
BsonDocument
Deprecated.Construct a new instance with the given listBsonElement
, none of which may be null.- Parameters:
bsonElements
- a list ofBsonElement
-
BsonDocument
Deprecated.Construct a new instance with a single key value pair- Parameters:
key
- the keyvalue
- the value
-
BsonDocument
public BsonDocument()Deprecated.Construct an empty document.
-
-
Method Details
-
parse
Deprecated.Parses a string in MongoDB Extended JSON format to aBsonDocument
- Parameters:
json
- the JSON string- Returns:
- a corresponding
BsonDocument
object - See Also:
-
toBsonDocument
Deprecated.Description copied from interface:Bson
Render the filter into a BsonDocument.- Specified by:
toBsonDocument
in interfaceBson
- Type Parameters:
C
- 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
-
getBsonType
Deprecated.Description copied from class:BsonValue
Gets the BSON type of this value.- Specified by:
getBsonType
in classBsonValue
- Returns:
- the BSON type, which may not be null (but may be BSONType.NULL)
-
size
public int size()Deprecated. -
isEmpty
public boolean isEmpty()Deprecated. -
containsKey
Deprecated.- Specified by:
containsKey
in interfaceMap<String,
BsonValue>
-
containsValue
Deprecated.- Specified by:
containsValue
in interfaceMap<String,
BsonValue>
-
get
Deprecated. -
getDocument
Deprecated.Gets the value of the key if it is a BsonDocument, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonDocument
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not a BsonDocument
-
getArray
Deprecated.Gets the value of the key if it is a BsonArray, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonArray
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getNumber
Deprecated.Gets the value of the key if it is a BsonNumber, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonNumber
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getInt32
Deprecated.Gets the value of the key if it is a BsonInt32, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonInt32
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getInt64
Deprecated.Gets the value of the key if it is a BsonInt64, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonInt64
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getDecimal128
Deprecated.Gets the value of the key if it is a BsonDecimal128, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonDecimal128
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type- Since:
- 3.4
-
getDouble
Deprecated.Gets the value of the key if it is a BsonDouble, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonDouble
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getBoolean
Deprecated.Gets the value of the key if it is a BsonBoolean, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonBoolean
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getString
Deprecated.Gets the value of the key if it is a BsonString, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonString
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getDateTime
Deprecated.Gets the value of the key if it is a BsonDateTime, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonDateTime
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getTimestamp
Deprecated.Gets the value of the key if it is a BsonTimestamp, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonTimestamp
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getObjectId
Deprecated.Gets the value of the key if it is a BsonObjectId, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonObjectId
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getRegularExpression
Deprecated.Gets the value of the key if it is a BsonRegularExpression, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonRegularExpression
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
getBinary
Deprecated.Gets the value of the key if it is a BsonBinary, or throws if not.- Parameters:
key
- the key- Returns:
- the value of the key as a BsonBinary
- Throws:
BsonInvalidOperationException
- if the document does not contain the key or the value is not of the expected type
-
isNull
Deprecated.Returns true if the value of the key is a BsonNull, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonNull, returns false if the document does not contain the key.
-
isDocument
Deprecated.Returns true if the value of the key is a BsonDocument, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonDocument, returns false if the document does not contain the key.
-
isArray
Deprecated.Returns true if the value of the key is a BsonArray, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonArray, returns false if the document does not contain the key.
-
isNumber
Deprecated.Returns true if the value of the key is a BsonNumber, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonNumber, returns false if the document does not contain the key.
-
isInt32
Deprecated.Returns true if the value of the key is a BsonInt32, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonInt32, returns false if the document does not contain the key.
-
isInt64
Deprecated.Returns true if the value of the key is a BsonInt64, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonInt64, returns false if the document does not contain the key.
-
isDecimal128
Deprecated.Returns true if the value of the key is a BsonDecimal128, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonDecimal128, returns false if the document does not contain the key.
- Since:
- 3.4
-
isDouble
Deprecated.Returns true if the value of the key is a BsonDouble, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonDouble, returns false if the document does not contain the key.
-
isBoolean
Deprecated.Returns true if the value of the key is a BsonBoolean, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonBoolean, returns false if the document does not contain the key.
-
isString
Deprecated.Returns true if the value of the key is a BsonString, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonString, returns false if the document does not contain the key.
-
isDateTime
Deprecated.Returns true if the value of the key is a BsonDateTime, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonDateTime, returns false if the document does not contain the key.
-
isTimestamp
Deprecated.Returns true if the value of the key is a BsonTimestamp, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonTimestamp, returns false if the document does not contain the key.
-
isObjectId
Deprecated.Returns true if the value of the key is a BsonObjectId, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonObjectId, returns false if the document does not contain the key.
-
isBinary
Deprecated.Returns true if the value of the key is a BsonBinary, returns false if the document does not contain the key.- Parameters:
key
- the key- Returns:
- true if the value of the key is a BsonBinary, returns false if the document does not contain the key.
-
get
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonValue
-
getDocument
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDocument.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonDocument
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getArray
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonArray.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonArray
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getNumber
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonNumber.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonNumber
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getInt32
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonInt32.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonInt32
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getInt64
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonInt64.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonInt64
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getDecimal128
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDecimal128.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonDecimal128
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type- Since:
- 3.4
-
getDouble
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDouble.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonDouble
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getBoolean
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonBoolean.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonBoolean
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getString
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonString.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonString
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getDateTime
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDateTime.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonDateTime
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getTimestamp
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonTimestamp.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonTimestamp
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getObjectId
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonObjectId.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonObjectId
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getBinary
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonBinary.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonBinary
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
getRegularExpression
Deprecated.If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonRegularExpression.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the value of the key as a BsonRegularExpression
- Throws:
BsonInvalidOperationException
- if the document contains the key but the value is not of the expected type
-
put
Deprecated. -
remove
Deprecated. -
putAll
Deprecated. -
clear
public void clear()Deprecated. -
keySet
Deprecated. -
values
Deprecated. -
entrySet
Deprecated. -
append
Deprecated.Put the given key and value into this document, and return the document.- Parameters:
key
- the keyvalue
- the value- Returns:
- this
-
getFirstKey
Deprecated.Gets the first key in the document.- Returns:
- the first key in the document
- Throws:
NoSuchElementException
- if the document is empty- Since:
- 3.6
-
asBsonReader
Deprecated.Gets the first value in the document- Returns:
- the first value in the document
- Throws:
NoSuchElementException
- if the document is empty- Since:
- 3.7
-
equals
Deprecated. -
hashCode
public int hashCode()Deprecated. -
toJson
Deprecated.Gets a JSON representation of this document using theJsonMode.STRICT
output mode, and otherwise the default settings ofJsonWriterSettings.Builder
.- Returns:
- a JSON representation of this document
- See Also:
-
toJson
Deprecated.Gets a JSON representation of this document using the givenJsonWriterSettings
.- Parameters:
settings
- the JSON writer settings- Returns:
- a JSON representation of this document
-
toString
Deprecated. -
clone
Deprecated.
-