org.codehaus.jackson.map
Class SerializerFactory

java.lang.Object
  extended by org.codehaus.jackson.map.SerializerFactory
Direct Known Subclasses:
BasicSerializerFactory

public abstract class SerializerFactory
extends Object

Abstract class that defines API used by SerializerProvider to obtain actual JsonSerializer instances from multiple distinct factories.


Nested Class Summary
static class SerializerFactory.Config
          Configuration settings container class for bean serializer factory.
 
Constructor Summary
SerializerFactory()
           
 
Method Summary
abstract  JsonSerializer<Object> createKeySerializer(SerializationConfig config, JavaType baseType, BeanProperty property)
          Method called to create serializer to use for serializing JSON property names (which must be output as JsonToken.FIELD_NAME) for Map that has specified declared key type, and is for specified property (or, if property is null, as root value)
 JsonSerializer<Object> createSerializer(JavaType type, SerializationConfig config)
          Deprecated. Since 1.7, call variant with more arguments
abstract  JsonSerializer<Object> createSerializer(SerializationConfig config, JavaType baseType, BeanProperty property)
          Method called to create (or, for immutable serializers, reuse) a serializer for given type.
 TypeSerializer createTypeSerializer(JavaType baseType, SerializationConfig config)
          Deprecated. Since 1.7, call variant with more arguments
abstract  TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType, BeanProperty property)
          Method called to create a type information serializer for given base type, if one is needed.
abstract  SerializerFactory.Config getConfig()
           
 SerializerFactory withAdditionalKeySerializers(Serializers additional)
           
 SerializerFactory withAdditionalSerializers(Serializers additional)
          Convenience method for creating a new factory instance with additional serializer provider; equivalent to calling
abstract  SerializerFactory withConfig(SerializerFactory.Config config)
          Method used for creating a new instance of this factory, but with different configuration.
 SerializerFactory withSerializerModifier(BeanSerializerModifier modifier)
          Convenience method for creating a new factory instance with additional bean serializer modifier; equivalent to calling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializerFactory

public SerializerFactory()
Method Detail

getConfig

public abstract SerializerFactory.Config getConfig()
Since:
1.7

withConfig

public abstract SerializerFactory withConfig(SerializerFactory.Config config)
Method used for creating a new instance of this factory, but with different configuration. Reason for specifying factory method (instead of plain constructor) is to allow proper sub-classing of factories.

Note that custom sub-classes generally must override implementation of this method, as it usually requires instantiating a new instance of factory type. Check out javadocs for BeanSerializerFactory for more details.

Since:
1.7

withAdditionalSerializers

public final SerializerFactory withAdditionalSerializers(Serializers additional)
Convenience method for creating a new factory instance with additional serializer provider; equivalent to calling
   withConfig(getConfig().withAdditionalSerializers(additional));

Since:
1.7

withAdditionalKeySerializers

public final SerializerFactory withAdditionalKeySerializers(Serializers additional)
Since:
1.8

withSerializerModifier

public final SerializerFactory withSerializerModifier(BeanSerializerModifier modifier)
Convenience method for creating a new factory instance with additional bean serializer modifier; equivalent to calling
   withConfig(getConfig().withSerializerModifier(modifier));

Since:
1.7

createSerializer

public abstract JsonSerializer<Object> createSerializer(SerializationConfig config,
                                                        JavaType baseType,
                                                        BeanProperty property)
                                                 throws JsonMappingException
Method called to create (or, for immutable serializers, reuse) a serializer for given type.

Throws:
JsonMappingException

createTypeSerializer

public abstract TypeSerializer createTypeSerializer(SerializationConfig config,
                                                    JavaType baseType,
                                                    BeanProperty property)
                                             throws JsonMappingException
Method called to create a type information serializer for given base type, if one is needed. If not needed (no polymorphic handling configured), should return null.

Parameters:
baseType - Declared type to use as the base type for type information serializer
Returns:
Type serializer to use for the base type, if one is needed; null if not.
Throws:
JsonMappingException
Since:
1.7

createKeySerializer

public abstract JsonSerializer<Object> createKeySerializer(SerializationConfig config,
                                                           JavaType baseType,
                                                           BeanProperty property)
                                                    throws JsonMappingException
Method called to create serializer to use for serializing JSON property names (which must be output as JsonToken.FIELD_NAME) for Map that has specified declared key type, and is for specified property (or, if property is null, as root value)

Parameters:
config - Serialization configuration in use
baseType - Declared type for Map keys
property - Property that contains Map being serialized; null when serializing root Map value.
Returns:
Serializer to use, if factory knows it; null if not (in which case default serializer is to be used)
Throws:
JsonMappingException
Since:
1.8

createSerializer

@Deprecated
public final JsonSerializer<Object> createSerializer(JavaType type,
                                                                SerializationConfig config)
Deprecated. Since 1.7, call variant with more arguments

Deprecated version of accessor for type id serializer: as of 1.7 one needs to instead call version that passes property information through.

Since:
1.5

createTypeSerializer

@Deprecated
public final TypeSerializer createTypeSerializer(JavaType baseType,
                                                            SerializationConfig config)
Deprecated. Since 1.7, call variant with more arguments

Deprecated version of accessor for type id serializer: as of 1.7 one needs to instead call version that passes property information through.

Since:
1.5