@Override
        public void parse(InputStream stream, ContentHandler ignore, Metadata metadata,
                          ParseContext context) throws IOException, SAXException, TikaException {

            //Test to see if we should avoid parsing
            if (parserState.recursiveParserWrapperHandler.hasHitMaximumEmbeddedResources()) {
                return;
            }
            // Work out what this thing is
            String objectName = getResourceName(metadata, parserState.unknownCount);
            String objectLocation = this.location + objectName;

            metadata.add(TikaCoreProperties.EMBEDDED_RESOURCE_PATH, objectLocation);

            String idPath =
                    this.embeddedIdPath.equals("/") ?
                            this.embeddedIdPath + ++parserState.embeddedCount :
                            this.embeddedIdPath + "/" + ++parserState.embeddedCount;
            metadata.add(TikaCoreProperties.EMBEDDED_ID_PATH, idPath);
            metadata.set(TikaCoreProperties.EMBEDDED_ID, parserState.embeddedCount);
            //get a fresh handler
            ContentHandler localHandler =
                    parserState.recursiveParserWrapperHandler.getNewContentHandler();
            parserState.recursiveParserWrapperHandler.startEmbeddedDocument(localHandler, metadata);

            Parser preContextParser = context.get(Parser.class);
            context.set(Parser.class,
                    new EmbeddedParserDecorator(getWrappedParser(), objectLocation,
                            idPath, parserState));
            long started = System.currentTimeMillis();
            //store the handler that was used before this parse
            //so that you can return it back to its state at the end of this parse
            RecursivelySecureContentHandler preParseHandler = context.get(RecursivelySecureContentHandler.class);

            ParentContentHandler preParseParentHandler = context.get(ParentContentHandler.class);
            context.set(ParentContentHandler.class, new ParentContentHandler(preParseHandler));
            TemporaryResources tmp = null;
            TikaInputStream tis = TikaInputStream.cast(stream);
            if (tis == null) {
                tmp = new TemporaryResources();
                tis = TikaInputStream.get(CloseShieldInputStream.wrap(stream), tmp, metadata);
            }
            ContentHandler secureContentHandler =
                    new RecursivelySecureContentHandler(localHandler, tis, preParseHandler.handlerCounter,
                    preParseHandler.throwOnWriteLimitReached, context);

            try {
                tis.setCloseShield();
                super.parse(tis, secureContentHandler, metadata, context);
            } catch (SAXException e) {
                if (WriteLimitReachedException.isWriteLimitReached(e)) {
                    metadata.add(TikaCoreProperties.WRITE_LIMIT_REACHED, "true");
                    throw e;
                } else {
                    if (catchEmbeddedExceptions) {
                        ParserUtils.recordParserFailure(this, e, metadata);
                    } else {
                        throw e;
                    }
                }
            } catch (CorruptedFileException e) {
                throw e;
            } catch (TikaException e) {
                if (e instanceof EncryptedDocumentException) {
                    metadata.set(TikaCoreProperties.IS_ENCRYPTED, true);
                }
                if (context.get(ZeroByteFileException.IgnoreZeroByteFileException.class) != null &&
                        e instanceof ZeroByteFileException) {
                    //do nothing
                } else if (catchEmbeddedExceptions) {
                    ParserUtils.recordParserFailure(this, e, metadata);
                } else {
                    throw e;
                }
            } finally {
                tis.removeCloseShield();
                context.set(Parser.class, preContextParser);
                context.set(RecursivelySecureContentHandler.class, preParseHandler);
                context.set(ParentContentHandler.class, preParseParentHandler);
                long elapsedMillis = System.currentTimeMillis() - started;
                metadata.set(TikaCoreProperties.PARSE_TIME_MILLIS, Long.toString(elapsedMillis));
                parserState.recursiveParserWrapperHandler
                        .endEmbeddedDocument(localHandler, metadata);
                if (tmp != null) {
                    tis.close();
                }
            }
        }
@param stream
@param recursiveParserWrapperHandler -- handler must implement
{@link RecursiveParserWrapperHandler}
@param metadata
@param context
@throws IOException
@throws SAXException
@throws TikaException
@throws IllegalStateException if the handler is not a {@link RecursiveParserWrapperHandler}
tika-core/src/main/java/org/apache/tika/parser/RecursiveParserWrapper.java