java.lang.Object
tools.jackson.databind.DatabindContext
tools.jackson.databind.SerializationContext
tools.jackson.databind.ser.SerializationContextExt
- All Implemented Interfaces:
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 classConcrete implementation defined separately so it can be declared `final`.Nested classes/interfaces inherited from interface tools.jackson.core.ObjectWriteContext
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
ConstructorsModifierConstructorDescriptionprotectedSerializationContextExt(TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f, SerializerCache cache) -
Method Summary
Modifier and TypeMethodDescriptionprotected Map<Object,WritableObjectId> Overridable helper method used for creatingMapused for storing mappings from serializable objects to their Object Ids.protected voidHelper method called when root value to serialize is nullvoidacceptJsonFormatVisitor(JavaType javaType, JsonFormatVisitorWrapper visitor) The method to be called byObjectMapperandObjectWriterto 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.Accessor for theJsonGeneratorcurrently in use for serializing content.includeFilterInstance(BeanPropertyDefinition forProperty, Class<?> filterClass) Method that can be called to construct and configureJsonIncludefilter instance, given aClassto instantiate (with default constructor, by default).booleanincludeFilterSuppressNulls(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.voidserializePolymorphic(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> valueSer, TypeSerializer typeSer) Alternate serialization call used for polymorphic types, whenTypeSerializeris 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 aClassto instantiate (with default constructor), or an uninitialized serializer instance.voidserializeValue(JsonGenerator gen, Object value) The method to be called byObjectMapperandObjectWriterfor serializing given value, using serializers that this provider has access to (via caching and/or creating new serializers as need be).voidserializeValue(JsonGenerator gen, Object value, JavaType rootType) The method to be called byObjectMapperandObjectWriterfor 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),voidserializeValue(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> ser) The method to be called byObjectWriterfor serializing given value (assumed to be of specified root type, instead of runtime type of value), when it may know specificValueSerializerto use.<T extends JsonNode>
TvalueToTree(Object fromValue) Method that will convert given Java value (usually bean) into its equivalent Tree modelJsonNoderepresentation.Methods inherited from class tools.jackson.databind.SerializationContext
_assignGenerator, _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, writeValueMethods inherited from class tools.jackson.databind.DatabindContext
_colonConcat, _desc, _format, _quotedString, _throwNotASubtype, _throwSubtypeClassNotAllowed, _throwSubtypeNameNotAllowed, _truncate, constructType, converterInstance, introspectBeanDescription, introspectClassAnnotations, introspectClassAnnotations, introspectDirectClassAnnotations, isAnnotationProcessingEnabled, lazyIntrospectBeanDescription, objectIdGeneratorInstance, objectIdResolverInstance, reportBadDefinition, reportBadTypeDefinition, resolveAndValidateSubType, resolveSubTypeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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(TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f, SerializerCache cache)
-
-
Method Details
-
serializerInstance
Description copied from class:SerializationContextMethod that can be called to construct and configure serializer instance, either given aClassto instantiate (with default constructor), or an uninitialized serializer instance. Either way, serializer will be properly resolved (viaValueSerializer.resolve(tools.jackson.databind.SerializationContext)).- Specified by:
serializerInstancein classSerializationContext- Parameters:
annotated- Annotated entity that contained definitionserDef- Serializer definition: either an instance or class
-
includeFilterInstance
Description copied from class:SerializationContextMethod that can be called to construct and configureJsonIncludefilter instance, given aClassto instantiate (with default constructor, by default).- Specified by:
includeFilterInstancein 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:SerializationContextFollow-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:
includeFilterSuppressNullsin classSerializationContext
-
valueToTree
Method that will convert given Java value (usually bean) into its equivalent Tree modelJsonNoderepresentation. Functionally similar to serializing value into token stream and parsing that stream back as tree model node, but more efficient asTokenBufferis 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:
valueToTreein classSerializationContext- Type Parameters:
T- Actual node type; usually either basicJsonNodeorObjectNode- Parameters:
fromValue- Java value to convert- Returns:
- (non-null) Root node of the resulting content tree: in case of
nullvalue node for whichJsonNode.isNull()returnstrue. - Throws:
JacksonException- Since:
- 3.0
-
findObjectId
Description copied from class:SerializationContextMethod 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:
findObjectIdin classSerializationContext
-
_createObjectIdMap
Overridable helper method used for creatingMapused for storing mappings from serializable objects to their Object Ids. -
getGenerator
Accessor for theJsonGeneratorcurrently in use for serializing content. Null for blueprint instances; non-null for actual active provider instances.- Overrides:
getGeneratorin classSerializationContext
-
serializeValue
The method to be called byObjectMapperandObjectWriterfor serializing given value, using serializers that this provider has access to (via caching and/or creating new serializers as need be).- Throws:
JacksonException
-
serializeValue
public void serializeValue(JsonGenerator gen, Object value, JavaType rootType) throws JacksonException The method to be called byObjectMapperandObjectWriterfor 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:
JacksonException
-
serializeValue
public void serializeValue(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> ser) throws JacksonException The method to be called byObjectWriterfor serializing given value (assumed to be of specified root type, instead of runtime type of value), when it may know specificValueSerializerto 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:
JacksonException
-
serializePolymorphic
public void serializePolymorphic(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> valueSer, TypeSerializer typeSer) throws JacksonException Alternate serialization call used for polymorphic types, whenTypeSerializeris already known, but the actual serializer may or may not be.- Throws:
JacksonException
-
_serializeNull
Helper method called when root value to serialize is null- Throws:
JacksonException
-
acceptJsonFormatVisitor
The method to be called byObjectMapperandObjectWriterto 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
-