Package org.apache.tika.config.loader
Class ParserLoader
java.lang.Object
org.apache.tika.config.loader.AbstractSpiComponentLoader<Parser>
org.apache.tika.config.loader.ParserLoader
- All Implemented Interfaces:
ComponentLoader<Parser>
Loader for parsers with support for:
- SPI fallback via "default-parser" marker with exclusions
- Mime type filtering decorations (_mime-include, _mime-exclude)
- EncodingDetector and Renderer dependency injection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ParsercreateDefaultComposite(Set<Class<? extends Parser>> exclusions, LoaderContext context) Create the SPI-backed default composite with exclusions.protected ParserdecorateDefaultComposite(Parser parser, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) Decorate the default composite with additional behavior.protected ParserloadComponent(String name, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) Load a single component from config.protected ParserpostProcess(Parser parser, LoaderContext context) Post-process a single component (e.g., inject dependencies).unwrapClass(Parser component) Unwrap a component to get the underlying class for auto-exclusion purposes.protected ParserwrapInComposite(List<Parser> parsers, LoaderContext context) Wrap a list of components in a composite.Methods inherited from class org.apache.tika.config.loader.AbstractSpiComponentLoader
getComponentClass, getDefaultMarkerName, getSectionName, handleSpecialName, load, postProcessList
-
Constructor Details
-
ParserLoader
public ParserLoader()
-
-
Method Details
-
loadComponent
protected Parser loadComponent(String name, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) throws TikaConfigException Description copied from class:AbstractSpiComponentLoaderLoad a single component from config. Subclasses can apply decorations (e.g., mime filtering for parsers).- Specified by:
loadComponentin classAbstractSpiComponentLoader<Parser>- Parameters:
name- the component name (friendly name or FQCN)configNode- the JSON configuration for this componentcontext- the loader context- Returns:
- the loaded component
- Throws:
TikaConfigException- if loading fails
-
createDefaultComposite
protected Parser createDefaultComposite(Set<Class<? extends Parser>> exclusions, LoaderContext context) Description copied from class:AbstractSpiComponentLoaderCreate the SPI-backed default composite with exclusions. E.g., new DefaultParser(..., exclusions) or new DefaultDetector(..., exclusions)- Specified by:
createDefaultCompositein classAbstractSpiComponentLoader<Parser>- Parameters:
exclusions- classes to exclude from SPI loadingcontext- the loader context- Returns:
- the default composite
-
decorateDefaultComposite
protected Parser decorateDefaultComposite(Parser parser, com.fasterxml.jackson.databind.JsonNode configNode, LoaderContext context) throws TikaConfigException Description copied from class:AbstractSpiComponentLoaderDecorate the default composite with additional behavior. E.g., for parsers, apply mime filtering from _mime-include/_mime-exclude. Default: returns the composite unchanged.- Overrides:
decorateDefaultCompositein classAbstractSpiComponentLoader<Parser>- Parameters:
parser- the default compositeconfigNode- the JSON configuration for the default marker (may be null)context- the loader context- Returns:
- the decorated composite
- Throws:
TikaConfigException- if decoration fails
-
wrapInComposite
Description copied from class:AbstractSpiComponentLoaderWrap a list of components in a composite. E.g., new CompositeParser(registry, list) or new CompositeDetector(registry, list)- Specified by:
wrapInCompositein classAbstractSpiComponentLoader<Parser>- Parameters:
parsers- the list of componentscontext- the loader context- Returns:
- the composite component
-
unwrapClass
Description copied from class:AbstractSpiComponentLoaderUnwrap a component to get the underlying class for auto-exclusion purposes. When a component is wrapped in a decorator (e.g., ParserDecorator for mime filtering), we need to exclude the underlying class from SPI, not the decorator class. Subclasses can override this for type-specific unwrapping.- Overrides:
unwrapClassin classAbstractSpiComponentLoader<Parser>
-
postProcess
Description copied from class:AbstractSpiComponentLoaderPost-process a single component (e.g., inject dependencies). Default: returns the component unchanged.- Overrides:
postProcessin classAbstractSpiComponentLoader<Parser>- Parameters:
parser- the component to post-processcontext- the loader context- Returns:
- the post-processed component
- Throws:
TikaConfigException- if post-processing fails
-