org.codehaus.jackson.map
Class DeserializationConfig

java.lang.Object
  extended by org.codehaus.jackson.map.DeserializationConfig
All Implemented Interfaces:
ClassIntrospector.MixInResolver, MapperConfig

public class DeserializationConfig
extends Object
implements MapperConfig

Object that contains baseline configuration for deserialization process. An instance is owned by ObjectMapper, which makes a copy that is passed during serialization process to DeserializerProvider and DeserializerFactory.

Note: although configuration settings can be changed at any time (for factories and instances), they are not guaranteed to have effect if called after constructing relevant mapper or deserializer instance. This because some objects may be configured, constructed and cached first time they are needed.


Nested Class Summary
static class DeserializationConfig.Feature
          Enumeration that defines togglable features that guide the serialization feature.
 
Field Summary
protected  AnnotationIntrospector _annotationIntrospector
          Introspector used for accessing annotation value based configuration.
protected  ClassIntrospector<? extends BeanDescription> _classIntrospector
          Introspector used to figure out Bean properties needed for bean serialization and deserialization.
protected  DateFormat _dateFormat
          Custom date format to use for de-serialization.
protected  int _featureFlags
          Bitset that contains all enabled features
protected  boolean _mixInAnnotationsShared
          Flag used to detect when a copy if mix-in annotations is needed: set when current copy is shared, cleared when a fresh copy is maed
protected  LinkedNode<DeserializationProblemHandler> _problemHandlers
          Linked list that contains all registered problem handlers.
protected static DateFormat DEFAULT_DATE_FORMAT
           
protected static int DEFAULT_FEATURE_FLAGS
          Bitfield (set of flags) of all Features that are enabled by default.
 
Constructor Summary
  DeserializationConfig(ClassIntrospector<? extends BeanDescription> intr, AnnotationIntrospector annIntr)
           
protected DeserializationConfig(DeserializationConfig src, HashMap<ClassKey,Class<?>> mixins)
           
 
Method Summary
 void addHandler(DeserializationProblemHandler h)
          Method that can be used to add a handler that can (try to) resolve non-fatal deserialization problems.
 void addMixInAnnotations(Class<?> target, Class<?> mixinSource)
          Method to use for adding mix-in annotations to use for augmenting specified class or interface.
 void clearHandlers()
          Method for removing all configuring problem handlers; usually done to replace existing handler(s) with different one(s)
 DeserializationConfig createUnshared()
          Method that is called to create a non-shared copy of the configuration to be used for a deserialization operation.
 void disable(DeserializationConfig.Feature f)
          Method for disabling specified feature.
 void enable(DeserializationConfig.Feature f)
          Method for enabling specified feature.
 Class<?> findMixInClassFor(Class<?> cls)
          Method that will check if there are "mix-in" classes (with mix-in annotations) for given class
 void fromAnnotations(Class<?> cls)
          Method that checks class annotations that the argument Object has, and modifies settings of this configuration object accordingly, similar to how those annotations would affect actual value classes annotated with them, but with global scope.
 AnnotationIntrospector getAnnotationIntrospector()
          Method for getting AnnotationIntrospector configured to introspect annotation values used for configuration.
 Base64Variant getBase64Variant()
          Method called during deserialization if Base64 encoded content needs to be decoded.
 DateFormat getDateFormat()
           
 LinkedNode<DeserializationProblemHandler> getProblemHandlers()
          Method for getting head of the problem handler chain.
<T extends BeanDescription>
T
introspect(JavaType type)
          Method that will introspect full bean properties for the purpose of building a bean deserializer
<T extends BeanDescription>
T
introspectClassAnnotations(Class<?> cls)
          Accessor for getting bean description that only contains class annotations: useful if no getter/setter/creator information is needed.
<T extends BeanDescription>
T
introspectForCreation(Class<?> cls)
          Method that will introspect subset of bean properties needed to construct bean instance.
 boolean isEnabled(DeserializationConfig.Feature f)
          Method for checking whether given feature is enabled or not
 void set(DeserializationConfig.Feature f, boolean state)
          Method for enabling or disabling specified feature.
 void setAnnotationIntrospector(AnnotationIntrospector introspector)
           
 void setDateFormat(DateFormat df)
          Method that will set the textual deserialization to use for deserializing Dates (and Calendars).
 void setIntrospector(ClassIntrospector<? extends BeanDescription> i)
           
 void setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
          Method to use for defining mix-in annotations to use for augmenting annotations that deserializable classes have.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FEATURE_FLAGS

protected static final int DEFAULT_FEATURE_FLAGS
Bitfield (set of flags) of all Features that are enabled by default.


DEFAULT_DATE_FORMAT

protected static final DateFormat DEFAULT_DATE_FORMAT

_classIntrospector

protected ClassIntrospector<? extends BeanDescription> _classIntrospector
Introspector used to figure out Bean properties needed for bean serialization and deserialization. Overridable so that it is possible to change low-level details of introspection, like adding new annotation types.


_annotationIntrospector

protected AnnotationIntrospector _annotationIntrospector
Introspector used for accessing annotation value based configuration.


_featureFlags

protected int _featureFlags
Bitset that contains all enabled features


_problemHandlers

protected LinkedNode<DeserializationProblemHandler> _problemHandlers
Linked list that contains all registered problem handlers. Implementation as front-added linked list allows for sharing of the list (tail) without copying the list.


