|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasterxml.jackson.databind.ser.SerializerFactory com.fasterxml.jackson.databind.ser.BasicSerializerFactory
public abstract class BasicSerializerFactory
Factory class that can provide serializers for standard JDK classes,
as well as custom classes that extend standard classes or implement
one of "well-known" interfaces (such as Collection
).
Since all the serializers are eagerly instantiated, and there is no additional introspection or customizability of these types, this factory is essentially stateless.
Field Summary | |
---|---|
protected static HashMap<String,JsonSerializer<?>> |
_concrete
Since these are all JDK classes, we shouldn't have to worry about ClassLoader used to load them. |
protected static HashMap<String,Class<? extends JsonSerializer<?>>> |
_concreteLazy
Actually it may not make much sense to eagerly instantiate all kinds of serializers: so this Map actually contains class references, not instances |
protected SerializerFactoryConfig |
_factoryConfig
Configuration settings for this factory; immutable instance (just like this factory), new version created via copy-constructor (fluent-style) |
protected OptionalHandlerFactory |
optionalHandlers
Helper object used to deal with serializers for optional JDK types (like ones omitted from GAE, Android) |
Constructor Summary | |
---|---|
protected |
BasicSerializerFactory(SerializerFactoryConfig config)
We will provide default constructor to allow sub-classing, but make it protected so that no non-singleton instances of the class will be instantiated. |
Method Summary | ||
---|---|---|
protected JsonSerializer<Object> |
_findContentSerializer(SerializerProvider prov,
Annotated a,
BeanProperty property)
|
|
protected JsonSerializer<Object> |
_findKeySerializer(SerializerProvider prov,
Annotated a,
BeanProperty property)
|
|
protected Class<?> |
_verifyAsClass(Object src,
String methodName,
Class<?> noneClass)
|
|
protected JsonSerializer<?> |
buildArraySerializer(SerializationConfig config,
ArrayType type,
BeanDescription beanDesc,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for Object[] (and subtypes, except for String). |
|
protected JsonSerializer<?> |
buildCollectionSerializer(SerializationConfig config,
CollectionType type,
BeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for List types that support efficient by-index access |
|
protected JsonSerializer<?> |
buildContainerSerializer(SerializerProvider prov,
JavaType type,
BeanDescription beanDesc,
BeanProperty property,
boolean staticTyping)
|
|
protected JsonSerializer<?> |
buildIterableSerializer(SerializationConfig config,
JavaType type,
BeanDescription beanDesc,
boolean staticTyping)
|
|
protected JsonSerializer<?> |
buildIteratorSerializer(SerializationConfig config,
JavaType type,
BeanDescription beanDesc,
boolean staticTyping)
|
|
protected JsonSerializer<?> |
buildMapSerializer(SerializationConfig config,
MapType type,
BeanDescription beanDesc,
boolean staticTyping,
JsonSerializer<Object> keySerializer,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for Map types. |
|
JsonSerializer<Object> |
createKeySerializer(SerializationConfig config,
JavaType type)
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) |
|
abstract JsonSerializer<Object> |
createSerializer(SerializerProvider prov,
JavaType type,
BeanProperty property)
Method called to create (or, for immutable serializers, reuse) a serializer for given type. |
|
TypeSerializer |
createTypeSerializer(SerializationConfig config,
JavaType baseType)
Method called to construct a type serializer for values with given declared base type. |
|
protected abstract Iterable<Serializers> |
customSerializers()
|
|
protected JsonSerializer<?> |
findSerializerByAddonType(SerializationConfig config,
JavaType javaType,
BeanDescription beanDesc,
boolean staticTyping)
Reflection-based serialized find method, which checks if given class implements one of recognized "add-on" interfaces. |
|
protected JsonSerializer<?> |
findSerializerByAnnotations(SerializerProvider prov,
JavaType type,
BeanDescription beanDesc)
Method called to see if one of primary per-class annotations (or related, like implementing of JsonSerializable )
determines the serializer to use. |
|
protected JsonSerializer<?> |
findSerializerByLookup(JavaType type,
SerializationConfig config,
BeanDescription beanDesc,
boolean staticTyping)
Method that will use fast lookup (and identity comparison) methods to see if we know serializer to use for given type. |
|
protected JsonSerializer<?> |
findSerializerByPrimaryType(SerializerProvider prov,
JavaType type,
BeanDescription beanDesc,
boolean staticTyping)
Method for checking if we can determine serializer to use based on set of known primary types, checking for set of known base types (exact matches having been compared against with findSerializerByLookup ). |
|
protected JsonSerializer<Object> |
findSerializerFromAnnotation(SerializerProvider prov,
Annotated a)
Helper method called to check if a class or method has an annotation (@link com.fasterxml.jackson.databind.annotation.JsonSerialize#using) that tells the class to use for serialization. |
|
JsonSerializer<?> |
getNullSerializer()
|
|
protected boolean |
isIndexedList(Class<?> cls)
|
|
protected static
|
modifySecondaryTypesByAnnotation(SerializationConfig config,
Annotated a,
T type)
|
|
protected
|
modifyTypeByAnnotation(SerializationConfig config,
Annotated a,
T type)
Helper method used to encapsulate details of annotation-based type coercion |
|
protected boolean |
usesStaticTyping(SerializationConfig config,
BeanDescription beanDesc,
TypeSerializer typeSer,
BeanProperty property)
Helper method to check whether global settings and/or class annotations for the bean class indicate that static typing (declared types) should be used for properties. |
|
SerializerFactory |
withAdditionalKeySerializers(Serializers additional)
Convenience method for creating a new factory instance with an additional key serializer provider. |
|
SerializerFactory |
withAdditionalSerializers(Serializers additional)
Convenience method for creating a new factory instance with an additional serializer provider. |
|
abstract SerializerFactory |
withConfig(SerializerFactoryConfig 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final HashMap<String,JsonSerializer<?>> _concrete
protected static final HashMap<String,Class<? extends JsonSerializer<?>>> _concreteLazy
protected final SerializerFactoryConfig _factoryConfig
protected OptionalHandlerFactory optionalHandlers
Constructor Detail |
---|
protected BasicSerializerFactory(SerializerFactoryConfig config)
Method Detail |
---|
public abstract SerializerFactory withConfig(SerializerFactoryConfig config)
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.
public final SerializerFactory withAdditionalSerializers(Serializers additional)
withAdditionalSerializers
in class SerializerFactory
public final SerializerFactory withAdditionalKeySerializers(Serializers additional)
withAdditionalKeySerializers
in class SerializerFactory
public final SerializerFactory withSerializerModifier(BeanSerializerModifier modifier)
withSerializerModifier
in class SerializerFactory
public abstract JsonSerializer<Object> createSerializer(SerializerProvider prov, JavaType type, BeanProperty property) throws JsonMappingException
SerializerFactory
createSerializer
in class SerializerFactory
prov
- Provider that needs to be used to resolve annotation-provided
serializers (but NOT for others)
JsonMappingException
public JsonSerializer<Object> createKeySerializer(SerializationConfig config, JavaType type)
SerializerFactory
JsonToken.FIELD_NAME
) for Map that has specified declared
key type, and is for specified property (or, if property is null, as root value)
createKeySerializer
in class SerializerFactory
type
- Declared type for Map keys
public TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType)
createTypeSerializer
in class SerializerFactory
baseType
- Declared type to use as the base type for type information serializer
public final JsonSerializer<?> getNullSerializer()
protected abstract Iterable<Serializers> customSerializers()
protected final JsonSerializer<?> findSerializerByLookup(JavaType type, SerializationConfig config, BeanDescription beanDesc, boolean staticTyping)
protected final JsonSerializer<?> findSerializerByAnnotations(SerializerProvider prov, JavaType type, BeanDescription beanDesc) throws JsonMappingException
JsonSerializable
)
determines the serializer to use.
Currently handles things like:
JsonSerializable
, use that
JsonValue
annotation (or equivalent), build serializer
based on that property
JsonMappingException
protected final JsonSerializer<?> findSerializerByPrimaryType(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException
findSerializerByLookup
).
This does not include "secondary" interfaces, but
mostly concrete or abstract base classes.
JsonMappingException
protected final JsonSerializer<?> findSerializerByAddonType(SerializationConfig config, JavaType javaType, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException
Iterable
, but their main
function is usually something else. The reason for
JsonMappingException
protected JsonSerializer<Object> findSerializerFromAnnotation(SerializerProvider prov, Annotated a) throws JsonMappingException
JsonMappingException
protected JsonSerializer<?> buildContainerSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc, BeanProperty property, boolean staticTyping) throws JsonMappingException
JsonMappingException
protected JsonSerializer<?> buildCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, BeanProperty property, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) throws JsonMappingException
List
types that support efficient by-index access
JsonMappingException
protected boolean isIndexedList(Class<?> cls)
protected JsonSerializer<?> buildMapSerializer(SerializationConfig config, MapType type, BeanDescription beanDesc, boolean staticTyping, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) throws JsonMappingException
Map
types.
JsonMappingException
protected JsonSerializer<?> buildArraySerializer(SerializationConfig config, ArrayType type, BeanDescription beanDesc, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) throws JsonMappingException
Object[]
(and subtypes, except for String).
JsonMappingException
protected JsonSerializer<?> buildIteratorSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException
JsonMappingException
protected JsonSerializer<?> buildIterableSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException
JsonMappingException
protected <T extends JavaType> T modifyTypeByAnnotation(SerializationConfig config, Annotated a, T type)
protected static <T extends JavaType> T modifySecondaryTypesByAnnotation(SerializationConfig config, Annotated a, T type)
protected JsonSerializer<Object> _findKeySerializer(SerializerProvider prov, Annotated a, BeanProperty property) throws JsonMappingException
JsonMappingException
protected JsonSerializer<Object> _findContentSerializer(SerializerProvider prov, Annotated a, BeanProperty property) throws JsonMappingException
JsonMappingException
protected boolean usesStaticTyping(SerializationConfig config, BeanDescription beanDesc, TypeSerializer typeSer, BeanProperty property)
protected Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClass)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |