Package org.apache.tika.config.loader
Class PresetRegistry
java.lang.Object
org.apache.tika.config.loader.PresetRegistry
Named, vetted parse-context fragments a caller selects whole, by name only ("presets").
A preset is operator config, not caller input: resolved with the same trust as the
config's own
parse-context block, and fully resolved at load so a bad preset
fails startup, not its first request.
Nothing is active unless the config's presets block names it: true
activates the classpath-catalog definition of that name (error if absent), an object
defines the preset in place (replacing any catalog definition wholesale),
false/null is an explicit no-op. Catalog jars can never activate
themselves. Presets do not compose.
The catalog is discovered from META-INF/tika/preset-catalog.properties
resources (hand-authored, unlike the annotation processor's generated
META-INF/tika/*.idx), each line name=/classpath/resource.json;
blank lines and # comments ignored.
"presets": {
"some-catalog-preset": true,
"ocr-heavy": { "pages": { "text": "EXTRACT_AND_OCR" } }
}
- Since:
- Apache Tika 4.1.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic booleanisValidName(String name) Legal preset name: the NAME rule, and not "config"-prefixed (tika-server gates/configendpoints on that path fragment).static PresetRegistryload(TikaJsonConfig config, ClassLoader classLoader) Builds the active roster from the config'spresetsblock (see the class javadoc for the value semantics), resolving every active preset.names()newParseContext(String name) A fully resolved ParseContext for the preset, or null for an unknown name.parseContextJson(String name) The preset'sparse-context-shaped JSON, or null for an unknown name.booleanTrue if the preset binds aContentHandlerFactory(it then owns the output format on routes with no explicit format segment).
-
Field Details
-
CONFIG_KEY
- See Also:
-
-
Method Details
-
load
public static PresetRegistry load(TikaJsonConfig config, ClassLoader classLoader) throws TikaConfigException Builds the active roster from the config'spresetsblock (see the class javadoc for the value semantics), resolving every active preset.- Parameters:
config- the loaded config, may be null (empty roster)classLoader- for catalog scanning and component resolution; null for the thread context loader- Throws:
TikaConfigException
-
isValidName
Legal preset name: the NAME rule, and not "config"-prefixed (tika-server gates/configendpoints on that path fragment). Public so wire deserializers can bound a preset-name field with the same rule. -
names
-
hasPreset
-
parseContextJson
The preset'sparse-context-shaped JSON, or null for an unknown name. -
newParseContext
A fully resolved ParseContext for the preset, or null for an unknown name. Fresh per call: callers mutate the result per request.- Throws:
TikaConfigException
-
suppliesContentHandlerFactory
True if the preset binds aContentHandlerFactory(it then owns the output format on routes with no explicit format segment).
-