Class EmbeddedDocumentUtil

  • All Implemented Interfaces:

    public class EmbeddedDocumentUtil
    extends Object
    implements Serializable
    Utility class to handle common issues with embedded documents.

    Use statically if all that is needed is getting the EmbeddedDocumentExtractor. Otherwise, instantiate an instance.

    Note: This is not thread safe. Make sure to instantiate one per thread.

    See Also:
    Serialized Form
    • Constructor Detail

      • EmbeddedDocumentUtil

        public EmbeddedDocumentUtil​(ParseContext context)
    • Method Detail

      • getEmbeddedDocumentExtractor

        public static EmbeddedDocumentExtractor getEmbeddedDocumentExtractor​(ParseContext context)
        This offers a uniform way to get an EmbeddedDocumentExtractor from a ParseContext. As of Tika 1.15, an AutoDetectParser will automatically be added to parse embedded documents if no Parser.class is specified in the ParseContext.

        If you'd prefer not to parse embedded documents, set Parser.class to EmptyParser in the ParseContext.

        context -
      • getDetector

        public Detector getDetector()
      • getMimeTypes

        public MimeTypes getMimeTypes()
      • getTikaConfig

        public TikaConfig getTikaConfig()
        Returns a TikaConfig -- trying to find it first in the ParseContext that was included during initialization, and then creating a new one from via TikaConfig.getDefaultConfig() if it can't find one in the ParseContext. This caches the default config so that it only has to be created once.
      • recordEmbeddedStreamException

        public static void recordEmbeddedStreamException​(Throwable t,
                                                         Metadata m)
      • shouldParseEmbedded

        public boolean shouldParseEmbedded​(Metadata m)
      • tryToFindExistingLeafParser

        public static Parser tryToFindExistingLeafParser​(Class clazz,
                                                         ParseContext context)
        Tries to find an existing parser within the ParseContext. It looks inside of CompositeParsers and ParserDecorators. The use case is when a parser needs to parse an internal stream that is _part_ of the document, e.g. rtf body inside an msg.

        Can return null if the context contains no parser or the correct parser can't be found.

        clazz - parser class to search for
        context -