_dateFormat

protected DateFormat _dateFormat
Custom date format to use for de-serialization. If specified, will be used instead of StdDateFormat.

Note that the configured format object will be cloned once per deserialization process (first time it is needed)


_mixInAnnotationsShared

protected boolean _mixInAnnotationsShared
Flag used to detect when a copy if mix-in annotations is needed: set when current copy is shared, cleared when a fresh copy is maed

Since:
1.2
Constructor Detail

DeserializationConfig

public DeserializationConfig(ClassIntrospector<? extends BeanDescription> intr,
                             AnnotationIntrospector annIntr)

DeserializationConfig

protected DeserializationConfig(DeserializationConfig src,
                                HashMap<ClassKey,Class<?>> mixins)
Method Detail

fromAnnotations

public void fromAnnotations(Class<?> cls)
Method that checks class annotations that the argument Object has, and modifies settings of this configuration object accordingly, similar to how those annotations would affect actual value classes annotated with them, but with global scope. Note that not all annotations have global significance, and thus only subset of Jackson annotations will have any effect.

Ones that are known to have effect are:

Specified by:
fromAnnotations in interface MapperConfig
Parameters:
cls - Class of which class annotations to use for changing configuration settings

createUnshared

public DeserializationConfig createUnshared()
Method that is called to create a non-shared copy of the configuration to be used for a deserialization operation. Note that if sub-classing and sub-class has additional instance methods, this method must be overridden to produce proper sub-class instance.

Specified by:
createUnshared in interface MapperConfig

setIntrospector

public void setIntrospector(ClassIntrospector<? extends BeanDescription> i)
Specified by:
setIntrospector in interface MapperConfig

getAnnotationIntrospector

public AnnotationIntrospector getAnnotationIntrospector()
Method for getting AnnotationIntrospector configured to introspect annotation values used for configuration.

Specified by:
getAnnotationIntrospector in interface MapperConfig

setAnnotationIntrospector

public void setAnnotationIntrospector(AnnotationIntrospector introspector)
Specified by:
setAnnotationIntrospector in interface MapperConfig

setMixInAnnotations

public void setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
Method to use for defining mix-in annotations to use for augmenting annotations that deserializable classes have. Mixing in is done when introspecting class annotations and properties. Map passed contains keys that are target classes (ones to augment with new annotation overrides), and values that are source classes (have annotations to use for augmentation). Annotations from source classes (and their supertypes) will override annotations that target classes (and their super-types) have.

Note: a copy of argument Map is created; the original Map is not modified or retained by this config object.

Specified by:
setMixInAnnotations in interface MapperConfig
Since:
1.2

addMixInAnnotations

public void addMixInAnnotations(Class<?> target,
                                Class<?> mixinSource)
Description copied from interface: MapperConfig
Method to use for adding mix-in annotations to use for augmenting specified class or interface. All annotations from mixinSource are taken to override annotations that target (or its supertypes) has.

Specified by:
addMixInAnnotations in interface MapperConfig
Parameters:
target - Class (or interface) whose annotations to effectively override
mixinSource - Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary

findMixInClassFor

public Class<?> findMixInClassFor(Class<?> cls)
Description copied from interface: MapperConfig
Method that will check if there are "mix-in" classes (with mix-in annotations) for given class

Specified by:
findMixInClassFor in interface ClassIntrospector.MixInResolver
Specified by:
findMixInClassFor in interface MapperConfig
Since:
1.2

addHandler

public void addHandler(DeserializationProblemHandler h)
Method that can be used to add a handler that can (try to) resolve non-fatal deserialization problems.


clearHandlers

public void clearHandlers()
Method for removing all configuring problem handlers; usually done to replace existing handler(s) with different one(s)

Since:
1.1

isEnabled

public final boolean isEnabled(DeserializationConfig.Feature f)
Method for checking whether given feature is enabled or not


getBase64Variant

public Base64Variant getBase64Variant()
Method called during deserialization if Base64 encoded content needs to be decoded. Default version just returns default Jackson uses, which is modified-mime which does not add linefeeds (because those would have to be escaped in Json strings).


getProblemHandlers

public LinkedNode<DeserializationProblemHandler> getProblemHandlers()
Method for getting head of the problem handler chain. May be null, if no handlers have been added.


getDateFormat

public DateFormat getDateFormat()

introspect

public <T extends BeanDescription> T introspect(JavaType type)
Method that will introspect full bean properties for the purpose of building a bean deserializer

Parameters:
type - Type of class to be introspected

introspectForCreation

public <T extends BeanDescription> T introspectForCreation(Class<?> cls)
Method that will introspect subset of bean properties needed to construct bean instance.


introspectClassAnnotations

public <T extends BeanDescription> T introspectClassAnnotations(Class<?> cls)
Accessor for getting bean description that only contains class annotations: useful if no getter/setter/creator information is needed.


enable

public void enable(DeserializationConfig.Feature f)
Method for enabling specified feature.


disable

public void disable(DeserializationConfig.Feature f)
Method for disabling specified feature.


set

public void set(DeserializationConfig.Feature f,
                boolean state)
Method for enabling or disabling specified feature.


setDateFormat

public void setDateFormat(DateFormat df)
Method that will set the textual deserialization to use for deserializing Dates (and Calendars). If null is passed, will use StdDateFormat.