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.


Constructor Summary
protected BasicDeserializerFactory()
           
 
Method Summary
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)
 JsonDeserializer<?> createArrayDeserializer(DeserializationConfig config, ArrayType type, DeserializerProvider p)
          Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert Json content into values of specified Java type.
 JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config, JavaType type, DeserializerProvider p)
          Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert Json content into values of specified Java "bean" (POJO) type.
 JsonDeserializer<?> createCollectionDeserializer(DeserializationConfig config, CollectionType type, DeserializerProvider p)
           
 JsonDeserializer<?> createEnumDeserializer(DeserializationConfig config, Class<?> enumClass, DeserializerProvider p)
          Factory method for constructing serializers of Enum types.
 JsonDeserializer<?> createMapDeserializer(DeserializationConfig config, MapType type, DeserializerProvider p)
           
 JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, Class<? extends JsonNode> nodeClass, DeserializerProvider p)
          Method called to create and return a deserializer that can construct JsonNode(s) from Json content.
protected  JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationConfig config, Annotated a)
          Helper method called to check if a class or method has annotation that tells which class to use for deserialization.
protected
<T extends JavaType>
T
modifyTypeByAnnotation(DeserializationConfig config, Annotated a, T type)
          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, Type rawType, Annotated a)
          Helper method used to resolve method return types and field types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicDeserializerFactory

protected BasicDeserializerFactory()
Method Detail

createArrayDeserializer

public JsonDeserializer<?> createArrayDeserializer(DeserializationConfig config,
                                                   ArrayType type,
                                                   DeserializerProvider p)
                                            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
type - Type to be deserialized
p - Provider that can be called to create deserializers for contained member types
Throws:
JsonMappingException

createCollectionDeserializer

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

createMapDeserializer

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

createEnumDeserializer

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

Specified by:
createEnumDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createTreeDeserializer

public JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config,
                                                  Class<? extends JsonNode> nodeClass,
                                                  DeserializerProvider p)
                                           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

createBeanDeserializer

public JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config,
                                                       JavaType type,
                                                       DeserializerProvider p)
                                                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 "bean" (POJO) type. At this point it is known that the type is not otherwise recognized as one of structured types (array, Collection, Map) or a well-known JDK type (enum, primitives/wrappers, String); this method only gets called if other options are exhausted. This also means that this method can be overridden to add support for custom types.

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

findDeserializerFromAnnotation

protected JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationConfig config,
                                                                  Annotated a)
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.


modifyTypeByAnnotation

protected <T extends JavaType> T modifyTypeByAnnotation(DeserializationConfig config,
                                                        Annotated a,
                                                        T type)
                                             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
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,
                               Type rawType,
                               Annotated a)
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 instances of key and content deserializers if defined by annotations.


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