com.fasterxml.jackson.databind

Class SerializerProvider

  • Direct Known Subclasses:
    DefaultSerializerProvider


    public abstract class SerializerProvider
    extends DatabindContext
    Class that defines API used by ObjectMapper and JsonSerializers to obtain serializers capable of serializing instances of specific types; as well as the default implementation of the functionality.

    Provider handles caching aspects of serializer handling; all construction details are delegated to SerializerFactory instance.

    Object life-cycle is such that an initial instance ("blueprint") is created and referenced by ObjectMapper and ObjectWriter intances; but for actual usage, a configured instance is created by using a create method in sub-class DefaultSerializerProvider. Only this instance can be used for actual serialization calls; blueprint object is only to be used for creating instances.

    • Field Detail

      • TYPE_OBJECT

        protected static final JavaType TYPE_OBJECT
      • CACHE_UNKNOWN_MAPPINGS

        protected static final boolean CACHE_UNKNOWN_MAPPINGS
        Setting for determining whether mappings for "unknown classes" should be cached for faster resolution. Usually this isn't needed, but maybe it is in some cases?
        See Also:
        Constant Field Values
      • DEFAULT_NULL_KEY_SERIALIZER

        public static final JsonSerializer<Object> DEFAULT_NULL_KEY_SERIALIZER
      • _config

        protected final SerializationConfig _config
        Serialization configuration to use for serialization processing.
      • _serializationView

        protected final Class<?> _serializationView
        View used for currently active serialization, if any.
      • _serializerFactory

        protected final SerializerFactory _serializerFactory
        Factory used for constructing actual serializer instances.
      • _serializerCache

        protected final SerializerCache _serializerCache
        Cache for doing type-to-value-serializer lookups.
      • _rootNames

        protected final RootNameLookup _rootNames
        Helper object for keeping track of introspected root names
      • _unknownTypeSerializer

        protected JsonSerializer<Object> _unknownTypeSerializer
        Serializer that gets called for values of types for which no serializers can be constructed.

        The default serializer will simply thrown an exception.

      • _keySerializer

        protected JsonSerializer<Object> _keySerializer
        Serializer used to output non-null keys of Maps (which will get output as JSON Objects), if not null; if null, us the standard default key serializer.
      • _nullKeySerializer

        protected JsonSerializer<Object> _nullKeySerializer
        Serializer used to (try to) output a null key, due to an entry of Map having null key. The default implementation will throw an exception if this happens; alternative implementation (like one that would write an Empty String) can be defined.
      • _knownSerializers

        protected final ReadOnlyClassToSerializerMap _knownSerializers
        For fast lookups, we will have a local non-shared read-only map that contains serializers previously fetched.
      • _dateFormat

        protected DateFormat _dateFormat
        Lazily acquired and instantiated formatter object: initialized first time it is needed, reused afterwards. Used via instances (not blueprints), so that access need not be thread-safe.
    • Constructor Detail

      • SerializerProvider

        public SerializerProvider()
        Constructor for creating master (or "blue-print") provider object, which is only used as the template for constructing per-binding instances.

Copyright © 2012-2014 FasterXML. All Rights Reserved.