Class StdSerializerProvider


  • public class StdSerializerProvider
    extends SerializerProvider
    Default SerializerProvider implementation. Handles caching aspects of serializer handling; all construction details are delegated to SerializerFactory instance.

    One note about implementation: the main instance constructed will be so-called "blueprint" object, and will NOT be used during actual serialization. Rather, an "instance" instance is created so that state can be carried along, as well as to avoid synchronization during serializer access. Because of this, if sub-classing, one must override method createInstance(org.codehaus.jackson.map.SerializationConfig, org.codehaus.jackson.map.SerializerFactory): if this is not done, an exception will get thrown as base class verifies that the instance has same class as the blueprint (instance.getClass() == blueprint.getClass()). Check is done to prevent weird bugs that would otherwise occur.

    Starting with version 1.5, provider is also responsible for some parts of type serialization; specifically for locating proper type serializers to use for types.

    • Field Detail

      • DEFAULT_NULL_KEY_SERIALIZER

        public static final JsonSerializer<java.lang.Object> DEFAULT_NULL_KEY_SERIALIZER
      • DEFAULT_KEY_SERIALIZER

        @Deprecated
        public static final JsonSerializer<java.lang.Object> DEFAULT_KEY_SERIALIZER
        Deprecated.
        Since 1.9, use StdKeySerializers instead
      • DEFAULT_UNKNOWN_SERIALIZER

        public static final JsonSerializer<java.lang.Object> DEFAULT_UNKNOWN_SERIALIZER
      • _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<java.lang.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; a possible alternative that can be used would be ToStringSerializer.

      • _keySerializer

        protected JsonSerializer<java.lang.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.
      • _nullValueSerializer

        protected JsonSerializer<java.lang.Object> _nullValueSerializer
        Serializer used to output a null value. Default implementation writes nulls using JsonGenerator.writeNull().
      • _nullKeySerializer

        protected JsonSerializer<java.lang.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 java.text.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.