Class DeserializationConfig
- java.lang.Object
-
- org.codehaus.jackson.map.MapperConfig<T>
-
- org.codehaus.jackson.map.DeserializationConfig
-
- All Implemented Interfaces:
ClassIntrospector.MixInResolver
public class DeserializationConfig extends MapperConfig<T>
Object that contains baseline configuration for deserialization process. An instance is owned byObjectMapper
, which makes a copy that is passed during serialization process toDeserializerProvider
andDeserializerFactory
.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.
As of version 1.9, the goal is to make this class eventually immutable. Because of this, existing methods that allow changing state of this instance are deprecated in favor of methods that create new instances with different configuration ("fluent factories")
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DeserializationConfig.Feature
Enumeration that defines togglable features that guide the serialization feature.-
Nested classes/interfaces inherited from class org.codehaus.jackson.map.MapperConfig
MapperConfig.Base, MapperConfig.ConfigFeature
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_featureFlags
Note: moved to base class in 1.9; was stored by sub-class earlierprotected JsonNodeFactory
_nodeFactory
Factory used for constructingJsonNode
instances.protected LinkedNode<DeserializationProblemHandler>
_problemHandlers
Linked list that contains all registered problem handlers.protected boolean
_sortPropertiesAlphabetically
Feature flag fromSerializationConfig
which is needed to know if serializer will by default sort properties in alphabetic order.-
Fields inherited from class org.codehaus.jackson.map.MapperConfig
_base, _mixInAnnotations, _mixInAnnotationsShared, _subtypeResolver, DEFAULT_DATE_FORMAT
-
-
Constructor Summary
Constructors Modifier Constructor Description DeserializationConfig(ClassIntrospector<? extends BeanDescription> intr, AnnotationIntrospector annIntr, VisibilityChecker<?> vc, SubtypeResolver subtypeResolver, PropertyNamingStrategy propertyNamingStrategy, TypeFactory typeFactory, HandlerInstantiator handlerInstantiator)
Constructor used by ObjectMapper to create default configuration object instance.protected
DeserializationConfig(DeserializationConfig src)
protected
DeserializationConfig(DeserializationConfig src, int featureFlags)
protected
DeserializationConfig(DeserializationConfig src, MapperConfig.Base base)
protected
DeserializationConfig(DeserializationConfig src, JsonNodeFactory f)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addHandler(DeserializationProblemHandler h)
Method that can be used to add a handler that can (try to) resolve non-fatal deserialization problems.boolean
canOverrideAccessModifiers()
Accessor for determining whether it is ok to try to force override of access modifiers to be able to get or set values of non-public Methods, Fields; to invoke non-public Constructors, Methods; or to instantiate non-public Classes.void
clearHandlers()
Method for removing all configured problem handlers; usually done to replace existing handler(s) with different one(s)DeserializationConfig
createUnshared(SubtypeResolver subtypeResolver)
Method that is called to create a non-shared copy of the configuration to be used for a deserialization operation.JsonDeserializer<Object>
deserializerInstance(Annotated annotated, Class<? extends JsonDeserializer<?>> deserClass)
void
disable(DeserializationConfig.Feature f)
Deprecated.Since 1.9, it is preferable to usewithout(org.codehaus.jackson.map.DeserializationConfig.Feature...)
instead; this method is deprecated as it modifies current instance instead of creating a new one (as the goal is to make this class immutable)void
enable(DeserializationConfig.Feature f)
Deprecated.Since 1.9, it is preferable to usewith(org.codehaus.jackson.map.DeserializationConfig.Feature...)
instead; this method is deprecated as it modifies current instance instead of creating a new one (as the goal is to make this class immutable)void
fromAnnotations(Class<?> cls)
Deprecated.Since 1.9, it is preferably to explicitly configure instances; this method also modifies existing instance which is against immutable design goals of this class.AnnotationIntrospector
getAnnotationIntrospector()
Method for gettingAnnotationIntrospector
configured to introspect annotation values used for configuration.Base64Variant
getBase64Variant()
Method called during deserialization if Base64 encoded content needs to be decoded.VisibilityChecker<?>
getDefaultVisibilityChecker()
Accessor for object used for determining whether specific property elements (method, constructors, fields) can be auto-detected based on their visibility (access modifiers).JsonNodeFactory
getNodeFactory()
LinkedNode<DeserializationProblemHandler>
getProblemHandlers()
Method for getting head of the problem handler chain.<T extends BeanDescription>
Tintrospect(JavaType type)
Method that will introspect full bean properties for the purpose of building a bean deserializer<T extends BeanDescription>
TintrospectClassAnnotations(JavaType type)
Accessor for getting bean description that only contains class annotations: useful if no getter/setter/creator information is needed.<T extends BeanDescription>
TintrospectDirectClassAnnotations(JavaType type)
Accessor for getting bean description that only contains immediate class annotations: ones from the class, and its direct mix-in, if any, but not from super types.<T extends BeanDescription>
TintrospectForCreation(JavaType type)
Method that will introspect subset of bean properties needed to construct bean instance.boolean
isAnnotationProcessingEnabled()
Method for determining whether annotation processing is enabled or not (default settings are typically that it is enabled; must explicitly disable).boolean
isEnabled(DeserializationConfig.Feature f)
An overload forMapperConfig.isEnabled(MapperConfig.ConfigFeature)
, needed for backwards-compatibility.boolean
isEnabled(MapperConfig.ConfigFeature f)
Method for checking whether given feature is enabled or notKeyDeserializer
keyDeserializerInstance(Annotated annotated, Class<? extends KeyDeserializer> keyDeserClass)
protected DeserializationConfig
passSerializationFeatures(int serializationFeatureFlags)
Helper method to be called right after creating a non-shared instance, needed to pass state of feature(s) shared with SerializationConfig.void
set(DeserializationConfig.Feature f, boolean state)
Deprecated.Since 1.9, it is preferable to usewithout(org.codehaus.jackson.map.DeserializationConfig.Feature...)
andwith(org.codehaus.jackson.map.DeserializationConfig.Feature...)
instead; this method is deprecated as it modifies current instance instead of creating a new one (as the goal is to make this class immutable)boolean
shouldSortPropertiesAlphabetically()
Accessor for checking whether default settings for property handling indicate that properties should be alphabetically ordered or not.ValueInstantiator
valueInstantiatorInstance(Annotated annotated, Class<? extends ValueInstantiator> instClass)
DeserializationConfig
with(DeserializationConfig.Feature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.DeserializationConfig
withAnnotationIntrospector(AnnotationIntrospector ai)
Method for constructing and returning a new instance with differentAnnotationIntrospector
to use (replacing old one).DeserializationConfig
withAppendedAnnotationIntrospector(AnnotationIntrospector ai)
Method for constructing and returning a new instance with additionalAnnotationIntrospector
appended (as the lowest priority one)DeserializationConfig
withClassIntrospector(ClassIntrospector<? extends BeanDescription> ci)
Method for constructing and returning a new instance with differentClassIntrospector
to use.DeserializationConfig
withDateFormat(DateFormat df)
Method for constructing and returning a new instance with differentDateFormat
to use.DeserializationConfig
withHandlerInstantiator(HandlerInstantiator hi)
Method for constructing and returning a new instance with differentHandlerInstantiator
to use.DeserializationConfig
withInsertedAnnotationIntrospector(AnnotationIntrospector ai)
Method for constructing and returning a new instance with additionalAnnotationIntrospector
inserted (as the highest priority one)DeserializationConfig
withNodeFactory(JsonNodeFactory f)
Fluent factory method that will construct a new instance with specifiedJsonNodeFactory
DeserializationConfig
without(DeserializationConfig.Feature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.DeserializationConfig
withPropertyNamingStrategy(PropertyNamingStrategy pns)
Method for constructing and returning a new instance with differentPropertyNamingStrategy
to use.DeserializationConfig
withSubtypeResolver(SubtypeResolver str)
Method for constructing and returning a new instance with differentSubtypeResolver
to use.DeserializationConfig
withTypeFactory(TypeFactory tf)
Method for constructing and returning a new instance with differentTypeFactory
to use.DeserializationConfig
withTypeResolverBuilder(TypeResolverBuilder<?> trb)
Method for constructing and returning a new instance with differentTypeResolverBuilder
to use.DeserializationConfig
withVisibility(JsonMethod forMethod, JsonAutoDetect.Visibility visibility)
Method for constructing and returning a new instance with different minimal visibility level for specified property typeDeserializationConfig
withVisibilityChecker(VisibilityChecker<?> vc)
Method for constructing and returning a new instance with differentVisibilityChecker
to use.-
Methods inherited from class org.codehaus.jackson.map.MapperConfig
addMixInAnnotations, appendAnnotationIntrospector, constructSpecializedType, constructType, constructType, findMixInClassFor, getClassIntrospector, getDateFormat, getDefaultTyper, getHandlerInstantiator, getPropertyNamingStrategy, getSubtypeResolver, getTypeFactory, insertAnnotationIntrospector, introspectClassAnnotations, introspectDirectClassAnnotations, mixInCount, setAnnotationIntrospector, setDateFormat, setMixInAnnotations, typeIdResolverInstance, typeResolverBuilderInstance
-
-
-
-
Field Detail
-
_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.
-
_nodeFactory
protected final JsonNodeFactory _nodeFactory
Factory used for constructingJsonNode
instances.- Since:
- 1.6
-
_sortPropertiesAlphabetically
protected boolean _sortPropertiesAlphabetically
Feature flag fromSerializationConfig
which is needed to know if serializer will by default sort properties in alphabetic order.Note that although this property is not marked as final, it is handled like it was, except for the fact that it is assigned with a call to
passSerializationFeatures(int)
instead of constructor.- Since:
- 1.9
-
_featureFlags
protected int _featureFlags
Note: moved to base class in 1.9; was stored by sub-class earlier
-
-
Constructor Detail
-
DeserializationConfig
public DeserializationConfig(ClassIntrospector<? extends BeanDescription> intr, AnnotationIntrospector annIntr, VisibilityChecker<?> vc, SubtypeResolver subtypeResolver, PropertyNamingStrategy propertyNamingStrategy, TypeFactory typeFactory, HandlerInstantiator handlerInstantiator)
Constructor used by ObjectMapper to create default configuration object instance.
-
DeserializationConfig
protected DeserializationConfig(DeserializationConfig src)
- Since:
- 1.8
-
DeserializationConfig
protected DeserializationConfig(DeserializationConfig src, MapperConfig.Base base)
- Since:
- 1.8
-
DeserializationConfig
protected DeserializationConfig(DeserializationConfig src, JsonNodeFactory f)
- Since:
- 1.8
-
DeserializationConfig
protected DeserializationConfig(DeserializationConfig src, int featureFlags)
- Since:
- 1.9
-
-
Method Detail
-
passSerializationFeatures
protected DeserializationConfig passSerializationFeatures(int serializationFeatureFlags)
Helper method to be called right after creating a non-shared instance, needed to pass state of feature(s) shared with SerializationConfig. Since 1.9
-
withClassIntrospector
public DeserializationConfig withClassIntrospector(ClassIntrospector<? extends BeanDescription> ci)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentClassIntrospector
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withClassIntrospector
in classMapperConfig<DeserializationConfig>
-
withAnnotationIntrospector
public DeserializationConfig withAnnotationIntrospector(AnnotationIntrospector ai)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentAnnotationIntrospector
to use (replacing old one).NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withAnnotationIntrospector
in classMapperConfig<DeserializationConfig>
-
withVisibilityChecker
public DeserializationConfig withVisibilityChecker(VisibilityChecker<?> vc)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentVisibilityChecker
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withVisibilityChecker
in classMapperConfig<DeserializationConfig>
-
withVisibility
public DeserializationConfig withVisibility(JsonMethod forMethod, JsonAutoDetect.Visibility visibility)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with different minimal visibility level for specified property typeNOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withVisibility
in classMapperConfig<DeserializationConfig>
-
withTypeResolverBuilder
public DeserializationConfig withTypeResolverBuilder(TypeResolverBuilder<?> trb)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentTypeResolverBuilder
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withTypeResolverBuilder
in classMapperConfig<DeserializationConfig>
-
withSubtypeResolver
public DeserializationConfig withSubtypeResolver(SubtypeResolver str)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentSubtypeResolver
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withSubtypeResolver
in classMapperConfig<DeserializationConfig>
-
withPropertyNamingStrategy
public DeserializationConfig withPropertyNamingStrategy(PropertyNamingStrategy pns)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentPropertyNamingStrategy
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withPropertyNamingStrategy
in classMapperConfig<DeserializationConfig>
-
withTypeFactory
public DeserializationConfig withTypeFactory(TypeFactory tf)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentTypeFactory
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withTypeFactory
in classMapperConfig<DeserializationConfig>
-
withDateFormat
public DeserializationConfig withDateFormat(DateFormat df)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentDateFormat
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withDateFormat
in classMapperConfig<DeserializationConfig>
-
withHandlerInstantiator
public DeserializationConfig withHandlerInstantiator(HandlerInstantiator hi)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with differentHandlerInstantiator
to use.NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method.- Specified by:
withHandlerInstantiator
in classMapperConfig<DeserializationConfig>
-
withInsertedAnnotationIntrospector
public DeserializationConfig withInsertedAnnotationIntrospector(AnnotationIntrospector ai)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with additionalAnnotationIntrospector
inserted (as the highest priority one)- Specified by:
withInsertedAnnotationIntrospector
in classMapperConfig<DeserializationConfig>
-
withAppendedAnnotationIntrospector
public DeserializationConfig withAppendedAnnotationIntrospector(AnnotationIntrospector ai)
Description copied from class:MapperConfig
Method for constructing and returning a new instance with additionalAnnotationIntrospector
appended (as the lowest priority one)- Specified by:
withAppendedAnnotationIntrospector
in classMapperConfig<DeserializationConfig>
-
withNodeFactory
public DeserializationConfig withNodeFactory(JsonNodeFactory f)
Fluent factory method that will construct a new instance with specifiedJsonNodeFactory
- Since:
- 1.8
-
with
public DeserializationConfig with(DeserializationConfig.Feature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.- Since:
- 1.9
-
without
public DeserializationConfig without(DeserializationConfig.Feature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.- Since:
- 1.9
-
fromAnnotations
@Deprecated public void fromAnnotations(Class<?> cls)
Deprecated.Since 1.9, it is preferably to explicitly configure instances; this method also modifies existing instance which is against immutable design goals of this class.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 classMapperConfig<DeserializationConfig>
- Parameters:
cls
- Class of which class annotations to use for changing configuration settings
-
createUnshared
public DeserializationConfig createUnshared(SubtypeResolver subtypeResolver)
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 classMapperConfig<DeserializationConfig>
-
getAnnotationIntrospector
public AnnotationIntrospector getAnnotationIntrospector()
Method for gettingAnnotationIntrospector
configured to introspect annotation values used for configuration.- Overrides:
getAnnotationIntrospector
in classMapperConfig<DeserializationConfig>
-
introspectClassAnnotations
public <T extends BeanDescription> T introspectClassAnnotations(JavaType type)
Accessor for getting bean description that only contains class annotations: useful if no getter/setter/creator information is needed.Note: part of
MapperConfig
since 1.7- Specified by:
introspectClassAnnotations
in classMapperConfig<DeserializationConfig>
-
introspectDirectClassAnnotations
public <T extends BeanDescription> T introspectDirectClassAnnotations(JavaType type)
Accessor for getting bean description that only contains immediate class annotations: ones from the class, and its direct mix-in, if any, but not from super types.Note: part of
MapperConfig
since 1.7- Specified by:
introspectDirectClassAnnotations
in classMapperConfig<DeserializationConfig>
-
isAnnotationProcessingEnabled
public boolean isAnnotationProcessingEnabled()
Description copied from class:MapperConfig
Method for determining whether annotation processing is enabled or not (default settings are typically that it is enabled; must explicitly disable).- Specified by:
isAnnotationProcessingEnabled
in classMapperConfig<DeserializationConfig>
- Returns:
- True if annotation processing is enabled; false if not
-
canOverrideAccessModifiers
public boolean canOverrideAccessModifiers()
Description copied from class:MapperConfig
Accessor for determining whether it is ok to try to force override of access modifiers to be able to get or set values of non-public Methods, Fields; to invoke non-public Constructors, Methods; or to instantiate non-public Classes. By default this is enabled, but on some platforms it needs to be prevented since if this would violate security constraints and cause failures.- Specified by:
canOverrideAccessModifiers
in classMapperConfig<DeserializationConfig>
- Returns:
- True if access modifier overriding is allowed (and may be done for any Field, Method, Constructor or Class); false to prevent any attempts to override.
-
shouldSortPropertiesAlphabetically
public boolean shouldSortPropertiesAlphabetically()
Description copied from class:MapperConfig
Accessor for checking whether default settings for property handling indicate that properties should be alphabetically ordered or not.- Specified by:
shouldSortPropertiesAlphabetically
in classMapperConfig<DeserializationConfig>
-
getDefaultVisibilityChecker
public VisibilityChecker<?> getDefaultVisibilityChecker()
Description copied from class:MapperConfig
Accessor for object used for determining whether specific property elements (method, constructors, fields) can be auto-detected based on their visibility (access modifiers). Can be changed to allow different minimum visibility levels for auto-detection. Note that this is the global handler; individual types (classes) can further override active checker used (usingJsonAutoDetect
annotation)- Overrides:
getDefaultVisibilityChecker
in classMapperConfig<DeserializationConfig>
-
isEnabled
public boolean isEnabled(DeserializationConfig.Feature f)
An overload forMapperConfig.isEnabled(MapperConfig.ConfigFeature)
, needed for backwards-compatibility.NOTE: will remove either this variant, or base class one, in 2.0./
- Since:
- 1.0 However, note that version 1.9.0 and 1.9.1 accidentally missed this overloaded variant
-
enable
@Deprecated public void enable(DeserializationConfig.Feature f)
Deprecated.Since 1.9, it is preferable to usewith(org.codehaus.jackson.map.DeserializationConfig.Feature...)
instead; this method is deprecated as it modifies current instance instead of creating a new one (as the goal is to make this class immutable)Method for enabling specified feature.
-
disable
@Deprecated public void disable(DeserializationConfig.Feature f)
Deprecated.Since 1.9, it is preferable to usewithout(org.codehaus.jackson.map.DeserializationConfig.Feature...)
instead; this method is deprecated as it modifies current instance instead of creating a new one (as the goal is to make this class immutable)Method for disabling specified feature.
-
set
@Deprecated public void set(DeserializationConfig.Feature f, boolean state)
Deprecated.Since 1.9, it is preferable to usewithout(org.codehaus.jackson.map.DeserializationConfig.Feature...)
andwith(org.codehaus.jackson.map.DeserializationConfig.Feature...)
instead; this method is deprecated as it modifies current instance instead of creating a new one (as the goal is to make this class immutable)Method for enabling or disabling specified feature.
-
getProblemHandlers
public LinkedNode<DeserializationProblemHandler> getProblemHandlers()
Method for getting head of the problem handler chain. May be null, if no handlers have been added.
-
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 configured problem handlers; usually done to replace existing handler(s) with different one(s)- Since:
- 1.1
-
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).
-
getNodeFactory
public final JsonNodeFactory getNodeFactory()
- Since:
- 1.6
-
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(JavaType type)
Method that will introspect subset of bean properties needed to construct bean instance.
-
deserializerInstance
public JsonDeserializer<Object> deserializerInstance(Annotated annotated, Class<? extends JsonDeserializer<?>> deserClass)
-
keyDeserializerInstance
public KeyDeserializer keyDeserializerInstance(Annotated annotated, Class<? extends KeyDeserializer> keyDeserClass)
-
valueInstantiatorInstance
public ValueInstantiator valueInstantiatorInstance(Annotated annotated, Class<? extends ValueInstantiator> instClass)
-
isEnabled
public boolean isEnabled(MapperConfig.ConfigFeature f)
Description copied from class:MapperConfig
Method for checking whether given feature is enabled or not- Specified by:
isEnabled
in classMapperConfig<T extends org.codehaus.jackson.map.MapperConfig.Impl<CFG,T>>
-
-