Top Description Inners Fields Constructors Methods
tools.jackson.databind.ser

public Class SerializationContextExt

extends SerializationContext
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.ser.SerializationContextExt.Impl
Imports
java.util.*, com.fasterxml.jackson.annotation.ObjectIdGenerator, tools.jackson.core.JacksonException, .JsonGenerator, .TokenStreamFactory, tools.jackson.databind.*, tools.jackson.databind.cfg.GeneratorSettings, .HandlerInstantiator, tools.jackson.databind.introspect.Annotated, .BeanPropertyDefinition, tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.node.JsonNodeFactory, .TreeBuildingGenerator, tools.jackson.databind.util.ClassUtil, .TokenBuffer

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 and Inner Type Summary

Modifier and TypeClass and Description
public static class
SerializationContextExt.Impl

Concrete implementation defined separately so it can be declared `final`.

Field Summary

Modifier and TypeField and Description
protected transient ArrayList<ObjectIdGenerator<?>>
protected transient Map<Object, WritableObjectId>
_seenObjectIds

Per-serialization map Object Ids that have seen so far, iff Object Id handling is enabled.

Inherited from tools.jackson.databind.SerializationContext:
_activeView_attributes_classIntrospector_config_dateFormat_generator_generatorConfig_knownSerializers_nullValueSerializer_serializerCache_serializerFactory_stdNullValueSerializer_streamFactory_writeCapabilitiesDEFAULT_UNKNOWN_SERIALIZER

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected Map<Object, WritableObjectId>
_createObjectIdMap()

Overridable helper method used for creating java.util.Map used for storing mappings from serializable objects to their Object Ids.

private final void
private final void
protected void
_serializeNull(JsonGenerator gen)

Helper method called when root value to serialize is null

public void
acceptJsonFormatVisitor(JavaType
The type for which to generate format
javaType
,
JsonFormatVisitorWrapper
the visitor to accept the format
visitor
)

The method to be called by ObjectMapper and ObjectWriter to expose the format of the given type to the given visitor

public WritableObjectId
findObjectId(Object forPojo, ObjectIdGenerator<?> generatorType)

Implements abstract tools.jackson.databind.SerializationContext.findObjectId.

Method called to find the Object Id for given POJO, if one has been generated.

public JsonGenerator
getGenerator()

Overrides tools.jackson.databind.SerializationContext.getGenerator.

Accessor for the JsonGenerator currently in use for serializing content.

public Object
includeFilterInstance(BeanPropertyDefinition forProperty, Class<?> filterClass)

Implements abstract tools.jackson.databind.SerializationContext.includeFilterInstance.

Method that can be called to construct and configure JsonInclude filter instance, given a Class to instantiate (with default constructor, by default).

public boolean
includeFilterSuppressNulls(Object filter)

Implements abstract tools.jackson.databind.SerializationContext.includeFilterSuppressNulls.

Follow-up method that may be called after calling includeFilterInstance, to check handling of `null` values by the filter.

public void
serializePolymorphic(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> valueSer, TypeSerializer typeSer)

Alternate serialization call used for polymorphic types, when TypeSerializer is already known, but the actual serializer may or may not be.

public ValueSerializer<Object>
serializerInstance(Annotated annotated, Object serDef)

Implements abstract tools.jackson.databind.SerializationContext.serializerInstance.

Method that can be called to construct and configure serializer instance, either given a Class to instantiate (with default constructor), or an uninitialized serializer instance.

public void
serializeValue(JsonGenerator gen, Object value)

The method to be called by ObjectMapper and ObjectWriter for serializing given value, using serializers that this provider has access to (via caching and/or creating new serializers as need be).

public void
serializeValue(JsonGenerator gen, Object value, JavaType
Type to use for locating serializer to use, instead of actual runtime type. Must be actual type, or one of its super types
rootType
)

The method to be called by ObjectMapper and ObjectWriter 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),

public void
serializeValue(JsonGenerator gen, Object value, JavaType
Type to use for locating serializer to use, instead of actual runtime type, if no serializer is passed
rootType
,
ValueSerializer<Object>
Root Serializer to use, if not null
ser
)

The method to be called by ObjectWriter for serializing given value (assumed to be of specified root type, instead of runtime type of value), when it may know specific ValueSerializer to use.

