Class ParameterBindingDocumentCodec
java.lang.Object
org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec
- All Implemented Interfaces:
org.bson.codecs.Codec<org.bson.Document>
,org.bson.codecs.CollectibleCodec<org.bson.Document>
,org.bson.codecs.Decoder<org.bson.Document>
,org.bson.codecs.Encoder<org.bson.Document>
public class ParameterBindingDocumentCodec
extends Object
implements org.bson.codecs.CollectibleCodec<org.bson.Document>
A
Modified version of MongoDB Inc. DocumentCodec licensed under the Apache License, Version 2.0.
Codec
implementation that allows binding parameters to placeholders or SpEL expressions when decoding a
JSON String. Modified version of MongoDB Inc. DocumentCodec licensed under the Apache License, Version 2.0.
- Since:
- 2.2
- Author:
- Jeff Yemin, Ross Lawley, Ralph Schaer, Christoph Strobl
-
Constructor Summary
ConstructorDescriptionConstruct a new instance with a defaultCodecRegistry
.ParameterBindingDocumentCodec
(org.bson.codecs.configuration.CodecRegistry registry) Construct a new instance with the given registry.ParameterBindingDocumentCodec
(org.bson.codecs.configuration.CodecRegistry registry, org.bson.codecs.BsonTypeClassMap bsonTypeClassMap) Construct a new instance with the given registry and BSON type class map.ParameterBindingDocumentCodec
(org.bson.codecs.configuration.CodecRegistry registry, org.bson.codecs.BsonTypeClassMap bsonTypeClassMap, org.bson.Transformer valueTransformer) Construct a new instance with the given registry and BSON type class map. -
Method Summary
Modifier and TypeMethodDescriptioncaptureExpressionDependencies
(String json, ValueProvider valueProvider, ExpressionParser expressionParser) DetermineExpressionDependencies
from Expressions that are nested in thejson
content.org.bson.Document
org.bson.Document
decode
(String json, ParameterBindingContext bindingContext) org.bson.Document
decode
(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext) boolean
documentHasId
(org.bson.Document document) void
encode
(org.bson.BsonWriter writer, org.bson.Document document, org.bson.codecs.EncoderContext encoderContext) org.bson.Document
generateIdIfAbsentFromDocument
(org.bson.Document document) org.bson.BsonValue
getDocumentId
(org.bson.Document document) Class<org.bson.Document>
-
Constructor Details
-
ParameterBindingDocumentCodec
public ParameterBindingDocumentCodec()Construct a new instance with a defaultCodecRegistry
. -
ParameterBindingDocumentCodec
public ParameterBindingDocumentCodec(org.bson.codecs.configuration.CodecRegistry registry) Construct a new instance with the given registry.- Parameters:
registry
- the registry
-
ParameterBindingDocumentCodec
public ParameterBindingDocumentCodec(org.bson.codecs.configuration.CodecRegistry registry, org.bson.codecs.BsonTypeClassMap bsonTypeClassMap) Construct a new instance with the given registry and BSON type class map.- Parameters:
registry
- the registrybsonTypeClassMap
- the BSON type class map
-
ParameterBindingDocumentCodec
public ParameterBindingDocumentCodec(org.bson.codecs.configuration.CodecRegistry registry, org.bson.codecs.BsonTypeClassMap bsonTypeClassMap, org.bson.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 document
-
-
Method Details
-
documentHasId
public boolean documentHasId(org.bson.Document document) - Specified by:
documentHasId
in interfaceorg.bson.codecs.CollectibleCodec<org.bson.Document>
-
getDocumentId
public org.bson.BsonValue getDocumentId(org.bson.Document document) - Specified by:
getDocumentId
in interfaceorg.bson.codecs.CollectibleCodec<org.bson.Document>
-
generateIdIfAbsentFromDocument
public org.bson.Document generateIdIfAbsentFromDocument(org.bson.Document document) - Specified by:
generateIdIfAbsentFromDocument
in interfaceorg.bson.codecs.CollectibleCodec<org.bson.Document>
-
encode
public void encode(org.bson.BsonWriter writer, org.bson.Document document, org.bson.codecs.EncoderContext encoderContext) - Specified by:
encode
in interfaceorg.bson.codecs.Encoder<org.bson.Document>
-
decode
-
decode
-
captureExpressionDependencies
public ExpressionDependencies captureExpressionDependencies(@Nullable String json, ValueProvider valueProvider, ExpressionParser expressionParser) DetermineExpressionDependencies
from Expressions that are nested in thejson
content. ReturnsOptional.empty()
ifjson
is empty or of it does not contain any SpEL expressions.- Parameters:
json
-expressionParser
-- Returns:
- merged
ExpressionDependencies
object if expressions were found, otherwiseExpressionDependencies.none()
. - Since:
- 3.1
-
decode
public org.bson.Document decode(org.bson.BsonReader reader, org.bson.codecs.DecoderContext decoderContext) - Specified by:
decode
in interfaceorg.bson.codecs.Decoder<org.bson.Document>
-
getEncoderClass
- Specified by:
getEncoderClass
in interfaceorg.bson.codecs.Encoder<org.bson.Document>
-