Package org.apache.tika.config
Class ConfigDeserializer
java.lang.Object
org.apache.tika.config.ConfigDeserializer
Deserializes JSON configuration without a compile-time dependency on Jackson.
Reads through tika-serialization (see ConfigReader), which also refuses untrusted JSON
that sets an OperatorOnly property. Throws if tika-serialization is not available.
Usage pattern in parsers, detectors, and other Tika components:
public class MyParser implements Parser {
public static class Config {
public int timeout = 30;
public boolean verbose = false;
}
public MyParser() {
// Default constructor for SPI
}
public MyParser(Config config) {
// Constructor with explicit config object
this.timeout = config.timeout;
this.verbose = config.verbose;
}
public MyParser(JsonConfig jsonConfig) {
this(ConfigDeserializer.buildConfig(jsonConfig, Config.class));
}
}
- Since:
- Apache Tika 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TbuildConfig(JsonConfig jsonConfig, Class<T> configClass) Deserializes a JSON configuration to a configuration object.
-
Constructor Details
-
ConfigDeserializer
public ConfigDeserializer()
-
-
Method Details
-
buildConfig
Deserializes a JSON configuration to a configuration object. Untrusted JSON (seeJsonConfig.trusted()) may not set anOperatorOnlyproperty.- Type Parameters:
T- the configuration type- Parameters:
jsonConfig- the JSON configurationconfigClass- the configuration class- Returns:
- the deserialized configuration object
- Throws:
RuntimeException- if tika-serialization is not on the classpath, deserialization fails, or untrusted JSON sets an operator-only property
-