org.codehaus.jackson.map.deser
Class BasicDeserializerFactory

java.lang.Object
  extended by org.codehaus.jackson.map.DeserializerFactory
      extended by org.codehaus.jackson.map.deser.BasicDeserializerFactory
Direct Known Subclasses:
BeanDeserializerFactory

public abstract class BasicDeserializerFactory
extends DeserializerFactory

Abstract factory base class that can provide deserializers for standard JDK classes, including collection classes and simple heuristics for "upcasting" commmon collection interface types (such as Collection).

Since all simple deserializers are eagerly instantiated, and there is no additional introspection or customizability of these types, this factory is stateless.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.jackson.map.DeserializerFactory
DeserializerFactory.Config
 
Field Summary
protected static HashMap<JavaType,JsonDeserializer<Object>> _arrayDeserializers
          And finally, we have special array deserializers for primitive array types
protected  OptionalHandlerFactory optionalHandlers
          To support external/optional deserializers, we'll use this helper class (as per [JACKSON-386])
 
Fields inherited from class org.codehaus.jackson.map.DeserializerFactory
NO_DESERIALIZERS
 
Constructor Summary
protected BasicDeserializerFactory()
           
 
Method Summary
protected abstract  JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type, DeserializationConfig config, DeserializerProvider p, BeanProperty property, TypeDeserializer elementTypeDeser, JsonDeserializer<?> elementDeser)
           
protected abstract  JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type, DeserializationConfig config, DeserializerProvider p, BasicBeanDescription beanDesc, BeanProperty property, TypeDeserializer elementTypeDeser, JsonDeserializer<?> elementDeser)
           
protected abstract  JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, DeserializerProvider p, BasicBeanDescription beanDesc, BeanProperty property, TypeDeserializer elementTypeDeser, JsonDeserializer<?> elementDeser)
           
protected abstract  JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type, DeserializationConfig config, BasicBeanDescription beanDesc, BeanProperty property)
           
protected abstract  JsonDeserializer<?> _findCustomMapDeserializer(MapType type, DeserializationConfig config, DeserializerProvider p, BasicBeanDescription beanDesc, BeanProperty property, KeyDeserializer keyDeser, TypeDeserializer elementTypeDeser, JsonDeserializer<?> elementDeser)
           
protected abstract  JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type, DeserializationConfig config, DeserializerProvider p, BasicBeanDescription beanDesc, BeanProperty property, KeyDeserializer keyDeser, TypeDeserializer elementTypeDeser, JsonDeserializer<?> elementDeser)
           
protected abstract  JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type, DeserializationConfig config, BeanProperty property)
           
protected  SettableBeanProperty constructCreatorProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, int index, AnnotatedParameter param)
          Method that will construct a property object that represents a logical property passed via Creator (constructor or static factory method)
protected  EnumResolver<?> constructEnumResolver(Class<?> enumClass, DeserializationConfig config)
           
 JsonDeserializer<?> createArrayDeserializer(DeserializationConfig config, DeserializerProvider p, ArrayType type, BeanProperty property)
          Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.
 JsonDeserializer<?> createCollectionDeserializer(DeserializationConfig config, DeserializerProvider p, CollectionType type, BeanProperty property)
           
 JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig config, DeserializerProvider p, CollectionLikeType type, BeanProperty property)
           
 JsonDeserializer<?> createEnumDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property)
          Factory method for constructing serializers of Enum types.
 JsonDeserializer<?> createMapDeserializer(DeserializationConfig config, DeserializerProvider p, MapType type, BeanProperty property)
           
 JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig config, DeserializerProvider p, MapLikeType type, BeanProperty property)
           
 JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType nodeType, BeanProperty property)
          Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.
protected  JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationConfig config, Annotated ann, BeanProperty property)
          Helper method called to check if a class or method has annotation that tells which class to use for deserialization.
