Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.databind.ser

public abstract Class DefaultSerializerProvider

extends SerializerProvider
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.Impl
Imports
java.io.IOException, java.util.*, java.util.concurrent.atomic.AtomicReference, com.fasterxml.jackson.annotation.ObjectIdGenerator, com.fasterxml.jackson.core.JsonGenerator, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.cfg.CacheProvider, .HandlerInstantiator, com.fasterxml.jackson.databind.introspect.Annotated, .BeanPropertyDefinition, com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.node.ObjectNode, com.fasterxml.jackson.databind.ser.impl.WritableObjectId, com.fasterxml.jackson.databind.util.ClassUtil

Standard implementation used by ObjectMapper: adds methods only exposed to ObjectMapper, as well as constructors.

Note that class is abstract just because it does not define createInstance method.

Also note that all custom SerializerProvider 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
DefaultSerializerProvider.Impl

Concrete implementation that defines factory method(s), defined as final.

Field Summary

Modifier and TypeField and Description
protected transient JsonGenerator
_generator

Generator used for serialization.

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.

private static final long
Inherited from com.fasterxml.jackson.databind.SerializerProvider:
_attributes_config_dateFormat_keySerializer_knownSerializers_nullKeySerializer_nullValueSerializer_serializationView_serializerCache_serializerFactory_stdNullValueSerializer_unknownTypeSerializerCACHE_UNKNOWN_MAPPINGSDEFAULT_NULL_KEY_SERIALIZERDEFAULT_UNKNOWN_SERIALIZER

Constructor Summary

AccessConstructor and Description
protected
protected
protected
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

private IOException
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 to expose the format of the given to to the given visitor

public int
cachedSerializersCount()

Method that can be used to determine how many serializers this provider is caching currently (if it does caching: default implementation does) Exact count depends on what kind of serializers get cached; default implementation caches all serializers, including ones that are eagerly constructed (for optimal access speed)

The main use case for this method is to allow conditional flushing of serializer cache, if certain number of entries is reached.

public DefaultSerializerProvider
copy()

Method needed to ensure that ObjectMapper#copy will work properly; specifically, that caches are cleared, but settings will otherwise remain identical; and that no sharing of state occurs.

public abstract DefaultSerializerProvider
createInstance(SerializationConfig config, SerializerFactory jsf)

Method that sub-classes need to implement: used to create a non-blueprint instances from the blueprint.

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

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.findObjectId.

Method called to find the Object Id for given POJO, if one has been generated.
public void
flushCachedSerializers()

Method that will drop all serializers currently cached by this provider.

public JsonSchema
generateJsonSchema(Class<?>
The type for which to generate schema
type
)

Deprecated Should not be used any more
The method to be called by ObjectMapper to generate JSON schema for given type.
public JsonGenerator
getGenerator()

Overrides com.fasterxml.jackson.databind.SerializerProvider.getGenerator.

Accessor for the JsonGenerator currently in use for serializing content.
public boolean
hasSerializerFor(Class<?> cls, AtomicReference<Throwable> cause)

Method that can be called to see if this serializer provider can find a serializer for an instance of given class.

public Object
includeFilterInstance(BeanPropertyDefinition
(optional) If filter is created for a property, that property; `null` if filter created via defaulting, global or per-type.
forProperty
,
Class<?> filterClass)

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.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 com.fasterxml.jackson.databind.SerializerProvider.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, JsonSerializer<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 JsonSerializer<Object>
serializerInstance(Annotated
Annotated entity that contained definition
annotated
,
Object
Serializer definition: either an instance or class
serDef
)

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.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
,
JsonSerializer<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 JsonSerializer to use.

public abstract DefaultSerializerProvider
withCaches(CacheProvider cacheProvider)

Fluent factory method used for constructing a new instance with cache instances provided by CacheProvider.

