Package org.bson.codecs
Class MapCodec
- java.lang.Object
 - 
- org.bson.codecs.MapCodec
 
 
- 
- All Implemented Interfaces:
 Codec<java.util.Map<java.lang.String,java.lang.Object>>,Decoder<java.util.Map<java.lang.String,java.lang.Object>>,Encoder<java.util.Map<java.lang.String,java.lang.Object>>,OverridableUuidRepresentationCodec<java.util.Map<java.lang.String,java.lang.Object>>
public class MapCodec extends java.lang.Object implements Codec<java.util.Map<java.lang.String,java.lang.Object>>, OverridableUuidRepresentationCodec<java.util.Map<java.lang.String,java.lang.Object>>
A Codec for Map instances.- Since:
 - 3.5
 
 
- 
- 
Constructor Summary
Constructors Constructor Description MapCodec()Construct a new instance with a defaultCodecRegistryMapCodec(CodecRegistry registry)Construct a new instance with the given registryMapCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap)Construct a new instance with the given registry and BSON type class map.MapCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer)Construct a new instance with the given registry and BSON type class map. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>decode(BsonReader reader, DecoderContext decoderContext)Decodes a BSON value from the given reader into an instance of the type parameterT.voidencode(BsonWriter writer, java.util.Map<java.lang.String,java.lang.Object> map, EncoderContext encoderContext)Encode an instance of the type parameterTinto a BSON value.java.lang.Class<java.util.Map<java.lang.String,java.lang.Object>>getEncoderClass()Returns the Class instance that this encodes.Codec<java.util.Map<java.lang.String,java.lang.Object>>withUuidRepresentation(UuidRepresentation uuidRepresentation)Implementations must return a new instance with theUuidRepresentationoverridden with the given value. 
 - 
 
- 
- 
Constructor Detail
- 
MapCodec
public MapCodec()
Construct a new instance with a defaultCodecRegistry 
- 
MapCodec
public MapCodec(CodecRegistry registry)
Construct a new instance with the given registry- Parameters:
 registry- the registry
 
- 
MapCodec
public MapCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap)
Construct a new instance with the given registry and BSON type class map.- Parameters:
 registry- the registrybsonTypeClassMap- the BSON type class map
 
- 
MapCodec
public MapCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer)
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 map
 
 - 
 
- 
Method Detail
- 
withUuidRepresentation
public Codec<java.util.Map<java.lang.String,java.lang.Object>> withUuidRepresentation(UuidRepresentation uuidRepresentation)
Description copied from interface:OverridableUuidRepresentationCodecImplementations must return a new instance with theUuidRepresentationoverridden with the given value.- Specified by:
 withUuidRepresentationin interfaceOverridableUuidRepresentationCodec<java.util.Map<java.lang.String,java.lang.Object>>- Parameters:
 uuidRepresentation- the UuidRepresentation- Returns:
 - a new instance equivalent to this but with the given UuidRepresentation
 
 
- 
encode
public void encode(BsonWriter writer, java.util.Map<java.lang.String,java.lang.Object> map, EncoderContext encoderContext)
Description copied from interface:EncoderEncode an instance of the type parameterTinto a BSON value. 
- 
decode
public java.util.Map<java.lang.String,java.lang.Object> decode(BsonReader reader, DecoderContext decoderContext)
Description copied from interface:DecoderDecodes a BSON value from the given reader into an instance of the type parameterT. 
- 
getEncoderClass
public java.lang.Class<java.util.Map<java.lang.String,java.lang.Object>> getEncoderClass()
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<java.util.Map<java.lang.String,java.lang.Object>>- Returns:
 - the Class instance that this encodes.
 
 
 - 
 
 -