@Test void extractContentShouldReturnEmptyWhenNullContentType() throws Exception { InputStream inputStream = ClassLoader.getSystemResourceAsStream("documents/html.txt"); assertThat(textExtractor.extractContent(inputStream, null)) .isEqualTo(ParsedContent.empty()); }
@Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (inputStream == null || contentType == null) { return ParsedContent.empty(); } Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); if (contentType.mimeType().equals(TEXT_HTML)) { return parseHtmlContent(inputStream, charset); } if (contentType.mimeType().equals(TEXT_PLAIN)) { return parsePlainTextContent(inputStream, charset); } return ParsedContent.empty(); }
JsoupTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (inputStream == null || contentType == null) { return ParsedContent.empty(); } Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); if (contentType.mimeType().equals(TEXT_HTML)) { return parseHtmlContent(inputStream, charset); } if (contentType.mimeType().equals(TEXT_PLAIN)) { return parsePlainTextContent(inputStream, charset); } return ParsedContent.empty(); } }
JsoupTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (inputStream == null || contentType == null) { return ParsedContent.empty(); } Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); if (contentType.mimeType().equals(TEXT_HTML)) { return parseHtmlContent(inputStream, charset); } if (contentType.mimeType().equals(TEXT_PLAIN)) { return parsePlainTextContent(inputStream, charset); } return ParsedContent.empty(); }  }
JsoupTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (inputStream == null || contentType == null) { return ParsedContent.empty(); } Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); if (contentType.mimeType().equals(TEXT_HTML)) { return parseHtmlContent(inputStream, charset); } if (contentType.mimeType().equals(TEXT_PLAIN)) { return parsePlainTextContent(inputStream, charset); } return ParsedContent.empty(); }  @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType); }
JsoupTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { if (inputStream == null || contentType == null) { return ParsedContent.empty(); } Charset charset = contentType.charset().orElse(StandardCharsets.UTF_8); if (contentType.mimeType().equals(TEXT_HTML)) { return parseHtmlContent(inputStream, charset); } if (contentType.mimeType().equals(TEXT_PLAIN)) { return parsePlainTextContent(inputStream, charset); } return ParsedContent.empty(); }  @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType);  }