Package org.bson.codecs
Class DocumentCodec
java.lang.Object
org.bson.codecs.DocumentCodec
- All Implemented Interfaces:
Codec<Document>,CollectibleCodec<Document>,Decoder<Document>,Encoder<Document>,OverridableUuidRepresentationCodec<Document>
@Deprecated(since="2022-10-31")
public class DocumentCodec
extends Object
implements CollectibleCodec<Document>, OverridableUuidRepresentationCodec<Document>
Deprecated.
Usage of this API is not supported in AEM as a Cloud Service.
A Codec for Document instances.
- Since:
- 3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Construct a new instance with a defaultCodecRegistry.DocumentCodec(CodecRegistry registry) Deprecated.Construct a new instance with the given registry.DocumentCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap) Deprecated.Construct a new instance with the given registry and BSON type class map.DocumentCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer) Deprecated.Construct a new instance with the given registry and BSON type class map. -
Method Summary
Modifier and TypeMethodDescriptiondecode(BsonReader reader, DecoderContext decoderContext) Deprecated.Decodes a BSON value from the given reader into an instance of the type parameterT.booleandocumentHasId(Document document) Deprecated.Returns true if the given document has an _id.voidencode(BsonWriter writer, Document document, EncoderContext encoderContext) Deprecated.Encode an instance of the type parameterTinto a BSON value.generateIdIfAbsentFromDocument(Document document) Deprecated.Generates a value for the _id field on the given document, if the document does not have one.getDocumentId(Document document) Deprecated.Gets the _id of the given document if it contains one, otherwise throwsIllegalArgumentException.Deprecated.Returns the Class instance that this encodes.withUuidRepresentation(UuidRepresentation uuidRepresentation) Deprecated.Implementations must return a new instance with theUuidRepresentationoverridden with the given value.
-
Constructor Details
-
DocumentCodec
public DocumentCodec()Deprecated.Construct a new instance with a defaultCodecRegistry. -
DocumentCodec
Deprecated.Construct a new instance with the given registry.- Parameters:
registry- the registry- Since:
- 3.5
-
DocumentCodec
Deprecated.Construct a new instance with the given registry and BSON type class map.- Parameters:
registry- the registrybsonTypeClassMap- the BSON type class map
-
DocumentCodec
public DocumentCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer) Deprecated.Construct a new instance with the given registry and BSON type class map. The transformer is applied as a last step when decoding values, which allows users of this codec to control the decoding process. For example, a user of this class could substitute a value decoded as a Document with an instance of a special purpose class (e.g., one representing a DBRef in MongoDB).- Parameters:
registry- the registrybsonTypeClassMap- the BSON type class mapvalueTransformer- the value transformer to use as a final step when decoding the value of any field in the document
-
-
Method Details
-
withUuidRepresentation
Deprecated.Description copied from interface:OverridableUuidRepresentationCodecImplementations must return a new instance with theUuidRepresentationoverridden with the given value.- Specified by:
withUuidRepresentationin interfaceOverridableUuidRepresentationCodec<Document>- Parameters:
uuidRepresentation- the UuidRepresentation- Returns:
- a new instance equivalent to this but with the given UuidRepresentation
-
documentHasId
Deprecated.Description copied from interface:CollectibleCodecReturns true if the given document has an _id.- Specified by:
documentHasIdin interfaceCollectibleCodec<Document>- Parameters:
document- the document in which to look for an _id- Returns:
- true if the document has an _id
-
getDocumentId
Deprecated.Description copied from interface:CollectibleCodecGets the _id of the given document if it contains one, otherwise throwsIllegalArgumentException. To avoid the latter case, calldocumentHasIdfirst to check.- Specified by:
getDocumentIdin interfaceCollectibleCodec<Document>- Parameters:
document- the document from which to get the _id- Returns:
- the _id of the document
-
generateIdIfAbsentFromDocument
Deprecated.Description copied from interface:CollectibleCodecGenerates a value for the _id field on the given document, if the document does not have one.- Specified by:
generateIdIfAbsentFromDocumentin interfaceCollectibleCodec<Document>- Parameters:
document- the document for which to generate a value for the _id.- Returns:
- the document with the _id
-
encode
Deprecated.Description copied from interface:EncoderEncode an instance of the type parameterTinto a BSON value. -
decode
Deprecated.Description copied from interface:DecoderDecodes a BSON value from the given reader into an instance of the type parameterT. -
getEncoderClass
Deprecated.Description copied from interface:EncoderReturns the Class instance that this encodes. This is necessary because Java does not reify generic types.- Specified by:
getEncoderClassin interfaceEncoder<Document>- Returns:
- the Class instance that this encodes.
-