Class TikaObjectMapperFactory

java.lang.Object
org.apache.tika.config.loader.TikaObjectMapperFactory

public class TikaObjectMapperFactory extends Object
Factory for creating ObjectMappers configured for Tika serialization.

Configures strict validation settings and loads component registries for friendly name resolution.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.fasterxml.jackson.databind.ObjectMapper
    Creates an ObjectMapper configured for Tika serialization.
    static com.fasterxml.jackson.databind.ObjectMapper
    createMapper(com.fasterxml.jackson.core.JsonFactory factory)
    Creates an ObjectMapper configured for Tika serialization with a custom JsonFactory.
    static com.fasterxml.jackson.databind.ObjectMapper
    A strict mapper without Tika's component serializers, for plugin configuration (PluginJson).
    static com.fasterxml.jackson.databind.ObjectMapper
     
    static com.fasterxml.jackson.databind.ObjectMapper
    Returns a shared plain ObjectMapper without TikaModule registration.
    static <T> T
    readConfig(String json, Class<T> configClass, boolean trusted)
    Reads a component's JSON config; called by tika-core's ConfigDeserializer by reflection.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TikaObjectMapperFactory

      public TikaObjectMapperFactory()
  • Method Details

    • getPlainMapper

      public static com.fasterxml.jackson.databind.ObjectMapper getPlainMapper()
      Returns a shared plain ObjectMapper without TikaModule registration.

      This mapper is suitable for:

      • Converting JsonNodes to JSON strings
      • Serializing component properties without compact format wrapping
      • Avoiding infinite recursion when serializing inside TikaModule

      Has FAIL_ON_EMPTY_BEANS disabled to allow serialization of classes with no properties.

      Returns:
      the shared plain ObjectMapper
    • readConfig

      public static <T> T readConfig(String json, Class<T> configClass, boolean trusted) throws Exception
      Reads a component's JSON config; called by tika-core's ConfigDeserializer by reflection. Untrusted JSON may not set an OperatorOnly property.
      Throws:
      Exception
    • getMapper

      public static com.fasterxml.jackson.databind.ObjectMapper getMapper()
    • createMapper

      public static com.fasterxml.jackson.databind.ObjectMapper createMapper()
      Creates an ObjectMapper configured for Tika serialization.
      Returns:
      configured ObjectMapper
    • createMapper

      public static com.fasterxml.jackson.databind.ObjectMapper createMapper(com.fasterxml.jackson.core.JsonFactory factory)
      Creates an ObjectMapper configured for Tika serialization with a custom JsonFactory.

      This can be used to create mappers for binary formats like Smile:

       ObjectMapper smileMapper = TikaObjectMapperFactory.createMapper(new SmileFactory());
       
      Parameters:
      factory - the JsonFactory to use, or null for default JSON
      Returns:
      configured ObjectMapper
    • createStrictPlainMapper

      public static com.fasterxml.jackson.databind.ObjectMapper createStrictPlainMapper()
      A strict mapper without Tika's component serializers, for plugin configuration (PluginJson). Same checks as getMapper() except FAIL_ON_NULL_FOR_PRIMITIVES, which also rejects an absent primitive record component, and optional primitives with defaults are the norm in plugin configs.