Inherited from com.fasterxml.jackson.databind.SerializerProvider:
_createAndCacheUntypedSerializer_createAndCacheUntypedSerializer_createUntypedSerializer_dateFormat_findExplicitUntypedSerializer_handleContextualResolvable_handleResolvable_reportIncompatibleRootTypebufferForValueConversionbufferForValueConversioncanOverrideAccessModifiersconstructSpecializedTypedefaultSerializeDateKeydefaultSerializeDateKeydefaultSerializeDateValuedefaultSerializeDateValuedefaultSerializeFielddefaultSerializeNulldefaultSerializeValuefindContentValueSerializerfindContentValueSerializerfindKeySerializerfindKeySerializerfindNullKeySerializerfindNullValueSerializerfindPrimaryPropertySerializerfindPrimaryPropertySerializerfindTypedValueSerializerfindTypedValueSerializerfindTypeSerializerfindValueSerializerfindValueSerializerfindValueSerializerfindValueSerializergetActiveViewgetAnnotationIntrospectorgetAttributegetConfiggetDatatypeFeaturesgetDefaultNullKeySerializergetDefaultNullValueSerializergetDefaultPropertyFormatgetDefaultPropertyInclusiongetFilterProvidergetLocalegetTimeZonegetTypeFactorygetUnknownTypeSerializerhandlePrimaryContextualizationhandleSecondaryContextualizationhasSerializationFeaturesinvalidTypeIdExceptionisEnabledisEnabledisEnabledisUnknownTypeSerializermappingExceptionmappingExceptionreportBadDefinitionreportBadDefinitionreportBadDefinitionreportBadPropertyDefinitionreportBadTypeDefinitionreportMappingProblemreportMappingProblemsetAttributesetDefaultKeySerializersetNullKeySerializersetNullValueSerializer

Field Detail

_generatorback to summary
protected transient JsonGenerator _generator

Generator used for serialization. Needed mostly for error reporting purposes.

Since
2.8
_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.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

DefaultSerializerProviderback to summary
protected DefaultSerializerProvider()
DefaultSerializerProviderback to summary
protected DefaultSerializerProvider(SerializerProvider src, SerializationConfig config, SerializerFactory f)
DefaultSerializerProviderback to summary
protected DefaultSerializerProvider(DefaultSerializerProvider src)
DefaultSerializerProviderback to summary
protected DefaultSerializerProvider(DefaultSerializerProvider src, CacheProvider cp)
Since
2.16

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.

Since
2.3
_serializeback to summary
private final void _serialize(JsonGenerator gen, Object value, JsonSerializer<Object> ser, PropertyName rootName) throws IOException
_serializeback to summary
private final void _serialize(JsonGenerator gen, Object value, JsonSerializer<Object> ser) throws IOException
_serializeNullback to summary
protected void _serializeNull(JsonGenerator gen) throws IOException

Helper method called when root value to serialize is null

Since
2.3
_wrapAsIOEback to summary
private IOException _wrapAsIOE(JsonGenerator g, Exception e)
acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JavaType javaType, JsonFormatVisitorWrapper visitor) throws JsonMappingException

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

Parameters
javaType:JavaType

The type for which to generate format

visitor:JsonFormatVisitorWrapper

the visitor to accept the format

cachedSerializersCountback to summary
public int cachedSerializersCount()

Method that can be used to determine how many serializers this provider is caching currently (if it does caching: default implementation does) Exact count depends on what kind of serializers get cached; default implementation caches all serializers, including ones that are eagerly constructed (for optimal access speed)

The main use case for this method is to allow conditional flushing of serializer cache, if certain number of entries is reached.

copyback to summary
public DefaultSerializerProvider copy()

Method needed to ensure that ObjectMapper#copy will work properly; specifically, that caches are cleared, but settings will otherwise remain identical; and that no sharing of state occurs.

Since
2.5
createInstanceback to summary
public abstract DefaultSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf)

Method that sub-classes need to implement: used to create a non-blueprint instances from the blueprint. This is needed to retain state during serialization.

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

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.findObjectId.

Doc from com.fasterxml.jackson.databind.SerializerProvider.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
flushCachedSerializersback to summary
public void flushCachedSerializers()

Method that will drop all serializers currently cached by this provider. This can be used to remove memory usage (in case some serializers are only used once or so), or to force re-construction of serializers after configuration changes for mapper than owns the provider.

generateJsonSchemaback to summary
public JsonSchema generateJsonSchema(Class<?> type) throws JsonMappingException

Deprecated

Should not be used any more

The method to be called by ObjectMapper to generate JSON schema for given type.

Parameters
type:Class<?>

The type for which to generate schema

Annotations
@Deprecated
getGeneratorback to summary
public JsonGenerator getGenerator()

Overrides com.fasterxml.jackson.databind.SerializerProvider.getGenerator.

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

Annotations
@Override
Since
2.8
hasSerializerForback to summary
public boolean hasSerializerFor(Class<?> cls, AtomicReference<Throwable> cause)

Method that can be called to see if this serializer provider can find a serializer for an instance of given class.