public <
Actual node type; usually either basic JsonNode or tools.jackson.databind.node.ObjectNode
T extends JsonNode
>
T

Returns:

(non-null) Root node of the resulting content tree: in case of null value node for which JsonNode#isNull() returns true.
valueToTree
(Object
Java value to convert
fromValue
)

Implements abstract tools.jackson.databind.SerializationContext.valueToTree.

Method that will convert given Java value (usually bean) into its equivalent Tree model JsonNode representation.

Inherited from tools.jackson.databind.SerializationContext:
_assignGenerator_createAndCachePropertySerializer_createAndCachePropertySerializer_createAndCacheUntypedSerializer_createAndCacheUntypedSerializer_dateFormat_handleResolvable_mappingProblem_reportIncompatibleRootTypebufferForValueConversioncanOverrideAccessModifiersclassIntrospectorconstructSpecializedTypecreateArrayNodecreateObjectNodedefaultSerializeDateKeydefaultSerializeDateKeydefaultSerializeDateValuedefaultSerializeDateValuedefaultSerializeNullValuedefaultSerializePropertyfindContentValueSerializerfindContentValueSerializerfindKeySerializerfindKeySerializerfindNullKeySerializerfindNullValueSerializerfindPrimaryPropertySerializerfindPrimaryPropertySerializerfindPropertyTypeSerializerfindRootNamefindRootNamefindRootValueSerializerfindRootValueSerializerfindTypedValueSerializerfindTypedValueSerializerfindTypeSerializerfindTypeSerializerfindValueSerializerfindValueSerializergetActiveViewgetAnnotationIntrospectorgetAttributegetCharacterEscapesgetConfiggetDatatypeFeaturesgetDefaultNullValueSerializergetDefaultPropertyFormatgetDefaultPropertyInclusiongetFilterProvidergetFormatWriteFeaturesgetLocalegetPrettyPrintergetRootValueSeparatorgetSchemagetStreamWriteFeaturesgetTimeZonegetTypeFactorygetUnknownTypeSerializerhandlePrimaryContextualizationhandleRootContextualizationhandleSecondaryContextualizationhasPrettyPrinterhasSerializationFeaturesintrospectBeanDescriptioninvalidTypeIdExceptionisEnabledisEnabledisEnabledisEnabledisUnknownTypeSerializerreportBadDefinitionreportBadDefinitionreportBadDefinitionreportBadPropertyDefinitionreportBadTypeDefinitionreportMappingProblemreportMappingProblemsetAttributetokenStreamFactorywriteTreewriteValue

Field Detail

_objectIdGeneratorsback to summary
protected transient ArrayList<ObjectIdGenerator<?>> _objectIdGenerators
_seenObjectIdsback to summary
protected transient Map<Object, WritableObjectId> _seenObjectIds

Per-serialization map Object Ids that have seen so far, iff Object Id handling is enabled.

Constructor Detail

SerializationContextExtback to summary
protected SerializationContextExt(TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f, SerializerCache cache)

Method Detail

_createObjectIdMapback to summary
protected Map<Object, WritableObjectId> _createObjectIdMap()

Overridable helper method used for creating java.util.Map used for storing mappings from serializable objects to their Object Ids.

_serializeback to summary
private final void _serialize(JsonGenerator gen, Object value, ValueSerializer<Object> ser, PropertyName rootName) throws JacksonException
_serializeback to summary
private final void _serialize(JsonGenerator gen, Object value, ValueSerializer<Object> ser) throws JacksonException
_serializeNullback to summary
protected void _serializeNull(JsonGenerator gen) throws JacksonException

Helper method called when root value to serialize is null

acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JavaType javaType, JsonFormatVisitorWrapper visitor)

The method to be called by ObjectMapper and ObjectWriter to expose the format of the given type to the given visitor

Parameters
javaType:JavaType

The type for which to generate format

visitor:JsonFormatVisitorWrapper

the visitor to accept the format

findObjectIdback to summary
public WritableObjectId findObjectId(Object forPojo, ObjectIdGenerator<?> generatorType)

Implements abstract tools.jackson.databind.SerializationContext.findObjectId.

Doc from tools.jackson.databind.SerializationContext.findObjectId.

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.

Annotations
@Override
getGeneratorback to summary
public JsonGenerator getGenerator()

Overrides tools.jackson.databind.SerializationContext.getGenerator.

