Class DatabindContext

  • Direct Known Subclasses:
    DeserializationContext, SerializerProvider

    public abstract class DatabindContext
    extends java.lang.Object
    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
    • Constructor Detail

      • DatabindContext

        public DatabindContext()
    • 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 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 via ObjectReader or ObjectWriter have 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 set
        value - 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 constructing JavaType for given JDK type (usually Class)
      • constructSpecializedType

        public abstract JavaType constructSpecializedType​(JavaType baseType,
                                                          java.lang.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.

      • getTypeFactory

        public abstract TypeFactory getTypeFactory()
      • converterInstance

        public Converter<java.lang.Object,​java.lang.Object> converterInstance​(Annotated annotated,
                                                                                    java.lang.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.
        Throws:
        JsonMappingException
        Since:
        2.2