Top Description Fields Constructors Methods
com.fasterxml.jackson.databind

public abstract Class DatabindContext

extends Object
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.SerializerProvider
Imports
java.lang.reflect.Type, java.util.Locale, .TimeZone, com.fasterxml.jackson.annotation.*, com.fasterxml.jackson.databind.cfg.DatatypeFeature, .DatatypeFeatures, .HandlerInstantiator, .MapperConfig, com.fasterxml.jackson.databind.introspect.Annotated, .ObjectIdInfo, com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator, .PolymorphicTypeValidator.Validity, com.fasterxml.jackson.databind.type.TypeFactory, com.fasterxml.jackson.databind.util.ClassUtil, .Converter

Shared base class for DeserializationContext and SerializerProvider, context objects passed through data-binding process. Designed so that some of implementations can rely on shared aspects like access to secondary contextual objects like type factories or handler instantiators.
Since
2.2

Field Summary

Modifier and TypeField and Description
private static final int
MAX_ERROR_STR_LEN

Let's limit length of error messages, for cases where underlying data may be very large -- no point in spamming logs with megabytes of meaningless data.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
_colonConcat(String msgBase, String extra)

protected String
_desc(String desc)

protected final String
_format(String msg, Object... msgArgs)

protected String
private JavaType
protected <T> T
_throwNotASubtype(JavaType baseType, String subType)

protected <T> T
protected <T> T
protected final String
public abstract boolean
canOverrideAccessModifiers()

Convenience method for accessing serialization view in use (if any); equivalent to:

   getConfig().canOverrideAccessModifiers();
public abstract JavaType
constructSpecializedType(JavaType baseType, Class<?> subclass)

Convenience method for constructing subtypes, retaining generic type parameter (if any).

public JavaType
constructType(Type type)

Convenience method for constructing JavaType for given JDK type (usually java.lang.Class)

public Converter<Object, Object>
converterInstance(Annotated annotated, Object converterDef)

Helper method to use to construct a Converter, given a definition that may be either actual converter instance, or Class for instantiating one.

public abstract Class<?>
getActiveView()

Accessor for locating currently active view, if any; returns null if no view has been set.

public abstract AnnotationIntrospector
getAnnotationIntrospector()

Convenience method for accessing serialization view in use (if any); equivalent to:

   getConfig().getAnnotationIntrospector();
public abstract Object

Returns:

Value of the attribute, if any; null otherwise
getAttribute
(Object
Key of the attribute to get
key
)

Method for accessing attributes available in this context.

public abstract MapperConfig<?>
getConfig()

Accessor to currently active configuration (both per-request configs and per-mapper config).

public abstract DatatypeFeatures
public abstract JsonFormat.Value
public abstract Locale
public abstract TimeZone
public abstract TypeFactory
protected abstract JsonMappingException
invalidTypeIdException(JavaType baseType, String typeId, String extraDesc)

Helper method for constructing exception to indicate that given type id could not be resolved to a valid subtype of specified base type.

public abstract boolean
isEnabled(MapperFeature feature)

Convenience method for checking whether specified Mapper feature is enabled or not.

public abstract boolean
isEnabled(DatatypeFeature feature)

Method for checking whether specified datatype feature is enabled or not.

public ObjectIdGenerator<?>
public ObjectIdResolver
public abstract <T> T
reportBadDefinition(JavaType type, String msg)

Helper method called to indicate a generic problem that stems from type definition(s), not input data, or input/output state; typically this means throwing a com.fasterxml.jackson.databind.exc.InvalidDefinitionException.

public <T> T
public JavaType
resolveAndValidateSubType(JavaType baseType, String subClass, PolymorphicTypeValidator ptv)

Lookup method similar to resolveSubType but one that also validates that resulting subtype is valid according to given PolymorphicTypeValidator.

public JavaType
resolveSubType(JavaType baseType, String subClassName)

Lookup method called when code needs to resolve class name from input; usually simple lookup.

public abstract DatabindContext

Returns:

This context object, to allow chaining
setAttribute
(Object
Key of the attribute to set
key
,
Object
Value to set attribute to
value
)

Method for setting per-call value of given attribute.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_ERROR_STR_LENback to summary
private static final int MAX_ERROR_STR_LEN

Let's limit length of error messages, for cases where underlying data may be very large -- no point in spamming logs with megabytes of meaningless data.

Since
2.9

Constructor Detail

DatabindContextback to summary
public DatabindContext()

Method Detail

_colonConcatback to summary
protected String _colonConcat(String msgBase, String extra)
Since
2.9
_descback to summary
protected String _desc(String desc)
Since
2.9
_formatback to summary
protected final String _format(String msg, Object... msgArgs)
Since
2.9
_quotedStringback to summary
protected String _quotedString(String desc)
Since
2.9
_resolveAndValidateGenericback to summary
private JavaType _resolveAndValidateGeneric(JavaType baseType, String subClass, PolymorphicTypeValidator ptv, int ltIndex) throws JsonMappingException
_throwNotASubtypeback to summary
protected <T> T _throwNotASubtype(JavaType baseType, String subType) throws JsonMappingException
_throwSubtypeClassNotAllowedback to summary
protected <T> T _throwSubtypeClassNotAllowed(JavaType baseType, String subType, PolymorphicTypeValidator ptv) throws JsonMappingException
_throwSubtypeNameNotAllowedback to summary
protected <T> T _throwSubtypeNameNotAllowed(JavaType baseType, String subType, PolymorphicTypeValidator ptv) throws JsonMappingException
_truncateback to summary
protected final String _truncate(String desc)
Since
2.9
canOverrideAccessModifiersback to summary
public abstract boolean canOverrideAccessModifiers()