protected  CreatorContainer findMapCreators(DeserializationConfig config, BasicBeanDescription beanDesc)
          Method used to find non-default constructors and factory methods that are marked to be used as Creators for a Map type.
 TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config, JavaType containerType, AnnotatedMember propertyEntity, BeanProperty property)
          Method called to find and create a type information deserializer for values of given container (list, array, map) property, if one is needed.
 TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated, BeanProperty property)
          Method called to create a type information deserializer for values of given non-container property, if one is needed.
protected  JsonDeserializer<Object> findStdBeanDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property)
          Method called by BeanDeserializerFactory to see if there might be a standard deserializer registered for given type.
 TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType, BeanProperty property)
          Method called to find and create a type information deserializer for given base type, if one is needed.
protected abstract  JavaType mapAbstractType(DeserializationConfig config, JavaType type)
           
protected
<T extends JavaType>
T
modifyTypeByAnnotation(DeserializationConfig config, Annotated a, T type, String propName)
          Method called to see if given method has annotations that indicate a more specific type than what the argument specifies.
protected  JavaType resolveType(DeserializationConfig config, BasicBeanDescription beanDesc, JavaType type, AnnotatedMember member, BeanProperty property)
          Helper method used to resolve method return types and field types.
abstract  DeserializerFactory withConfig(DeserializerFactory.Config config)
          Method used for creating a new instance of this factory, but with different configuration.
 
Methods inherited from class org.codehaus.jackson.map.DeserializerFactory
createArrayDeserializer, createBeanDeserializer, createBeanDeserializer, createCollectionDeserializer, createEnumDeserializer, createKeyDeserializer, createMapDeserializer, createTreeDeserializer, findTypeDeserializer, getConfig, withAbstractTypeResolver, withAdditionalDeserializers, withAdditionalKeyDeserializers, withDeserializerModifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_arrayDeserializers

protected static final HashMap<JavaType,JsonDeserializer<Object>> _arrayDeserializers
And finally, we have special array deserializers for primitive array types


optionalHandlers

protected OptionalHandlerFactory optionalHandlers
To support external/optional deserializers, we'll use this helper class (as per [JACKSON-386])

Constructor Detail

BasicDeserializerFactory

protected BasicDeserializerFactory()
Method Detail

withConfig

public abstract DeserializerFactory withConfig(DeserializerFactory.Config config)
Description copied from class: DeserializerFactory
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 must override implementation of this method, as it usually requires instantiating a new instance of factory type. Check out javadocs for BeanDeserializerFactory for more details.

Specified by:
withConfig in class DeserializerFactory

_findCustomArrayDeserializer

protected abstract JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type,
                                                                    DeserializationConfig config,
                                                                    DeserializerProvider p,
                                                                    BeanProperty property,
                                                                    TypeDeserializer elementTypeDeser,
                                                                    JsonDeserializer<?> elementDeser)
                                                             throws JsonMappingException
Throws:
JsonMappingException

_findCustomCollectionDeserializer

protected abstract JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type,
                                                                         DeserializationConfig config,
                                                                         DeserializerProvider p,
                                                                         BasicBeanDescription beanDesc,
                                                                         BeanProperty property,
                                                                         TypeDeserializer elementTypeDeser,
                                                                         JsonDeserializer<?> elementDeser)
                                                                  throws JsonMappingException
Throws:
JsonMappingException

_findCustomCollectionLikeDeserializer

protected abstract JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type,
                                                                             DeserializationConfig config,
                                                                             DeserializerProvider p,
                                                                             BasicBeanDescription beanDesc,
                                                                             BeanProperty property,
                                                                             TypeDeserializer elementTypeDeser,
                                                                             JsonDeserializer<?> elementDeser)
                                                                      throws JsonMappingException
Throws:
JsonMappingException

_findCustomEnumDeserializer

protected abstract JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type,
                                                                   DeserializationConfig config,
                                                                   BasicBeanDescription beanDesc,
                                                                   BeanProperty property)
                                                            throws JsonMappingException
Throws:
JsonMappingException

_findCustomMapDeserializer

