public abstract class SerializerProvider extends Object
ObjectMapper and
 JsonSerializers to obtain serializers capable of serializing
 instances of specific types.
 Note about usage: for JsonSerializer instances, only accessors
 for locating other (sub-)serializers are to be used. ObjectMapper,
 on the other hand, is to initialize recursive serialization process by
 calling serializeValue(org.codehaus.jackson.map.SerializationConfig, org.codehaus.jackson.JsonGenerator, java.lang.Object, org.codehaus.jackson.map.SerializerFactory).
| Modifier and Type | Field and Description | 
|---|---|
| protected SerializationConfig | _configSerialization configuration to use for serialization processing. | 
| protected Class<?> | _serializationViewView used for currently active serialization | 
| protected static JavaType | TYPE_OBJECT | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | SerializerProvider(SerializationConfig config) | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract 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) | 
| JavaType | constructSpecializedType(JavaType baseType,
                        Class<?> subclass) | 
| JavaType | constructType(Type type) | 
| abstract void | defaultSerializeDateKey(Date date,
                       JsonGenerator jgen)Method that will handle serialization of Dates used as  Mapkeys,
 based onSerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPSvalue (and if using textual representation, configured date format) | 
| abstract void | defaultSerializeDateKey(long timestamp,
                       JsonGenerator jgen)Method that will handle serialization of Dates used as  Mapkeys,
 based onSerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPSvalue (and if using textual representation, configured date format) | 
| abstract void | defaultSerializeDateValue(Date date,
                         JsonGenerator jgen)Method that will handle serialization of Date(-like) values, using
  SerializationConfigsettings to determine expected serialization
 behavior. | 
| abstract void | defaultSerializeDateValue(long timestamp,
                         JsonGenerator jgen)Method that will handle serialization of Date(-like) values, using
  SerializationConfigsettings to determine expected serialization
 behavior. | 
| void | defaultSerializeField(String fieldName,
                     Object value,
                     JsonGenerator jgen)Convenience method that will serialize given field with specified
 value. | 
| void | defaultSerializeNull(JsonGenerator jgen) | 
| void | defaultSerializeValue(Object value,
                     JsonGenerator jgen)Convenience method that will serialize given value (which can be
 null) using standard serializer locating functionality. | 
| abstract JsonSerializer<Object> | findKeySerializer(JavaType keyType,
                 BeanProperty property)Method called to get the serializer to use for serializing
 non-null Map keys. | 
| JsonSerializer<Object> | findTypedValueSerializer(Class<?> valueType,
                        boolean cache)Deprecated. 
 As of version 1.7, use version that exposes property object
    instead of just its type (needed for contextual serializers) | 
| abstract JsonSerializer<Object> | findTypedValueSerializer(Class<?> valueType,
                        boolean cache,
                        BeanProperty property)Method called to locate regular serializer, matching type serializer,
 and if both found, wrap them in a serializer that calls both in correct
 sequence. | 
| JsonSerializer<Object> | findTypedValueSerializer(JavaType valueType,
                        boolean cache)Deprecated. 
 As of version 1.7, use version that exposes property object
    instead of just its type (needed for contextual serializers) | 
| abstract JsonSerializer<Object> | findTypedValueSerializer(JavaType valueType,
                        boolean cache,
                        BeanProperty property)Method called to locate regular serializer, matching type serializer,
 and if both found, wrap them in a serializer that calls both in correct
 sequence. | 
| JsonSerializer<Object> | findValueSerializer(Class<?> runtimeType)Deprecated. 
 As of version 1.7, use version that exposes property object
    instead of just its type (needed for contextual serializers) | 
| abstract JsonSerializer<Object> | findValueSerializer(Class<?> runtimeType,
                   BeanProperty property)Method called to get hold of a serializer for a value of given type;
 or if no such serializer can be found, a default handler (which
 may do a best-effort generic serialization or just simply
 throw an exception when invoked). | 
| JsonSerializer<Object> | findValueSerializer(JavaType serializationType)Deprecated. 
 As of version 1.7, use version that exposes property object
    instead of just its type (needed for contextual serializers) | 
| abstract JsonSerializer<Object> | findValueSerializer(JavaType serializationType,
                   BeanProperty property)Similar to  findValueSerializer(Class), but takes full generics-aware
 type instead of raw class. | 
| abstract void | flushCachedSerializers()Method that will drop all serializers currently cached by this provider. | 
| abstract JsonSchema | generateJsonSchema(Class<?> type,
                  SerializationConfig config,
                  SerializerFactory jsf)Generate Json-schema for
 given type. | 
| SerializationConfig | getConfig()Method for accessing configuration for the serialization processing. | 
| FilterProvider | getFilterProvider()Convenience method for accessing provider to find serialization filters used,
 equivalent to calling: | 
| JsonSerializer<Object> | getKeySerializer()Deprecated. 
 As of version 1.7, use version that exposes property object
    instead of just its type (needed for contextual serializers) | 
