java.lang.Object
tools.jackson.databind.DatabindContext
tools.jackson.databind.SerializationContext
tools.jackson.databind.ser.SerializationContextExt
- All Implemented Interfaces:
tools.jackson.core.ObjectWriteContext
- Direct Known Subclasses:
SerializationContextExt.Impl
Extension over
SerializationContext
that adds methods needed by
ObjectMapper
(and ObjectWriter
) but that are not to be exposed
as general context during serialization.
Also note that all custom SerializationContext
implementations must sub-class this class: ObjectMapper
requires this type, not basic provider type.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Concrete implementation defined separately so it can be declared `final`.Nested classes/interfaces inherited from interface tools.jackson.core.ObjectWriteContext
tools.jackson.core.ObjectWriteContext.Base
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayList<ObjectIdGenerator<?>>
protected Map<Object,
WritableObjectId> Per-serialization map Object Ids that have seen so far, iff Object Id handling is enabled.Fields inherited from class tools.jackson.databind.SerializationContext
_activeView, _attributes, _classIntrospector, _config, _dateFormat, _generator, _generatorConfig, _knownSerializers, _nullValueSerializer, _serializerCache, _serializerFactory, _stdNullValueSerializer, _streamFactory, _writeCapabilities, DEFAULT_UNKNOWN_SERIALIZER
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SerializationContextExt
(tools.jackson.core.TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f, SerializerCache cache) -
Method Summary
Modifier and TypeMethodDescriptionprotected Map<Object,
WritableObjectId> Overridable helper method used for creatingMap
used for storing mappings from serializable objects to their Object Ids.protected void
_serializeNull
(tools.jackson.core.JsonGenerator gen) Helper method called when root value to serialize is nullvoid
acceptJsonFormatVisitor
(JavaType javaType, JsonFormatVisitorWrapper visitor) The method to be called byObjectMapper
andObjectWriter
to expose the format of the given type to the given visitorfindObjectId
(Object forPojo, ObjectIdGenerator<?> generatorType) Method called to find the Object Id for given POJO, if one has been generated.tools.jackson.core.JsonGenerator
Accessor for theJsonGenerator
currently in use for serializing content.includeFilterInstance
(BeanPropertyDefinition forProperty, Class<?> filterClass) Method that can be called to construct and configureJsonInclude
filter instance, given aClass
to instantiate (with default constructor, by default).boolean
includeFilterSuppressNulls
(Object filter) Follow-up method that may be called after callingSerializationContext.includeFilterInstance(tools.jackson.databind.introspect.BeanPropertyDefinition, java.lang.Class<?>)
, to check handling of `null` values by the filter.void
serializePolymorphic
(tools.jackson.core.JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> valueSer, TypeSerializer typeSer) Alternate serialization call used for polymorphic types, whenTypeSerializer
is already known, but the actual serializer may or may not be.serializerInstance
(Annotated annotated, Object serDef) Method that can be called to construct and configure serializer instance, either given aClass
to instantiate (with default constructor), or an uninitialized serializer instance.void
serializeValue
(tools.jackson.core.JsonGenerator gen, Object value) The method to be called byObjectMapper
andObjectWriter
for serializing given value, using serializers that this provider has access to (via caching and/or creating new serializers as need be).void
serializeValue
(tools.jackson.core.JsonGenerator gen, Object value, JavaType rootType) The method to be called byObjectMapper
andObjectWriter
for serializing given value (assumed to be of specified root type, instead of runtime type of value), using serializers that this provider has access to (via caching and/or creating new serializers as need be),void
serializeValue
(tools.jackson.core.JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> ser) The method to be called byObjectWriter
for serializing given value (assumed to be of specified root type, instead of runtime type of value), when it may know specificValueSerializer
to use.<T extends JsonNode>
TvalueToTree
(Object fromValue) Method that will convert given Java value (usually bean) into its equivalent Tree modelJsonNode
representation.Methods inherited from class tools.jackson.databind.SerializationContext
_createAndCachePropertySerializer, _createAndCachePropertySerializer, _createAndCacheUntypedSerializer, _createAndCacheUntypedSerializer, _dateFormat, _handleResolvable, _mappingProblem, _reportIncompatibleRootType, bufferForValueConversion, canOverrideAccessModifiers, classIntrospector, constructSpecializedType, createArrayNode, createObjectNode, defaultSerializeDateKey, defaultSerializeDateKey, defaultSerializeDateValue, defaultSerializeDateValue, defaultSerializeNullValue, defaultSerializeProperty, findContentValueSerializer, findContentValueSerializer, findKeySerializer, findKeySerializer, findNullKeySerializer, findNullValueSerializer, findPrimaryPropertySerializer, findPrimaryPropertySerializer, findPropertyTypeSerializer, findRootName, findRootName, findRootValueSerializer, findRootValueSerializer, findTypedValueSerializer, findTypedValueSerializer, findTypeSerializer, findTypeSerializer, findValueSerializer, findValueSerializer, getActiveView, getAnnotationIntrospector, getAttribute, getCharacterEscapes, getConfig, getDatatypeFeatures, getDefaultNullValueSerializer, getDefaultPropertyFormat, getDefaultPropertyInclusion, getFilterProvider, getFormatWriteFeatures, getLocale, getPrettyPrinter, getRootValueSeparator, getSchema, getStreamWriteFeatures, getTimeZone, getTypeFactory, getUnknownTypeSerializer, handlePrimaryContextualization, handleRootContextualization, handleSecondaryContextualization, hasPrettyPrinter, hasSerializationFeatures, introspectBeanDescription, invalidTypeIdException, isEnabled, isEnabled, isEnabled, isEnabled, isUnknownTypeSerializer, reportBadDefinition, reportBadDefinition, reportBadDefinition, reportBadPropertyDefinition, reportBadTypeDefinition, reportMappingProblem, reportMappingProblem, setAttribute, tokenStreamFactory, writeTree, writeValue
Methods inherited from class tools.jackson.databind.DatabindContext
_colonConcat, _desc, _format, _quotedString, _throwNotASubtype, _throwSubtypeClassNotAllowed, _throwSubtypeNameNotAllowed, _truncate, constructType, converterInstance, introspectClassAnnotations, introspectClassAnnotations, introspectDirectClassAnnotations, isAnnotationProcessingEnabled, objectIdGeneratorInstance, objectIdResolverInstance, reportBadDefinition, resolveAndValidateSubType, resolveSubType
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface tools.jackson.core.ObjectWriteContext
createGenerator, createGenerator, createGenerator
-
Field Details
-
_seenObjectIds
Per-serialization map Object Ids that have seen so far, iff Object Id handling is enabled. -
_objectIdGenerators
-
-
Constructor Details
-
SerializationContextExt
protected SerializationContextExt(tools.jackson.core.TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f, SerializerCache cache)
-
-
Method Details
-
serializerInstance
Description copied from class:SerializationContext
Method that can be called to construct and configure serializer instance, either given aClass
to instantiate (with default constructor), or an uninitialized serializer instance. Either way, serializer will be properly resolved (viaValueSerializer.resolve(tools.jackson.databind.SerializationContext)
).- Specified by:
serializerInstance
in classSerializationContext
- Parameters:
annotated
- Annotated entity that contained definitionserDef
- Serializer definition: either an instance or class
-
includeFilterInstance
Description copied from class:SerializationContext
Method that can be called to construct and configureJsonInclude
filter instance, given aClass
to instantiate (with default constructor, by default).- Specified by:
includeFilterInstance
in classSerializationContext
- Parameters:
forProperty
- (optional) If filter is created for a property, that property; `null` if filter created via defaulting, global or per-type.
-
includeFilterSuppressNulls
Description copied from class:SerializationContext
Follow-up method that may be called after callingSerializationContext.includeFilterInstance(tools.jackson.databind.introspect.BeanPropertyDefinition, java.lang.Class<?>)
, to check handling of `null` values by the filter.- Specified by:
includeFilterSuppressNulls
in classSerializationContext
-
valueToTree
public <T extends JsonNode> T valueToTree(Object fromValue) throws tools.jackson.core.JacksonException Method that will convert given Java value (usually bean) into its equivalent Tree modelJsonNode
representation. Functionally similar to serializing value into token stream and parsing that stream back as tree model node, but more efficient asTokenBuffer
is used to contain the intermediate representation instead of fully serialized contents.NOTE: while results are usually identical to that of serialization followed by deserialization, this is not always the case. In some cases serialization into intermediate representation will retain encapsulation of things like raw value (
RawValue
) or basic node identity (JsonNode
). If so, result is a valid tree, but values are not re-constructed through actual format representation. So if transformation requires actual materialization of encoded content, it will be necessary to do actual serialization.- Specified by:
valueToTree
in classSerializationContext
- Type Parameters:
T
- Actual node type; usually either basicJsonNode
orObjectNode
- Parameters:
fromValue
- Java value to convert- Returns:
- (non-null) Root node of the resulting content tree: in case of
null
value node for whichJsonNode.isNull()
returnstrue
. - Throws:
tools.jackson.core.JacksonException
- Since:
- 3.0
-
findObjectId
Description copied from class:SerializationContext
Method called to find the Object Id for given POJO, if one has been generated. Will always return a non-null Object; contents vary depending on whether an Object Id already exists or not.- Specified by:
findObjectId
in classSerializationContext
-
_createObjectIdMap
Overridable helper method used for creatingMap
used for storing mappings from serializable objects to their Object Ids. -
getGenerator
public tools.jackson.core.JsonGenerator getGenerator()Accessor for theJsonGenerator
currently in use for serializing content. Null for blueprint instances; non-null for actual active provider instances.- Overrides:
getGenerator
in classSerializationContext
-
serializeValue
public void serializeValue(tools.jackson.core.JsonGenerator gen, Object value) throws tools.jackson.core.JacksonException The method to be called byObjectMapper
andObjectWriter
for serializing given value, using serializers that this provider has access to (via caching and/or creating new serializers as need be).- Throws:
tools.jackson.core.JacksonException
-
serializeValue
public void serializeValue(tools.jackson.core.JsonGenerator gen, Object value, JavaType rootType) throws tools.jackson.core.JacksonException The method to be called byObjectMapper
andObjectWriter
for serializing given value (assumed to be of specified root type, instead of runtime type of value), using serializers that this provider has access to (via caching and/or creating new serializers as need be),- Parameters:
rootType
- Type to use for locating serializer to use, instead of actual runtime type. Must be actual type, or one of its super types- Throws:
tools.jackson.core.JacksonException
-
serializeValue
public void serializeValue(tools.jackson.core.JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> ser) throws tools.jackson.core.JacksonException The method to be called byObjectWriter
for serializing given value (assumed to be of specified root type, instead of runtime type of value), when it may know specificValueSerializer
to use.- Parameters:
rootType
- Type to use for locating serializer to use, instead of actual runtime type, if no serializer is passedser
- Root Serializer to use, if not null- Throws:
tools.jackson.core.JacksonException
-
serializePolymorphic
public void serializePolymorphic(tools.jackson.core.JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> valueSer, TypeSerializer typeSer) throws tools.jackson.core.JacksonException Alternate serialization call used for polymorphic types, whenTypeSerializer
is already known, but the actual serializer may or may not be.- Throws:
tools.jackson.core.JacksonException
-
_serializeNull
protected void _serializeNull(tools.jackson.core.JsonGenerator gen) throws tools.jackson.core.JacksonException Helper method called when root value to serialize is null- Throws:
tools.jackson.core.JacksonException
-
acceptJsonFormatVisitor
The method to be called byObjectMapper
andObjectWriter
to expose the format of the given type to the given visitor- Parameters:
javaType
- The type for which to generate formatvisitor
- the visitor to accept the format
-