protected abstract JsonDeserializer<?> _findCustomMapDeserializer(MapType type,
                                                                  DeserializationConfig config,
                                                                  DeserializerProvider p,
                                                                  BasicBeanDescription beanDesc,
                                                                  BeanProperty property,
                                                                  KeyDeserializer keyDeser,
                                                                  TypeDeserializer elementTypeDeser,
                                                                  JsonDeserializer<?> elementDeser)
                                                           throws JsonMappingException
Throws:
JsonMappingException

_findCustomMapLikeDeserializer

protected abstract JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type,
                                                                      DeserializationConfig config,
                                                                      DeserializerProvider p,
                                                                      BasicBeanDescription beanDesc,
                                                                      BeanProperty property,
                                                                      KeyDeserializer keyDeser,
                                                                      TypeDeserializer elementTypeDeser,
                                                                      JsonDeserializer<?> elementDeser)
                                                               throws JsonMappingException
Throws:
JsonMappingException

_findCustomTreeNodeDeserializer

protected abstract JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type,
                                                                       DeserializationConfig config,
                                                                       BeanProperty property)
                                                                throws JsonMappingException
Throws:
JsonMappingException

createArrayDeserializer

public JsonDeserializer<?> createArrayDeserializer(DeserializationConfig config,
                                                   DeserializerProvider p,
                                                   ArrayType type,
                                                   BeanProperty property)
                                            throws JsonMappingException
Description copied from class: DeserializerFactory
Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.

Specified by:
createArrayDeserializer in class DeserializerFactory
p - Provider that can be called to create deserializers for contained member types
type - Type to be deserialized
Throws:
JsonMappingException

createCollectionDeserializer

public JsonDeserializer<?> createCollectionDeserializer(DeserializationConfig config,
                                                        DeserializerProvider p,
                                                        CollectionType type,
                                                        BeanProperty property)
                                                 throws JsonMappingException
Specified by:
createCollectionDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createCollectionLikeDeserializer

public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig config,
                                                            DeserializerProvider p,
                                                            CollectionLikeType type,
                                                            BeanProperty property)
                                                     throws JsonMappingException
Specified by:
createCollectionLikeDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createMapDeserializer

public JsonDeserializer<?> createMapDeserializer(DeserializationConfig config,
                                                 DeserializerProvider p,
                                                 MapType type,
                                                 BeanProperty property)
                                          throws JsonMappingException
Specified by:
createMapDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createMapLikeDeserializer

public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig config,
                                                     DeserializerProvider p,
                                                     MapLikeType type,
                                                     BeanProperty property)
                                              throws JsonMappingException
Specified by:
createMapLikeDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createEnumDeserializer

public JsonDeserializer<?> createEnumDeserializer(DeserializationConfig config,
                                                  DeserializerProvider p,
                                                  JavaType type,
                                                  BeanProperty property)
                                           throws JsonMappingException
Factory method for constructing serializers of Enum types.

Specified by:
createEnumDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createTreeDeserializer

public JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config,
                                                  DeserializerProvider p,
                                                  JavaType nodeType,
                                                  BeanProperty property)
                                           throws JsonMappingException
Description copied from class: DeserializerFactory
Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.

Specified by:
createTreeDeserializer in class DeserializerFactory
Throws:
JsonMappingException

findStdBeanDeserializer

protected JsonDeserializer<Object> findStdBeanDeserializer(DeserializationConfig config,
                                                           DeserializerProvider p,
                                                           JavaType type,
                                                           BeanProperty property)
                                                    throws JsonMappingException
Method called by BeanDeserializerFactory to see if there might be a standard deserializer registered for given type.

Throws:
JsonMappingException
Since:
1.8

findTypeDeserializer

public TypeDeserializer findTypeDeserializer(DeserializationConfig config,
                                             JavaType baseType,
                                             BeanProperty property)
Description copied from class: DeserializerFactory
Method called to find and create a type information deserializer for given base type, if one is needed. If not needed (no polymorphic handling configured for type), should return null.

