Top Description Fields Constructors Methods
tools.jackson.databind

public abstract Class DatabindContext

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

Shared base class for DeserializationContext and SerializationContext, 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.

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();
protected abstract ClassIntrospector
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 PropertyName
public abstract PropertyName
findRootName(Class<?> rawRootType)

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
public final BeanDescription
introspectBeanDescription(JavaType type)

Convenience method for doing full "for serialization or deserialization" introspection of specified type; results may be cached for duration (lifespan) of this context as well.

public abstract BeanDescription
public AnnotatedClass
public AnnotatedClass
public AnnotatedClass
protected abstract DatabindException
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 final boolean
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 BeanDescription.Supplier
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 tools.jackson.databind.exc.InvalidDefinitionException.

public <T> T
public abstract <T> T
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.

Constructor Detail

DatabindContextback to summary
public DatabindContext()

Method Detail

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

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

   getConfig().canOverrideAccessModifiers();
classIntrospectorback to summary
protected abstract ClassIntrospector classIntrospector()
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)

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
findRootNameback to summary
public abstract PropertyName findRootName(JavaType rootType)
findRootNameback to summary
public abstract PropertyName findRootName(Class<?> rawRootType)
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

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)
getLocaleback to summary
public abstract Locale getLocale()
getTimeZoneback to summary
public abstract TimeZone getTimeZone()
getTypeFactoryback to summary
public abstract TypeFactory getTypeFactory()
introspectBeanDescriptionback to summary
public final BeanDescription introspectBeanDescription(JavaType type)

Convenience method for doing full "for serialization or deserialization" introspection of specified type; results may be cached for duration (lifespan) of this context as well.

introspectBeanDescriptionback to summary
public abstract BeanDescription introspectBeanDescription(JavaType type, AnnotatedClass classDef)
introspectClassAnnotationsback to summary
public AnnotatedClass introspectClassAnnotations(JavaType type)
introspectClassAnnotationsback to summary
public AnnotatedClass introspectClassAnnotations(Class<?> rawType)
introspectDirectClassAnnotationsback to summary
public AnnotatedClass introspectDirectClassAnnotations(JavaType type)
invalidTypeIdExceptionback to summary
protected abstract DatabindException 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.

isAnnotationProcessingEnabledback to summary
public final boolean isAnnotationProcessingEnabled()
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
lazyIntrospectBeanDescriptionback to summary
public BeanDescription.Supplier lazyIntrospectBeanDescription(JavaType type)
objectIdGeneratorInstanceback to summary
public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated, ObjectIdInfo objectIdInfo)
objectIdResolverInstanceback to summary
public ObjectIdResolver objectIdResolverInstance(Annotated annotated, ObjectIdInfo objectIdInfo)
reportBadDefinitionback to summary
public abstract <T> T reportBadDefinition(JavaType type, String msg) throws DatabindException

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 tools.jackson.databind.exc.InvalidDefinitionException.

reportBadDefinitionback to summary
public <T> T reportBadDefinition(Class<?> type, String msg) throws DatabindException
reportBadTypeDefinitionback to summary
public abstract <T> T reportBadTypeDefinition(BeanDescription bean, String msg, Object... msgArgs) throws DatabindException
reportBadTypeDefinitionback to summary
public <T> T reportBadTypeDefinition(BeanDescription.Supplier beanDescRef, String msg, Object... msgArgs) throws DatabindException
resolveAndValidateSubTypeback to summary
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.

resolveSubTypeback to summary
public JavaType resolveSubType(JavaType baseType, String subClassName)

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.

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