com.fasterxml.jackson.databind.ser

Class DefaultSerializerProvider

    • Field Detail

      • _seenObjectIds

        protected transient Map<Object,WritableObjectId> _seenObjectIds
        Per-serialization map Object Ids that have seen so far, iff Object Id handling is enabled.
      • _objectIdGenerators

        protected transient ArrayList<com.fasterxml.jackson.annotation.ObjectIdGenerator<?>> _objectIdGenerators
      • _generator

        protected transient com.fasterxml.jackson.core.JsonGenerator _generator
        Generator used for serialization. Needed mostly for error reporting purposes.
        Since:
        2.8
    • Method Detail

      • copy

        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
      • includeFilterInstance

        public Object includeFilterInstance(BeanPropertyDefinition forProperty,
                                            Class<?> filterClass)
        Description copied from class: SerializerProvider
        Method that can be called to construct and configure JsonInclude filter instance, given a Class to instantiate (with default constructor, by default).
        Specified by:
        includeFilterInstance in class SerializerProvider
        Parameters:
        forProperty - (optional) If filter is created for a property, that property; `null` if filter created via defaulting, global or per-type.
      • findObjectId

        public WritableObjectId findObjectId(Object forPojo,
                                             com.fasterxml.jackson.annotation.ObjectIdGenerator<?> generatorType)
        Description copied from class: SerializerProvider
        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.
        Specified by:
        findObjectId in class SerializerProvider
      • _createObjectIdMap

        protected Map<Object,WritableObjectId> _createObjectIdMap()
        Overridable helper method used for creating Map used for storing mappings from serializable objects to their Object Ids.
        Since:
        2.3
      • hasSerializerFor

        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.

      • getGenerator

        public com.fasterxml.jackson.core.JsonGenerator getGenerator()
        Accessor for the JsonGenerator currently in use for serializing content. Null for blueprint instances; non-null for actual active provider instances.
        Overrides:
        getGenerator in class SerializerProvider
        Since:
        2.8
      • serializeValue

        public void serializeValue(com.fasterxml.jackson.core.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).
        Throws:
        IOException
      • serializeValue

        public void serializeValue(com.fasterxml.jackson.core.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 - Type to use for locating serializer to use, instead of actual runtime type. Must be actual type, or one of its super types
        Throws:
        IOException
      • serializeValue

        public void serializeValue(com.fasterxml.jackson.core.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 - Type to use for locating serializer to use, instead of actual runtime type, if no serializer is passed
        ser - Root Serializer to use, if not null
        Throws:
        IOException
        Since:
        2.1
      • _serializeNull

        protected void _serializeNull(com.fasterxml.jackson.core.JsonGenerator gen)
                               throws IOException
        Helper method called when root value to serialize is null
        Throws:
        IOException
        Since:
        2.3
      • cachedSerializersCount

        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.

      • flushCachedSerializers

        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.

Copyright © 2008–2024 FasterXML. All rights reserved.