XLZParser extends AbstractParser { public void parse( InputStream stream, ContentHandler baseHandler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException { ZipFile zipFile = null; ZipInputStream zipStream = null; if (stream instanceof TikaInputStream) { TikaInputStream tis = (TikaInputStream) stream; Object container = ((TikaInputStream) stream).getOpenContainer(); if (container instanceof ZipFile) { zipFile = (ZipFile) container; } else if (tis.hasFile()) { zipFile = new ZipFile(tis.getFile()); } else { zipStream = new ZipInputStream(stream); } } else { zipStream = new ZipInputStream(stream); } XHTMLContentHandler xhtml = new XHTMLContentHandler(baseHandler, metadata); EndDocumentShieldingContentHandler handler = new EndDocumentShieldingContentHandler(xhtml); if (zipFile != null) { try { handleZipFile(zipFile, metadata, context, handler); } finally { zipFile.close(); } } else { try { handleZipStream(zipStream, metadata, context, handler); } finally { zipStream.close(); } } if (handler.getEndDocumentWasCalled()) { handler.reallyEndDocument(); } }  @Override Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler baseHandler,
            Metadata metadata, ParseContext context);  }
@Test public void testXLZ() throws Exception { try (InputStream input = XLZParserTest.class.getResourceAsStream("/test-documents/testXLIFF12.xlz")) { Metadata metadata = new Metadata(); ContentHandler handler = new BodyContentHandler(); new XLZParser().parse(input, handler, metadata, new ParseContext()); String content = handler.toString(); assertContains("Hooray", content); assertEquals("2", metadata.get("file-count")); assertEquals("4", metadata.get("tu-count")); assertEquals("en", metadata.get("source-language")); assertEquals("fr", metadata.get("target-language")); } }