TikaTextExtractor extends TextExtractor { @Override public boolean supportsMimeType( String mimeType ) { MediaType mediaType = MediaType.parse(mimeType); if (mediaType == null) { logger().debug("Invalid mime-type: {0}", mimeType); return false; } initialize(); for (MediaType excludedMediaType : excludedMediaTypes) { if (excludedMediaType.equals(mediaType)) { return false; } if (excludedMediaType.getSubtype().equalsIgnoreCase("*") && mediaType.getType().equalsIgnoreCase(excludedMediaType.getType())) { return false; } } return includedMediaTypes.isEmpty() ? parserSupportedMediaTypes.contains(mediaType) : parserSupportedMediaTypes.contains(mediaType) && includedMediaTypes.contains(mediaType); } TikaTextExtractor(); @Override boolean supportsMimeType( String mimeType ); @Override void extractFrom( final Binary binary,
                             final TextExtractor.Output output,
                             final Context context ); @Override String toString();  }
@Test public void shouldSupportExtractingFromTextFiles() throws Exception { assertThat(extractor.supportsMimeType("text/plain"), is(true)); }
@Test public void shouldSupportExtractingFromPdfFiles() throws Exception { assertThat(extractor.supportsMimeType("application/pdf"), is(true)); }
@Test public void shouldNotSupportExtractingFromPostscriptFiles() throws Exception { assertThat(extractor.supportsMimeType("application/postscript"), is(false)); }
@Test public void shouldSupportExtractingFromDocWordFiles() throws Exception { assertThat(extractor.supportsMimeType("application/msword"), is(true)); }
@Test public void shouldSupportExtractingFromDocxWordFiles() throws Exception { assertThat(extractor.supportsMimeType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"), is(true)); }