View Javadoc

1   package com.atlassian.bonnie.search.extractor;
2   
3   import com.atlassian.bonnie.search.SearchableAttachment;
4   
5   import java.io.InputStream;
6   
7   import com.atlassian.core.util.FileUtils;
8   
9   public class DefaultTextContentExtractor extends BaseAttachmentContentExtractor
10  {
11      /**
12       * Extract text from mime types like 'text/*', 'application/xml*' and 'application/*+xml'
13       */
14      protected boolean shouldExtractFrom(String fileName, String contentType)
15      {
16          return contentType.startsWith("text/") || contentType.startsWith("application/xml") ||
17                  (contentType.startsWith("application/") && contentType.endsWith("+xml"));
18      }
19  
20      protected String extractText(InputStream is, SearchableAttachment attachment)
21      {
22          return FileUtils.getInputStreamTextContent(is);
23      }
24  }