Package org.apache.tika.parser.hook
Interface ParseHook
- All Known Implementing Classes:
InferenceDispatcher
public interface ParseHook
Sees every document a parse touches, at the entry point that already sees each one once:
the auto-detect parser, after detection. A hook is built at config load, carried in the
ParseContext for the duration of the top-level parse, and may ask for a document's
bytes after its own parser has run. Tika core knows nothing about what a hook does with
them; an inference module does.- Since:
- Apache Tika 4.1
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidend(Metadata root, boolean failed, ParseContext context) End of the top-level parse;failedwhen the parse threw.default voidAfter the document's parser ran cleanly.default voidofferPage(MediaType type, Metadata document, Metadata parent, int page, Path bytes, ParseContext context) A page ofdocumentrendered by its own parser;pageis 1-based,bytesandparentas inoffer(org.apache.tika.mime.MediaType, org.apache.tika.metadata.Metadata, org.apache.tika.metadata.Metadata, java.nio.file.Path, org.apache.tika.parser.ParseContext).default voidstart(Metadata root, ParseContext context) Top of the top-level parse; a hook may refuse the request.default booleanwants(MediaType type, Metadata metadata, ParseContext context) Whether this hook wants the bytes of a document of this detected type.default booleanwantsPages(MediaType renderType, Metadata document, ParseContext context) Whether this hook wants the pages of the document being parsed rendered as images of this type.
-
Method Details
-
start
Top of the top-level parse; a hook may refuse the request.- Throws:
TikaException
-
wants
Whether this hook wants the bytes of a document of this detected type.- Throws:
TikaException
-
offer
default void offer(MediaType type, Metadata metadata, Metadata parent, Path bytes, ParseContext context) throws IOException, TikaException After the document's parser ran cleanly.bytesis the document pinned to a file for this call only;parentis the document it is embedded in, null at top level.- Throws:
IOExceptionTikaException
-
wantsPages
default boolean wantsPages(MediaType renderType, Metadata document, ParseContext context) throws TikaException Whether this hook wants the pages of the document being parsed rendered as images of this type. Its parser asks once, before rendering anything for the hooks.- Throws:
TikaException
-
offerPage
default void offerPage(MediaType type, Metadata document, Metadata parent, int page, Path bytes, ParseContext context) throws IOException, TikaException A page ofdocumentrendered by its own parser;pageis 1-based,bytesandparentas inoffer(org.apache.tika.mime.MediaType, org.apache.tika.metadata.Metadata, org.apache.tika.metadata.Metadata, java.nio.file.Path, org.apache.tika.parser.ParseContext).- Throws:
IOExceptionTikaException
-
end
End of the top-level parse;failedwhen the parse threw.
-