Package com.mongodb
Class DBObjectCodec
- java.lang.Object
-
- com.mongodb.DBObjectCodec
-
- All Implemented Interfaces:
Codec<DBObject>
,CollectibleCodec<DBObject>
,Decoder<DBObject>
,Encoder<DBObject>
,OverridableUuidRepresentationCodec<DBObject>
public class DBObjectCodec extends Object implements CollectibleCodec<DBObject>, OverridableUuidRepresentationCodec<DBObject>
A collectible codec for a DBObject.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description DBObjectCodec()
Construct an instance with the default codec registryDBObjectCodec(CodecRegistry codecRegistry)
Construct an instance with the given codec registry.DBObjectCodec(CodecRegistry codecRegistry, BsonTypeClassMap bsonTypeClassMap)
Construct an instance.DBObjectCodec(CodecRegistry codecRegistry, BsonTypeClassMap bsonTypeClassMap, com.mongodb.DBObjectFactory objectFactory)
Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DBObject
decode(BsonReader reader, DecoderContext decoderContext)
boolean
documentHasId(DBObject document)
void
encode(BsonWriter writer, DBObject document, EncoderContext encoderContext)
DBObject
generateIdIfAbsentFromDocument(DBObject document)
BsonValue
getDocumentId(DBObject document)
Class<DBObject>
getEncoderClass()
Codec<DBObject>
withUuidRepresentation(UuidRepresentation uuidRepresentation)
-
-
-
Constructor Detail
-
DBObjectCodec
public DBObjectCodec()
Construct an instance with the default codec registry- Since:
- 3.7
-
DBObjectCodec
public DBObjectCodec(CodecRegistry codecRegistry)
Construct an instance with the given codec registry.- Parameters:
codecRegistry
- the non-null codec registry
-
DBObjectCodec
public DBObjectCodec(CodecRegistry codecRegistry, BsonTypeClassMap bsonTypeClassMap)
Construct an instance.- Parameters:
codecRegistry
- the codec registrybsonTypeClassMap
- the non-null BsonTypeClassMap
-
DBObjectCodec
public DBObjectCodec(CodecRegistry codecRegistry, BsonTypeClassMap bsonTypeClassMap, com.mongodb.DBObjectFactory objectFactory)
Construct an instance.- Parameters:
codecRegistry
- the non-null codec registrybsonTypeClassMap
- the non-null BsonTypeClassMapobjectFactory
- the non-null object factory used to create empty DBObject instances when decoding
-
-
Method Detail
-
encode
public void encode(BsonWriter writer, DBObject document, EncoderContext encoderContext)
-
decode
public DBObject decode(BsonReader reader, DecoderContext decoderContext)
-
getEncoderClass
public Class<DBObject> getEncoderClass()
- Specified by:
getEncoderClass
in interfaceEncoder<DBObject>
-
documentHasId
public boolean documentHasId(DBObject document)
- Specified by:
documentHasId
in interfaceCollectibleCodec<DBObject>
-
getDocumentId
public BsonValue getDocumentId(DBObject document)
- Specified by:
getDocumentId
in interfaceCollectibleCodec<DBObject>
-
generateIdIfAbsentFromDocument
public DBObject generateIdIfAbsentFromDocument(DBObject document)
- Specified by:
generateIdIfAbsentFromDocument
in interfaceCollectibleCodec<DBObject>
-
withUuidRepresentation
public Codec<DBObject> withUuidRepresentation(UuidRepresentation uuidRepresentation)
- Specified by:
withUuidRepresentation
in interfaceOverridableUuidRepresentationCodec<DBObject>
-
-