Package org.apache.tika.config.loader
Class TikaObjectMapperFactory
java.lang.Object
org.apache.tika.config.loader.TikaObjectMapperFactory
Factory for creating ObjectMappers configured for Tika serialization.
Configures strict validation settings and loads component registries for friendly name resolution.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.ObjectMapperCreates an ObjectMapper configured for Tika serialization.static com.fasterxml.jackson.databind.ObjectMappercreateMapper(com.fasterxml.jackson.core.JsonFactory factory) Creates an ObjectMapper configured for Tika serialization with a custom JsonFactory.static com.fasterxml.jackson.databind.ObjectMapperA strict mapper without Tika's component serializers, for plugin configuration (PluginJson).static com.fasterxml.jackson.databind.ObjectMapperstatic com.fasterxml.jackson.databind.ObjectMapperReturns a shared plain ObjectMapper without TikaModule registration.static <T> TreadConfig(String json, Class<T> configClass, boolean trusted) Reads a component's JSON config; called by tika-core's ConfigDeserializer by reflection.
-
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_BEANSdisabled to allow serialization of classes with no properties.- Returns:
- the shared plain ObjectMapper
-
readConfig
Reads a component's JSON config; called by tika-core's ConfigDeserializer by reflection. Untrusted JSON may not set anOperatorOnlyproperty.- 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 asgetMapper()exceptFAIL_ON_NULL_FOR_PRIMITIVES, which also rejects an absent primitive record component, and optional primitives with defaults are the norm in plugin configs.
-