TikaParserConfig { public static Set<MediaType> getNonIndexedMediaTypes(InputStream configStream) throws TikaException, IOException, SAXException { Set<MediaType> result = new HashSet<>(); Element element = getBuilder().parse(configStream).getDocumentElement(); NodeList nodes = element.getElementsByTagName("parsers"); if (nodes.getLength() == 1) { Node parentNode = nodes.item(0); NodeList parsersNodes = parentNode.getChildNodes(); for (int i = 0; i < parsersNodes.getLength(); i++) { Node node = parsersNodes.item(i); if (node instanceof Element) { String className = ((Element) node).getAttribute("class"); if (EMPTY_PARSER.equals(className)) { NodeList mimes = ((Element) node).getElementsByTagName("mime"); parseMimeTypes(result, mimes); } } } } return result; }  static Set<MediaType> getNonIndexedMediaTypes(InputStream configStream);  }
@Test public void emptyParser() throws Exception{ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<properties>\n" + " <detectors>\n" + " <detector class=\"org.apache.tika.detect.TypeDetector\"/>\n" + " </detectors>\n" + " <parsers>\n" + " <parser class=\"org.apache.tika.parser.DefaultParser\"/>\n" + " <parser class=\"org.apache.tika.parser.EmptyParser\">\n" + " <mime>application/x-archive</mime>\n" + " <mime>application/x-bzip</mime>\n" + " </parser>\n" + " </parsers>\n" + "</properties>"; Set<MediaType> types = TikaParserConfig.getNonIndexedMediaTypes( new ReaderInputStream(new StringReader(xml), "UTF-8")); assertEquals(2, types.size()); assertTrue(types.contains(MediaType.parse("application/x-archive"))); }