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:
java.io.Serializable,org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.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:AbstractRecursiveParserWrapperHandler.TIKA_CONTENTIf 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 inherited from class org.apache.tika.sax.AbstractRecursiveParserWrapperHandler
CONTAINER_EXCEPTION, EMBEDDED_DEPTH, EMBEDDED_EXCEPTION, EMBEDDED_RESOURCE_LIMIT_REACHED, EMBEDDED_RESOURCE_PATH, PARSE_TIME_MILLIS, TIKA_CONTENT, TIKA_CONTENT_HANDLER, WRITE_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 parsed
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendDocument(org.xml.sax.ContentHandler contentHandler, Metadata metadata)This is called after the full parse has completed.voidendEmbeddedDocument(org.xml.sax.ContentHandler contentHandler, Metadata metadata)This is called after parsing an embedded document.java.util.List<Metadata>getMetadataList()voidstartEmbeddedDocument(org.xml.sax.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
-
-
Method Detail
-
startEmbeddedDocument
public void startEmbeddedDocument(org.xml.sax.ContentHandler contentHandler, Metadata metadata) throws org.xml.sax.SAXExceptionThis is called before parsing an embedded document- Overrides:
startEmbeddedDocumentin classAbstractRecursiveParserWrapperHandler- Parameters:
contentHandler- - local content handler to use on the embedded documentmetadata- metadata to use for the embedded document- Throws:
org.xml.sax.SAXException
-
endEmbeddedDocument
public void endEmbeddedDocument(org.xml.sax.ContentHandler contentHandler, Metadata metadata) throws org.xml.sax.SAXExceptionThis is called after parsing an embedded document.- Overrides:
endEmbeddedDocumentin classAbstractRecursiveParserWrapperHandler- Parameters:
contentHandler- local contenthandler used on the embedded documentmetadata- metadata from the embedded document- Throws:
org.xml.sax.SAXException
-
endDocument
public void endDocument(org.xml.sax.ContentHandler contentHandler, Metadata metadata) throws org.xml.sax.SAXExceptionDescription copied from class:AbstractRecursiveParserWrapperHandlerThis 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:
endDocumentin classAbstractRecursiveParserWrapperHandler- Parameters:
contentHandler- content handler used on the main documentmetadata- metadata from the main document- Throws:
org.xml.sax.SAXException
-
getMetadataList
public java.util.List<Metadata> getMetadataList()
- Returns:
- a list of Metadata objects, one for the main document and one for each embedded document
-
-