| JsonSerializer<Object> | getKeySerializer(JavaType valueType,
                BeanProperty property)Deprecated. 
 As of version 1.8 | 
| abstract JsonSerializer<Object> | getNullKeySerializer()Method called to get the serializer to use for serializing
 Map keys that are nulls: this is needed since JSON does not allow
 any non-String value as key, including null. | 
| abstract JsonSerializer<Object> | getNullValueSerializer()Method called to get the serializer to use for serializing
 values (root level, Array members or List field values)
 that are nulls. | 
| Class<?> | getSerializationView()Convenience method for accessing serialization view in use (if any); equivalent to: | 
| abstract JsonSerializer<Object> | getUnknownTypeSerializer(Class<?> unknownType)Method called to get the serializer to use if provider
 can not determine an actual type-specific serializer
 to use; typically when none of  SerializerFactoryinstances are able to construct a serializer. | 
| abstract boolean | hasSerializerFor(SerializationConfig cfg,
                Class<?> cls,
                SerializerFactory jsf)Method that can be called to see if this serializer provider
 can find a serializer for an instance of given class. | 
| boolean | isEnabled(SerializationConfig.Feature feature)Convenience method for checking whether specified serialization
 feature is enabled or not. | 
| abstract void | serializeValue(SerializationConfig cfg,
              JsonGenerator jgen,
              Object value,
              JavaType rootType,
              SerializerFactory jsf)The method to be called by  ObjectMapperto
 execute recursive serialization, using serializers that
 this provider has access to; and using specified root type
 for locating first-level serializer. | 
| abstract void | serializeValue(SerializationConfig cfg,
              JsonGenerator jgen,
              Object value,
              SerializerFactory jsf)The method to be called by  ObjectMapperto
 execute recursive serialization, using serializers that
 this provider has access to. | 
| abstract void | setDefaultKeySerializer(JsonSerializer<Object> ks)Method that can be used to specify serializer to use for serializing
 all non-null JSON property names, unless more specific key serializer
 is found (i.e. | 
| abstract void | setNullKeySerializer(JsonSerializer<Object> nks)Method that can be used to specify serializer that will be
 used to write JSON property names matching null keys for Java
 Maps (which will throw an exception if try write such property
 name) | 
| abstract void | setNullValueSerializer(JsonSerializer<Object> nvs)Method that can be used to specify serializer that will be
 used to write JSON values matching Java null values
 instead of default one (which simply writes JSON null) | 
protected static final JavaType TYPE_OBJECT
protected final SerializationConfig _config
protected final Class<?> _serializationView
protected SerializerProvider(SerializationConfig config)
public abstract void setNullKeySerializer(JsonSerializer<Object> nks)
public abstract void setNullValueSerializer(JsonSerializer<Object> nvs)
public abstract void setDefaultKeySerializer(JsonSerializer<Object> ks)
Note that key serializer registration are different from value serializer registrations.
public abstract void serializeValue(SerializationConfig cfg, JsonGenerator jgen, Object value, SerializerFactory jsf) throws IOException, JsonGenerationException
ObjectMapper to
 execute recursive serialization, using serializers that
 this provider has access to.jsf - Underlying factory object used for creating serializers
    as neededIOExceptionJsonGenerationExceptionpublic abstract void serializeValue(SerializationConfig cfg, JsonGenerator jgen, Object value, JavaType rootType, SerializerFactory jsf) throws IOException, JsonGenerationException
ObjectMapper to
 execute recursive serialization, using serializers that
 this provider has access to; and using specified root type
 for locating first-level serializer.rootType - Type to use for locating serializer to use, instead of actual
    runtime type. Must be actual type, or one of its super typesIOExceptionJsonGenerationExceptionpublic abstract JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf) throws JsonMappingException
type - The type for which to generate schemaJsonMappingExceptionpublic abstract boolean hasSerializerFor(SerializationConfig cfg, Class<?> cls, SerializerFactory jsf)
Note that no Exceptions are thrown, including unchecked ones: implementations are to swallow exceptions if necessary.
public final SerializationConfig getConfig()
public final boolean isEnabled(SerializationConfig.Feature feature)
getConfig().isEnabled(feature);
public final Class<?> getSerializationView()
getConfig().getSerializationView();
public final FilterProvider getFilterProvider()
getConfig().getFilterProvider();
public JavaType constructSpecializedType(JavaType baseType, Class<?> subclass)
public abstract JsonSerializer<Object> findValueSerializer(Class<?> runtimeType, BeanProperty property) throws JsonMappingException
Note: this method is only called for non-null values; not for keys or null values. For these, check out other accessor methods.
 Note that starting with version 1.5, serializers should also be type-aware
 if they handle polymorphic types. That means that it may be necessary
 to also use a TypeSerializer based on declared (static) type
 being serializer (whereas actual data may be serialized using dynamic
 type)
