org.codehaus.jackson.map.deser
Class StdDeserializerProvider

java.lang.Object
  extended by org.codehaus.jackson.map.DeserializerProvider
      extended by org.codehaus.jackson.map.deser.StdDeserializerProvider

public class StdDeserializerProvider
extends DeserializerProvider

Default DeserializerProvider implementation. Handles low-level caching (non-root) aspects of deserializer handling; all construction details are delegated to configured DeserializerFactory instance that the provider owns.


Field Summary
protected  ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _cachedDeserializers
          We will also cache some dynamically constructed deserializers; specifically, ones that are expensive to construct.
 
Constructor Summary
StdDeserializerProvider()
          Default constructor.
StdDeserializerProvider(DeserializerFactory f)
           
 
Method Summary
protected  JsonDeserializer<Object> _createAndCacheValueDeserializer(DeserializationConfig config, JavaType type, JavaType referrer, String refPropName)
          Method that will try to create a deserializer for given type, and resolve and cache it if necessary
protected  JsonDeserializer<Object> _createDeserializer(DeserializationConfig config, JavaType type, JavaType referrer, String refPropName)
           
protected  JsonDeserializer<Object> _findCachedDeserializer(JavaType type)
           
protected  KeyDeserializer _handleUnknownKeyDeserializer(JavaType type)
           
protected  JsonDeserializer<Object> _handleUnknownValueDeserializer(JavaType type)
           
protected  void _resolveDeserializer(DeserializationConfig config, ResolvableDeserializer ser)
           
 KeyDeserializer findKeyDeserializer(DeserializationConfig config, JavaType type)
          Method called to get hold of a deserializer to use for deserializing keys for Map.
 JsonDeserializer<Object> findValueDeserializer(DeserializationConfig config, JavaType type, JavaType referrer, String refPropName)
          Method called to get hold of a deserializer for a value of given type; or if no such deserializer can be found, a default handler (which may do a best-effort generic serialization or just simply throw an exception when invoked).
 boolean hasValueDeserializerFor(DeserializationConfig config, JavaType type)
          Method that can be called to find out whether a deserializer can be found for given type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_cachedDeserializers

protected final ConcurrentHashMap<JavaType,JsonDeserializer<Object>> _cachedDeserializers
We will also cache some dynamically constructed deserializers; specifically, ones that are expensive to construct. This currently means bean and Enum deserializers; array, List and Map deserializers will not be cached.

Given that we don't expect much concurrency for additions (should very quickly converge to zero after startup), let's explicitly define a low concurrency setting.

Constructor Detail

StdDeserializerProvider

public StdDeserializerProvider()
Default constructor. Equivalent to calling
   new StdDeserializerProvider(BeanDeserializerFactory.instance);


StdDeserializerProvider

public StdDeserializerProvider(DeserializerFactory f)
Method Detail

findValueDeserializer

public JsonDeserializer<Object> findValueDeserializer(DeserializationConfig config,
                                                      JavaType type,
                                                      JavaType referrer,
                                                      String refPropName)
                                               throws JsonMappingException
Description copied from class: DeserializerProvider
Method called to get hold of a deserializer for a value of given type; or if no such deserializer can be found, a default handler (which may do a best-effort generic serialization or just simply throw an exception when invoked).

Note: this method is only called for value types; not for keys. Key deserializers can be accessed using DeserializerProvider.findKeyDeserializer(org.codehaus.jackson.map.DeserializationConfig, org.codehaus.jackson.type.JavaType).

Specified by:
findValueDeserializer in class DeserializerProvider
type - Declared type of the value to deserializer (obtained using 'setter' method signature and/or type annotations
referrer - Type that contains the value, if any: null for root-level object.
refPropName - Logical name of the property within instance of referrer, if through a property (field). Null for Collection and Array types, where reference is not through a field, as well as for "any property" fallback references
Throws:
JsonMappingException - if there are fatal problems with accessing suitable deserializer; including that of not finding any serializer

findKeyDeserializer

public KeyDeserializer findKeyDeserializer(DeserializationConfig config,
                                           JavaType type)
                                    throws JsonMappingException
Description copied from class: DeserializerProvider
Method called to get hold of a deserializer to use for deserializing keys for Map.

Specified by:
findKeyDeserializer in class DeserializerProvider
Throws:
JsonMappingException - if there are fatal problems with accessing suitable key deserializer; including that of not finding any serializer

hasValueDeserializerFor

public boolean hasValueDeserializerFor(DeserializationConfig config,
                                       JavaType type)
Method that can be called to find out whether a deserializer can be found for given type

Specified by:
hasValueDeserializerFor in class DeserializerProvider

_findCachedDeserializer

protected JsonDeserializer<Object> _findCachedDeserializer(JavaType type)

_createAndCacheValueDeserializer

protected JsonDeserializer<Object> _createAndCacheValueDeserializer(DeserializationConfig config,
                                                                    JavaType type,
                                                                    JavaType referrer,
                                                                    String refPropName)
                                                             throws JsonMappingException
Method that will try to create a deserializer for given type, and resolve and cache it if necessary

Throws:
JsonMappingException

_createDeserializer

protected JsonDeserializer<Object> _createDeserializer(DeserializationConfig config,
                                                       JavaType type,
                                                       JavaType referrer,
                                                       String refPropName)
                                                throws JsonMappingException
Throws:
JsonMappingException

_resolveDeserializer

protected void _resolveDeserializer(DeserializationConfig config,
                                    ResolvableDeserializer ser)
                             throws JsonMappingException
Throws:
JsonMappingException

_handleUnknownValueDeserializer

protected JsonDeserializer<Object> _handleUnknownValueDeserializer(JavaType type)
                                                            throws JsonMappingException
Throws:
JsonMappingException

_handleUnknownKeyDeserializer

protected KeyDeserializer _handleUnknownKeyDeserializer(JavaType type)
                                                 throws JsonMappingException
Throws:
JsonMappingException