Accessor for the JsonGenerator currently in use for serializing content. Null for blueprint instances; non-null for actual active provider instances.

Annotations
@Override
includeFilterInstanceback to summary
public Object includeFilterInstance(BeanPropertyDefinition forProperty, Class<?> filterClass)

Implements abstract tools.jackson.databind.SerializationContext.includeFilterInstance.

Doc from tools.jackson.databind.SerializationContext.includeFilterInstance.

Method that can be called to construct and configure JsonInclude filter instance, given a Class to instantiate (with default constructor, by default).

Annotations
@Override
includeFilterSuppressNullsback to summary
public boolean includeFilterSuppressNulls(Object filter)

Implements abstract tools.jackson.databind.SerializationContext.includeFilterSuppressNulls.

Doc from tools.jackson.databind.SerializationContext.includeFilterSuppressNulls.

Follow-up method that may be called after calling includeFilterInstance, to check handling of `null` values by the filter.

Annotations
@Override
serializePolymorphicback to summary
public void serializePolymorphic(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> valueSer, TypeSerializer typeSer) throws JacksonException

Alternate serialization call used for polymorphic types, when TypeSerializer is already known, but the actual serializer may or may not be.

serializerInstanceback to summary
public ValueSerializer<Object> serializerInstance(Annotated annotated, Object serDef)

Implements abstract tools.jackson.databind.SerializationContext.serializerInstance.

Doc from tools.jackson.databind.SerializationContext.serializerInstance.

Method that can be called to construct and configure serializer instance, either given a Class to instantiate (with default constructor), or an uninitialized serializer instance. Either way, serializer will be properly resolved (via tools.jackson.databind.ValueSerializer#resolve).

Annotations
@Override
serializeValueback to summary
public void serializeValue(JsonGenerator gen, Object value) throws JacksonException

The method to be called by ObjectMapper and ObjectWriter for serializing given value, using serializers that this provider has access to (via caching and/or creating new serializers as need be).

serializeValueback to summary
public void serializeValue(JsonGenerator gen, Object value, JavaType rootType) throws JacksonException

The method to be called by ObjectMapper and ObjectWriter 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:JavaType

Type to use for locating serializer to use, instead of actual runtime type. Must be actual type, or one of its super types

serializeValueback to summary
public void serializeValue(JsonGenerator gen, Object value, JavaType rootType, ValueSerializer<Object> ser) throws JacksonException

The method to be called by ObjectWriter for serializing given value (assumed to be of specified root type, instead of runtime type of value), when it may know specific ValueSerializer to use.

Parameters
rootType:JavaType

Type to use for locating serializer to use, instead of actual runtime type, if no serializer is passed

ser:ValueSerializer<Object>

Root Serializer to use, if not null

valueToTreeback to summary
public <T extends JsonNode> T valueToTree(Object fromValue) throws JacksonException

Implements abstract tools.jackson.databind.SerializationContext.valueToTree.

Method that will convert given Java value (usually bean) into its equivalent Tree model JsonNode representation. Functionally similar to serializing value into token stream and parsing that stream back as tree model node, but more efficient as TokenBuffer 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 (tools.jackson.databind.util.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.

Parameters
<T>
Actual node type; usually either basic JsonNode or tools.jackson.databind.node.ObjectNode
fromValue:Object

Java value to convert

Returns:T

(non-null) Root node of the resulting content tree: in case of null value node for which JsonNode#isNull() returns true.

Annotations
@Override
@SuppressWarnings:unchecked
Since
3.0
tools.jackson.databind.ser back to summary

public final Class SerializationContextExt.Impl

extends SerializationContextExt
Class Inheritance

Concrete implementation defined separately so it can be declared `final`. Alternate implements should instead just extend SerializationContextExt

Field Summary

Inherited from tools.jackson.databind.ser.SerializationContextExt:
_objectIdGenerators_seenObjectIds

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from tools.jackson.databind.ser.SerializationContextExt:
_createObjectIdMap_serializeNullacceptJsonFormatVisitorfindObjectIdgetGeneratorincludeFilterInstanceincludeFilterSuppressNullsserializePolymorphicserializerInstanceserializeValueserializeValueserializeValuevalueToTree

Constructor Detail

Implback to summary
public Impl(TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f, SerializerCache cache)