Package org.apache.tika.sax
Class RecursiveParserWrapperHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.tika.sax.AbstractRecursiveParserWrapperHandler
-
- org.apache.tika.sax.RecursiveParserWrapperHandler
-
- All Implemented Interfaces:
Serializable
,ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
public class RecursiveParserWrapperHandler extends AbstractRecursiveParserWrapperHandler
This is the default implementation ofAbstractRecursiveParserWrapperHandler
. See its documentation for more details.This caches the a metadata object for each embedded file and for the container file. It places the extracted content in the metadata object, with this key:
TikaCoreProperties.TIKA_CONTENT
If memory is a concern, subclass AbstractRecursiveParserWrapperHandler to handle each embedded document.NOTE: This handler must only be used with the
RecursiveParserWrapper
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Metadata>
metadataList
-
Fields inherited from class org.apache.tika.sax.AbstractRecursiveParserWrapperHandler
EMBEDDED_RESOURCE_LIMIT_REACHED
-
-
Constructor Summary
Constructors Constructor Description RecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory)
Create a handler with no limit on the number of embedded resourcesRecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory, int maxEmbeddedResources)
Create a handler that limits the number of embedded resources that will be parsedRecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory, int maxEmbeddedResources, MetadataFilter metadataFilter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endDocument(ContentHandler contentHandler, Metadata metadata)
This is called after the full parse has completed.void
endEmbeddedDocument(ContentHandler contentHandler, Metadata metadata)
This is called after parsing an embedded document.List<Metadata>
getMetadataList()
void
startEmbeddedDocument(ContentHandler contentHandler, Metadata metadata)
This is called before parsing an embedded document-
Methods inherited from class org.apache.tika.sax.AbstractRecursiveParserWrapperHandler
getContentHandlerFactory, getNewContentHandler, getNewContentHandler, hasHitMaximumEmbeddedResources
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Constructor Detail
-
RecursiveParserWrapperHandler
public RecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory)
Create a handler with no limit on the number of embedded resources
-
RecursiveParserWrapperHandler
public RecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory, int maxEmbeddedResources)
Create a handler that limits the number of embedded resources that will be parsed- Parameters:
maxEmbeddedResources
- number of embedded resources that will be parsed
-
RecursiveParserWrapperHandler
public RecursiveParserWrapperHandler(ContentHandlerFactory contentHandlerFactory, int maxEmbeddedResources, MetadataFilter metadataFilter)
-
-
Method Detail
-
startEmbeddedDocument
public void startEmbeddedDocument(ContentHandler contentHandler, Metadata metadata) throws SAXException
This is called before parsing an embedded document- Overrides:
startEmbeddedDocument
in classAbstractRecursiveParserWrapperHandler
- Parameters:
contentHandler
- - local content handler to use on the embedded documentmetadata
- metadata to use for the embedded document- Throws:
SAXException
-
endEmbeddedDocument
public void endEmbeddedDocument(ContentHandler contentHandler, Metadata metadata) throws SAXException
This is called after parsing an embedded document.- Overrides:
endEmbeddedDocument
in classAbstractRecursiveParserWrapperHandler
- Parameters:
contentHandler
- local contenthandler used on the embedded documentmetadata
- metadata from the embedded document- Throws:
SAXException
-
endDocument
public void endDocument(ContentHandler contentHandler, Metadata metadata) throws SAXException
Description copied from class:AbstractRecursiveParserWrapperHandler
This is called after the full parse has completed. Override this for custom behavior. Make sure to call this assuper.endDocument(...)
in subclasses because this adds whether or not the embedded resource maximum has been hit to the metadata.- Overrides:
endDocument
in classAbstractRecursiveParserWrapperHandler
- Parameters:
contentHandler
- content handler used on the main documentmetadata
- metadata from the main document- Throws:
SAXException
-
-