Class ParsingEmbeddedDocumentExtractor
- All Implemented Interfaces:
EmbeddedDocumentExtractor
- Direct Known Subclasses:
UnpackExtractor
Stateless: every method takes the ParseContext of the enclosing parse
as a parameter rather than capturing one at construction, so a single shared
instance (INSTANCE) is safe to reuse across parses and threads.
- Since:
- Apache Tika 0.8
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckEmbeddedLimits(ParseRecord parseRecord, ParseContext context) Checks embedded document limits from ParseRecord: the task deadline, then max count, then max depth.booleanisWriteFileNameToContent(ParseContext context) Returns whether to write file names to content based onSAXOutputConfigin the ParseContext.voidparseEmbedded(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext context, boolean outputHtml) Processes the supplied embedded resource, calling the delegating parser with the appropriate details.protected voidrecordException(Exception e, ParseContext context) booleanshouldParseEmbedded(Metadata metadata, ParseContext context) Determines whether the given embedded document should be parsed.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
ParsingEmbeddedDocumentExtractor
public ParsingEmbeddedDocumentExtractor()
-
-
Method Details
-
shouldParseEmbedded
Description copied from interface:EmbeddedDocumentExtractorDetermines whether the given embedded document should be parsed.Note: Implementations may throw
EmbeddedLimitReachedException(a RuntimeException) if a limit is exceeded and throwing is configured.- Specified by:
shouldParseEmbeddedin interfaceEmbeddedDocumentExtractor- Parameters:
metadata- the metadata for the embedded documentcontext- the parse context of the enclosing parse- Returns:
- true if the embedded document should be parsed
-
checkEmbeddedLimits
Checks embedded document limits from ParseRecord: the task deadline, then max count, then max depth.If throwing is configured for the limit hit, the corresponding EmbeddedLimitReachedException is thrown. Otherwise, returns false and sets the appropriate limit flag on the ParseRecord.
Note: The deadline and count limits are hard stops (once hit, no more embedded docs are parsed). The depth limit only affects documents at that depth - sibling documents at shallower depths will still be parsed.
Subclasses that override parseEmbedded() should call this method to enforce limits.
- Parameters:
parseRecord- the parse record to checkcontext- the parse context of the enclosing parse- Returns:
- true if the embedded document should be parsed, false if limits are exceeded
- Throws:
EmbeddedLimitReachedException- if a limit is exceeded and throwing is configured
-
parseEmbedded
public void parseEmbedded(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext context, boolean outputHtml) throws SAXException, IOException Description copied from interface:EmbeddedDocumentExtractorProcesses the supplied embedded resource, calling the delegating parser with the appropriate details.- Specified by:
parseEmbeddedin interfaceEmbeddedDocumentExtractor- Parameters:
tis- The embedded resourcehandler- The handler to usemetadata- The metadata for the embedded resourcecontext- The parse contextoutputHtml- Should we output HTML for this resource, or has the parser already done so?- Throws:
SAXExceptionIOException
-
recordException
-
getDelegatingParser
-
isWriteFileNameToContent
Returns whether to write file names to content based onSAXOutputConfigin the ParseContext. Defaults totrueif no config is present.- Parameters:
context- the parse context of the enclosing parse- Returns:
- true if file names should be written to content
-