Note that no Exceptions are thrown, including unchecked ones: implementations are to swallow exceptions if necessary.

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

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.includeFilterInstance.

Doc from com.fasterxml.jackson.databind.SerializerProvider.includeFilterInstance.

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

Parameters
forProperty:BeanPropertyDefinition

(optional) If filter is created for a property, that property; `null` if filter created via defaulting, global or per-type.

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

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.includeFilterSuppressNulls.

Doc from com.fasterxml.jackson.databind.SerializerProvider.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, JsonSerializer<Object> valueSer, TypeSerializer typeSer) throws IOException

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

Since
2.6
serializerInstanceback to summary
public JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException

Implements abstract com.fasterxml.jackson.databind.SerializerProvider.serializerInstance.

Doc from com.fasterxml.jackson.databind.SerializerProvider.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, serialize will be properly resolved (via com.fasterxml.jackson.databind.ser.ResolvableSerializer) and/or contextualized (via com.fasterxml.jackson.databind.ser.ContextualSerializer) as necessary.

Parameters
annotated:Annotated

Annotated entity that contained definition

serDef:Object

Serializer definition: either an instance or class

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

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 IOException

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, JsonSerializer<Object> ser) throws IOException

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 JsonSerializer to use.

Parameters
rootType:JavaType

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

ser:JsonSerializer<Object>

Root Serializer to use, if not null

Since
2.1
withCachesback to summary
public abstract DefaultSerializerProvider withCaches(CacheProvider cacheProvider)

Fluent factory method used for constructing a new instance with cache instances provided by CacheProvider.

Since
2.16
com.fasterxml.jackson.databind.ser back to summary

public final Class DefaultSerializerProvider.Impl

extends DefaultSerializerProvider
Class Inheritance

Concrete implementation that defines factory method(s), defined as final.

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from com.fasterxml.jackson.databind.ser.DefaultSerializerProvider:
_generator_objectIdGenerators_seenObjectIds

Constructor Summary

AccessConstructor and Description
public
Impl()

public
protected
protected

Method Summary

Modifier and TypeMethod and Description
public DefaultSerializerProvider
copy()

Overrides com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.copy.

Method needed to ensure that ObjectMapper#copy will work properly; specifically, that caches are cleared, but settings will otherwise remain identical; and that no sharing of state occurs.
public DefaultSerializerProvider.Impl
createInstance(SerializationConfig config, SerializerFactory jsf)

Implements abstract com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.createInstance.

Method that sub-classes need to implement: used to create a non-blueprint instances from the blueprint.
public DefaultSerializerProvider
withCaches(CacheProvider cp)

Implements abstract com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.withCaches.

Fluent factory method used for constructing a new instance with cache instances provided by CacheProvider.
Inherited from com.fasterxml.jackson.databind.ser.DefaultSerializerProvider:
_createObjectIdMap_serializeNullacceptJsonFormatVisitorcachedSerializersCountfindObjectIdflushCachedSerializersgenerateJsonSchemagetGeneratorhasSerializerForincludeFilterInstanceincludeFilterSuppressNullsserializePolymorphicserializerInstanceserializeValueserializeValueserializeValue

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serialVersionUID.

Constructor Detail

Implback to summary
public Impl()
Implback to summary
public Impl(DefaultSerializerProvider.Impl src)
Implback to summary
protected Impl(SerializerProvider src, SerializationConfig config, SerializerFactory f)
Implback to summary
protected Impl(DefaultSerializerProvider.Impl src, CacheProvider cp)
Since
2.16

Method Detail

copyback to summary
public DefaultSerializerProvider copy()

Overrides com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.copy.

Doc from com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.copy.

Method needed to ensure that ObjectMapper#copy will work properly; specifically, that caches are cleared, but settings will otherwise remain identical; and that no sharing of state occurs.

Annotations
@Override
createInstanceback to summary
public DefaultSerializerProvider.Impl createInstance(SerializationConfig config, SerializerFactory jsf)

Implements abstract com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.createInstance.

Doc from com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.createInstance.

Method that sub-classes need to implement: used to create a non-blueprint instances from the blueprint. This is needed to retain state during serialization.

Annotations
@Override
withCachesback to summary
public DefaultSerializerProvider withCaches(CacheProvider cp)

Implements abstract com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.withCaches.

Doc from com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.withCaches.

Fluent factory method used for constructing a new instance with cache instances provided by CacheProvider.

Annotations
@Override