Convenience method for accessing serialization view in use (if any); equivalent to:

   getConfig().canOverrideAccessModifiers();
constructSpecializedTypeback to summary
public abstract JavaType constructSpecializedType(JavaType baseType, Class<?> subclass)

Convenience method for constructing subtypes, retaining generic type parameter (if any).

Note

since 2.11 handling has varied a bit across serialization, deserialization.

constructTypeback to summary
public JavaType constructType(Type type)

Convenience method for constructing JavaType for given JDK type (usually java.lang.Class)

converterInstanceback to summary
public Converter<Object, Object> converterInstance(Annotated annotated, Object converterDef) throws JsonMappingException

Helper method to use to construct a Converter, given a definition that may be either actual converter instance, or Class for instantiating one.

Annotations
@SuppressWarnings:unchecked
Since
2.2
getActiveViewback to summary
public abstract Class<?> getActiveView()

Accessor for locating currently active view, if any; returns null if no view has been set.

getAnnotationIntrospectorback to summary
public abstract AnnotationIntrospector getAnnotationIntrospector()

Convenience method for accessing serialization view in use (if any); equivalent to:

   getConfig().getAnnotationIntrospector();
getAttributeback to summary
public abstract Object getAttribute(Object key)

Method for accessing attributes available in this context. Per-call attributes have highest precedence; attributes set via ObjectReader or ObjectWriter have lower precedence.

Parameters
key:Object

Key of the attribute to get

Returns:Object

Value of the attribute, if any; null otherwise

Since
2.3
getConfigback to summary
public abstract MapperConfig<?> getConfig()

Accessor to currently active configuration (both per-request configs and per-mapper config).

getDatatypeFeaturesback to summary
public abstract DatatypeFeatures getDatatypeFeatures()
Since
2.15
getDefaultPropertyFormatback to summary
public abstract JsonFormat.Value getDefaultPropertyFormat(Class<?> baseType)
Since
2.7
getLocaleback to summary
public abstract Locale getLocale()
Since
2.6
getTimeZoneback to summary
public abstract TimeZone getTimeZone()
Since
2.6
getTypeFactoryback to summary
public abstract TypeFactory getTypeFactory()
invalidTypeIdExceptionback to summary
protected abstract JsonMappingException invalidTypeIdException(JavaType baseType, String typeId, String extraDesc)

Helper method for constructing exception to indicate that given type id could not be resolved to a valid subtype of specified base type. Most commonly called during polymorphic deserialization.

Note that most of the time this method should NOT be called directly: instead, method handleUnknownTypeId() should be called which will call this method if necessary.

Since
2.9
isEnabledback to summary
public abstract boolean isEnabled(MapperFeature feature)

Convenience method for checking whether specified Mapper feature is enabled or not. Shortcut for:

  getConfig().isEnabled(feature);
isEnabledback to summary
public abstract boolean isEnabled(DatatypeFeature feature)

Method for checking whether specified datatype feature is enabled or not.

Since
2.14
objectIdGeneratorInstanceback to summary
public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated, ObjectIdInfo objectIdInfo) throws JsonMappingException
objectIdResolverInstanceback to summary
public ObjectIdResolver objectIdResolverInstance(Annotated annotated, ObjectIdInfo objectIdInfo)
reportBadDefinitionback to summary
public abstract <T> T reportBadDefinition(JavaType type, String msg) throws JsonMappingException

Helper method called to indicate a generic problem that stems from type definition(s), not input data, or input/output state; typically this means throwing a com.fasterxml.jackson.databind.exc.InvalidDefinitionException.

Since
2.9
reportBadDefinitionback to summary
public <T> T reportBadDefinition(Class<?> type, String msg) throws JsonMappingException
Since
2.9
resolveAndValidateSubTypeback to summary
public JavaType resolveAndValidateSubType(JavaType baseType, String subClass, PolymorphicTypeValidator ptv) throws JsonMappingException

Lookup method similar to resolveSubType but one that also validates that resulting subtype is valid according to given PolymorphicTypeValidator.

Since
2.10
resolveSubTypeback to summary
public JavaType resolveSubType(JavaType baseType, String subClassName) throws JsonMappingException

Lookup method called when code needs to resolve class name from input; usually simple lookup. Note that unlike resolveAndValidateSubType this method DOES NOT validate subtype against configured PolymorphicTypeValidator: usually because such check has already been made.

Since
2.9
setAttributeback to summary
public abstract DatabindContext setAttribute(Object key, Object value)

Method for setting per-call value of given attribute. This will override any previously defined value for the attribute within this context.

Parameters
key:Object

Key of the attribute to set

value:Object

Value to set attribute to

Returns:DatabindContext

This context object, to allow chaining

Since
2.3