JsonMappingException - if there are fatal problems with
   accessing suitable serializer; including that of not
   finding any serializerpublic abstract JsonSerializer<Object> findValueSerializer(JavaType serializationType, BeanProperty property) throws JsonMappingException
findValueSerializer(Class), but takes full generics-aware
 type instead of raw class.JsonMappingExceptionpublic abstract JsonSerializer<Object> findTypedValueSerializer(Class<?> valueType, boolean cache, BeanProperty property) throws JsonMappingException
valueType - Type for purpose of locating a serializer; usually dynamic
   runtime type, but can also be static declared type, depending on configurationcache - Whether resulting value serializer should be cached or not; this is just
    a hintJsonMappingExceptionpublic abstract JsonSerializer<Object> findTypedValueSerializer(JavaType valueType, boolean cache, BeanProperty property) throws JsonMappingException
valueType - Declared type of value being serialized (which may not
    be actual runtime type); used for finding both value serializer and
    type serializer to use for adding polymorphic type (if any)cache - Whether resulting value serializer should be cached or not; this is just
    a hintJsonMappingExceptionpublic abstract JsonSerializer<Object> findKeySerializer(JavaType keyType, BeanProperty property) throws JsonMappingException
findValueSerializer(java.lang.Class<?>, org.codehaus.jackson.map.BeanProperty) method is because actual write
 method must be different (@link JsonGenerator#writeFieldName};
 but also since behavior for some key types may differ.
Note that the serializer itself can be called with instances of any Java object, but not nulls.
JsonMappingException@Deprecated public final JsonSerializer<Object> findValueSerializer(Class<?> runtimeType) throws JsonMappingException
JsonMappingException@Deprecated public final JsonSerializer<Object> findValueSerializer(JavaType serializationType) throws JsonMappingException
JsonMappingException@Deprecated public final JsonSerializer<Object> findTypedValueSerializer(Class<?> valueType, boolean cache) throws JsonMappingException
JsonMappingException@Deprecated public final JsonSerializer<Object> findTypedValueSerializer(JavaType valueType, boolean cache) throws JsonMappingException
JsonMappingException@Deprecated public final JsonSerializer<Object> getKeySerializer() throws JsonMappingException
JsonMappingException@Deprecated public final JsonSerializer<Object> getKeySerializer(JavaType valueType, BeanProperty property) throws JsonMappingException
findKeySerializer(org.codehaus.jackson.type.JavaType, org.codehaus.jackson.map.BeanProperty), since process is now
 more complicated than simple lookup.JsonMappingExceptionpublic abstract JsonSerializer<Object> getNullKeySerializer()
Typically, returned serializer will either throw an exception, or use an empty String; but other behaviors are possible.
public abstract JsonSerializer<Object> getNullValueSerializer()
Typically returned serializer just writes out Json literal null value.
public abstract JsonSerializer<Object> getUnknownTypeSerializer(Class<?> unknownType)
SerializerFactory
 instances are able to construct a serializer.
 Typically, returned serializer will throw an exception,
 although alternatively ToStringSerializer could
 be returned as well.
unknownType - Type for which no serializer is foundpublic final void defaultSerializeValue(Object value, JsonGenerator jgen) throws IOException, JsonProcessingException
defaultSerializeField(java.lang.String, java.lang.Object, org.codehaus.jackson.JsonGenerator) instead.IOExceptionJsonProcessingExceptionpublic final void defaultSerializeField(String fieldName, Object value, JsonGenerator jgen) throws IOException, JsonProcessingException
IOExceptionJsonProcessingExceptionpublic abstract void defaultSerializeDateValue(long timestamp,
                             JsonGenerator jgen)
                                        throws IOException,
                                               JsonProcessingException
SerializationConfig settings to determine expected serialization
 behavior.
 Note: date here means "full" date, that is, date AND time, as per
 Java convention (and not date-only values like in SQL)IOExceptionJsonProcessingExceptionpublic abstract void defaultSerializeDateValue(Date date, JsonGenerator jgen) throws IOException, JsonProcessingException
SerializationConfig settings to determine expected serialization
 behavior.
 Note: date here means "full" date, that is, date AND time, as per
 Java convention (and not date-only values like in SQL)IOExceptionJsonProcessingExceptionpublic abstract void defaultSerializeDateKey(long timestamp,
                           JsonGenerator jgen)
                                      throws IOException,
                                             JsonProcessingException
Map keys,
 based on SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS
 value (and if using textual representation, configured date format)IOExceptionJsonProcessingExceptionpublic abstract void defaultSerializeDateKey(Date date, JsonGenerator jgen) throws IOException, JsonProcessingException
Map keys,
 based on SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS
 value (and if using textual representation, configured date format)IOExceptionJsonProcessingExceptionpublic final void defaultSerializeNull(JsonGenerator jgen) throws IOException, JsonProcessingException
IOExceptionJsonProcessingExceptionpublic abstract int cachedSerializersCount()
The main use case for this method is to allow conditional flushing of serializer cache, if certain number of entries is reached.
public abstract void flushCachedSerializers()