Package org.apache.tika.extractor
Class EmbeddedDocumentUtil
- java.lang.Object
- 
- org.apache.tika.extractor.EmbeddedDocumentUtil
 
- 
- All Implemented Interfaces:
- Serializable
 
 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 SummaryConstructors Constructor Description EmbeddedDocumentUtil(ParseContext context)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DetectorgetDetector()static EmbeddedDocumentExtractorgetEmbeddedDocumentExtractor(ParseContext context)This offers a uniform way to get an EmbeddedDocumentExtractor from a ParseContext.StringgetExtension(TikaInputStream is, Metadata metadata)MimeTypesgetMimeTypes()PasswordProvidergetPasswordProvider()static ParsergetStatelessParser(ParseContext context)Utility function to get the Parser that was sent in to the ParseContext to handle embedded documents.TikaConfiggetTikaConfig()voidparseEmbedded(InputStream inputStream, ContentHandler handler, Metadata metadata, boolean outputHtml)static voidrecordEmbeddedStreamException(Throwable t, Metadata m)static voidrecordException(Throwable t, Metadata m)booleanshouldParseEmbedded(Metadata m)static ParsertryToFindExistingLeafParser(Class clazz, ParseContext context)Tries to find an existing parser within the ParseContext.
 
- 
- 
- 
Constructor Detail- 
EmbeddedDocumentUtilpublic EmbeddedDocumentUtil(ParseContext context) 
 
- 
 - 
Method Detail- 
getEmbeddedDocumentExtractorpublic 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 toEmptyParserin the ParseContext.- Parameters:
- context-
- Returns:
- EmbeddedDocumentExtractor
 
 - 
getStatelessParserpublic static Parser getStatelessParser(ParseContext context) Utility function to get the Parser that was sent in to the ParseContext to handle embedded documents. If it is stateful, unwrap it to get its stateless delegating parser.If there is no Parser in the parser context, this will return null. - Parameters:
- context-
- Returns:
 
 - 
getPasswordProviderpublic PasswordProvider getPasswordProvider() 
 - 
getDetectorpublic Detector getDetector() 
 - 
getMimeTypespublic MimeTypes getMimeTypes() 
 - 
getTikaConfigpublic TikaConfig getTikaConfig() - Returns:
- Returns a TikaConfig-- trying to find it first in the ParseContext that was included during initialization, and then creating a new one from viaTikaConfig.getDefaultConfig()if it can't find one in the ParseContext. This caches the default config so that it only has to be created once.
 
 - 
getExtensionpublic String getExtension(TikaInputStream is, Metadata metadata) 
 - 
recordEmbeddedStreamExceptionpublic static void recordEmbeddedStreamException(Throwable t, Metadata m) 
 - 
shouldParseEmbeddedpublic boolean shouldParseEmbedded(Metadata m) 
 - 
parseEmbeddedpublic void parseEmbedded(InputStream inputStream, ContentHandler handler, Metadata metadata, boolean outputHtml) throws IOException, SAXException - Throws:
- IOException
- SAXException
 
 - 
tryToFindExistingLeafParserpublic 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 returnnullif the context contains no parser or the correct parser can't be found.- Parameters:
- clazz- parser class to search for
- context-
- Returns:
 
 
- 
 
-