Note that this method is usually only directly called for values of container (Collection, array, Map) types and root values, but not for bean property values.

Overrides:
findTypeDeserializer in class DeserializerFactory
baseType - Declared base type of the value to deserializer (actual deserializer type will be this type or its subtype)
Returns:
Type deserializer to use for given base type, if one is needed; null if not.

findPropertyTypeDeserializer

public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config,
                                                     JavaType baseType,
                                                     AnnotatedMember annotated,
                                                     BeanProperty property)
Method called to create a type information deserializer for values of given non-container property, if one is needed. If not needed (no polymorphic handling configured for property), should return null.

Note that this method is only called for non-container bean properties, and not for values in container types or root values (or container properties)

Parameters:
baseType - Declared base type of the value to deserializer (actual deserializer type will be this type or its subtype)
Returns:
Type deserializer to use for given base type, if one is needed; null if not.
Since:
1.5

findPropertyContentTypeDeserializer

public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config,
                                                            JavaType containerType,
                                                            AnnotatedMember propertyEntity,
                                                            BeanProperty property)
Method called to find and create a type information deserializer for values of given container (list, array, map) property, if one is needed. If not needed (no polymorphic handling configured for property), should return null.

Note that this method is only called for container bean properties, and not for values in container types or root values (or non-container properties)

Parameters:
containerType - Type of property; must be a container type
propertyEntity - Field or method that contains container property
Since:
1.5

mapAbstractType

protected abstract JavaType mapAbstractType(DeserializationConfig config,
                                            JavaType type)
                                     throws JsonMappingException
Throws:
JsonMappingException

findDeserializerFromAnnotation

protected JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationConfig config,
                                                                  Annotated ann,
                                                                  BeanProperty property)
                                                           throws JsonMappingException
Helper method called to check if a class or method has annotation that tells which class to use for deserialization. Returns null if no such annotation found.

Throws:
JsonMappingException

modifyTypeByAnnotation

protected <T extends JavaType> T modifyTypeByAnnotation(DeserializationConfig config,
                                                        Annotated a,
                                                        T type,
                                                        String propName)
                                             throws JsonMappingException
Method called to see if given method has annotations that indicate a more specific type than what the argument specifies. If annotations are present, they must specify compatible Class; instance of which can be assigned using the method. This means that the Class has to be raw class of type, or its sub-class (or, implementing class if original Class instance is an interface).

Parameters:
a - Method or field that the type is associated with
type - Type derived from the setter argument
propName - Name of property that refers to type, if any; null if no property information available (when modify type declaration of a class, for example)
Returns:
Original type if no annotations are present; or a more specific type derived from it if type annotation(s) was found
Throws:
JsonMappingException - if invalid annotation is found

resolveType

protected JavaType resolveType(DeserializationConfig config,
                               BasicBeanDescription beanDesc,
                               JavaType type,
                               AnnotatedMember member,
                               BeanProperty property)
Helper method used to resolve method return types and field types. The main trick here is that the containing bean may have type variable binding information (when deserializing using generic type passed as type reference), which is needed in some cases.

Starting with version 1.3, this method will also resolve instances of key and content deserializers if defined by annotations.


constructEnumResolver

protected EnumResolver<?> constructEnumResolver(Class<?> enumClass,
                                                DeserializationConfig config)

findMapCreators

protected CreatorContainer findMapCreators(DeserializationConfig config,
                                           BasicBeanDescription beanDesc)
                                    throws JsonMappingException
Method used to find non-default constructors and factory methods that are marked to be used as Creators for a Map type.

Throws:
JsonMappingException

constructCreatorProperty

protected SettableBeanProperty constructCreatorProperty(DeserializationConfig config,
                                                        BasicBeanDescription beanDesc,
                                                        String name,
                                                        int index,
                                                        AnnotatedParameter param)
                                                 throws JsonMappingException
Method that will construct a property object that represents a logical property passed via Creator (constructor or static factory method)

Throws:
JsonMappingException