Package com.fasterxml.jackson.databind
Class DatabindContext
- java.lang.Object
-
- com.fasterxml.jackson.databind.DatabindContext
-
- Direct Known Subclasses:
DeserializationContext,SerializerProvider
public abstract class DatabindContext extends java.lang.ObjectShared base class forDeserializationContextandSerializerProvider, 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
-
-
Constructor Summary
Constructors Constructor Description DatabindContext()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.String_colonConcat(java.lang.String msgBase, java.lang.String extra)protected java.lang.String_desc(java.lang.String desc)protected java.lang.String_format(java.lang.String msg, java.lang.Object... msgArgs)protected java.lang.String_quotedString(java.lang.String desc)protected java.lang.String_truncate(java.lang.String desc)abstract booleancanOverrideAccessModifiers()Convenience method for accessing serialization view in use (if any); equivalent to:JavaTypeconstructSpecializedType(JavaType baseType, java.lang.Class<?> subclass)Convenience method for constructing subtypes, retaining generic type parameter (if any)JavaTypeconstructType(java.lang.reflect.Type type)Convenience method for constructingJavaTypefor given JDK type (usuallyClass)Converter<java.lang.Object,java.lang.Object>converterInstance(Annotated annotated, java.lang.Object converterDef)Helper method to use to construct aConverter, given a definition that may be either actual converter instance, or Class for instantiating one.abstract java.lang.Class<?>getActiveView()Accessor for locating currently active view, if any; returns null if no view has been set.abstract AnnotationIntrospectorgetAnnotationIntrospector()Convenience method for accessing serialization view in use (if any); equivalent to:abstract java.lang.ObjectgetAttribute(java.lang.Object key)Method for accessing attributes available in this context.abstract MapperConfig<?>getConfig()Accessor to currently active configuration (both per-request configs and per-mapper config).abstract com.fasterxml.jackson.annotation.JsonFormat.ValuegetDefaultPropertyFormat(java.lang.Class<?> baseType)abstract java.util.LocalegetLocale()abstract java.util.TimeZonegetTimeZone()abstract TypeFactorygetTypeFactory()protected abstract JsonMappingExceptioninvalidTypeIdException(JavaType baseType, java.lang.String typeId, java.lang.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.abstract booleanisEnabled(MapperFeature feature)Convenience method for checking whether specified serialization feature is enabled or not.com.fasterxml.jackson.annotation.ObjectIdGenerator<?>objectIdGeneratorInstance(Annotated annotated, ObjectIdInfo objectIdInfo)com.fasterxml.jackson.annotation.ObjectIdResolverobjectIdResolverInstance(Annotated annotated, ObjectIdInfo objectIdInfo)abstract <T> TreportBadDefinition(JavaType type, java.lang.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 aInvalidDefinitionException.<T> TreportBadDefinition(java.lang.Class<?> type, java.lang.String msg)JavaTyperesolveSubType(JavaType baseType, java.lang.String subClass)Lookup method called when code needs to resolve class name from input; usually simple lookupabstract DatabindContextsetAttribute(java.lang.Object key, java.lang.Object value)Method for setting per-call value of given attribute.
-
-
-
Method Detail
-
getConfig
public abstract MapperConfig<?> getConfig()
Accessor to currently active configuration (both per-request configs and per-mapper config).
-
getAnnotationIntrospector
public abstract AnnotationIntrospector getAnnotationIntrospector()
Convenience method for accessing serialization view in use (if any); equivalent to:getConfig().getAnnotationIntrospector();
-
isEnabled
public abstract boolean isEnabled(MapperFeature feature)
Convenience method for checking whether specified serialization feature is enabled or not. Shortcut for:getConfig().isEnabled(feature);
-
canOverrideAccessModifiers
public abstract boolean canOverrideAccessModifiers()
Convenience method for accessing serialization view in use (if any); equivalent to:getConfig().canOverrideAccessModifiers();
-
getActiveView
public abstract java.lang.Class<?> getActiveView()
Accessor for locating currently active view, if any; returns null if no view has been set.
-
getLocale
public abstract java.util.Locale getLocale()
- Since:
- 2.6
-
getTimeZone
public abstract java.util.TimeZone getTimeZone()
- Since:
- 2.6
-
getDefaultPropertyFormat
public abstract com.fasterxml.jackson.annotation.JsonFormat.Value getDefaultPropertyFormat(java.lang.Class<?> baseType)
- Since:
- 2.7
-
getAttribute
public abstract java.lang.Object getAttribute(java.lang.Object key)
Method for accessing attributes available in this context. Per-call attributes have highest precedence; attributes set viaObjectReaderorObjectWriterhave lower precedence.- Parameters:
key- Key of the attribute to get- Returns:
- Value of the attribute, if any; null otherwise
- Since:
- 2.3
-
setAttribute
public abstract DatabindContext setAttribute(java.lang.Object key, java.lang.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- Key of the attribute to setvalue- Value to set attribute to- Returns:
- This context object, to allow chaining
- Since:
- 2.3
-
constructType
public JavaType constructType(java.lang.reflect.Type type)
Convenience method for constructingJavaTypefor given JDK type (usuallyClass)
-
constructSpecializedType
public JavaType constructSpecializedType(JavaType baseType, java.lang.Class<?> subclass)
Convenience method for constructing subtypes, retaining generic type parameter (if any)
-
resolveSubType
public JavaType resolveSubType(JavaType baseType, java.lang.String subClass) throws JsonMappingException
Lookup method called when code needs to resolve class name from input; usually simple lookup- Throws:
JsonMappingException- Since:
- 2.9
-
invalidTypeIdException
protected abstract JsonMappingException invalidTypeIdException(JavaType baseType, java.lang.String typeId, java.lang.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
-
getTypeFactory
public abstract TypeFactory getTypeFactory()
-
objectIdGeneratorInstance
public com.fasterxml.jackson.annotation.ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated, ObjectIdInfo objectIdInfo) throws JsonMappingException
- Throws:
JsonMappingException
-
objectIdResolverInstance
public com.fasterxml.jackson.annotation.ObjectIdResolver objectIdResolverInstance(Annotated annotated, ObjectIdInfo objectIdInfo)
-
converterInstance
public Converter<java.lang.Object,java.lang.Object> converterInstance(Annotated annotated, java.lang.Object converterDef) throws JsonMappingException
Helper method to use to construct aConverter, given a definition that may be either actual converter instance, or Class for instantiating one.- Throws:
JsonMappingException- Since:
- 2.2
-
reportBadDefinition
public abstract <T> T reportBadDefinition(JavaType type, java.lang.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 aInvalidDefinitionException.- Throws:
JsonMappingException- Since:
- 2.9
-
reportBadDefinition
public <T> T reportBadDefinition(java.lang.Class<?> type, java.lang.String msg) throws JsonMappingException- Throws:
JsonMappingException- Since:
- 2.9
-
_format
protected final java.lang.String _format(java.lang.String msg, java.lang.Object... msgArgs)- Since:
- 2.9
-
_truncate
protected final java.lang.String _truncate(java.lang.String desc)
- Since:
- 2.9
-
_quotedString
protected java.lang.String _quotedString(java.lang.String desc)
- Since:
- 2.9
-
_colonConcat
protected java.lang.String _colonConcat(java.lang.String msgBase, java.lang.String extra)- Since:
- 2.9
-
_desc
protected java.lang.String _desc(java.lang.String desc)
- Since:
- 2.9
-
-