org.apache.jackrabbit.extractor
Interface TextExtractor

All Known Subinterfaces:
DelegatingTextExtractor
All Known Implementing Classes:
AbstractTextExtractor, CompositeTextExtractor, DefaultTextExtractor, EmptyTextExtractor, HTMLTextExtractor, JackrabbitTextExtractor, MsExcelTextExtractor, MsPowerPointTextExtractor, MsWordTextExtractor, OpenOfficeTextExtractor, PdfTextExtractor, PlainTextExtractor, PooledTextExtractor, RTFTextExtractor, TextFilterExtractor, XMLTextExtractor

public interface TextExtractor

Interface for extracting text content from binary streams.


Method Summary
 Reader extractText(InputStream stream, String type, String encoding)
          Returns a reader for the text content of the given binary document.
 String[] getContentTypes()
          Returns the MIME types supported by this extractor.
 

Method Detail

getContentTypes

String[] getContentTypes()
Returns the MIME types supported by this extractor. The returned strings must be in lower case, and the returned array must not be empty.

The returned array must not be modified.

Returns:
supported MIME types, lower case

extractText

Reader extractText(InputStream stream,
                   String type,
                   String encoding)
                   throws IOException
Returns a reader for the text content of the given binary document. The content type and character encoding (if available and applicable) are given as arguments. The given content type is guaranteed to be one of the types reported by getContentTypes() unless the implementation explicitly permits other content types.

The implementation can choose either to read and parse the given document immediately or to return a reader that does it incrementally. The only constraint is that the implementation must close the given stream latest when the returned reader is closed. The caller on the other hand is responsible for closing the returned reader.

The implemenation should only throw an exception on transient errors, i.e. when it can expect to be able to successfully extract the text content of the same binary at another time. An effort should be made to recover from syntax errors and other similar problems.

This method should be thread-safe, i.e. it is possible that this method is invoked simultaneously by different threads to extract the text content of different documents. On the other hand the returned reader does not need to be thread-safe.

Parameters:
stream - binary document from which to extract text
type - MIME type of the given document, lower case
encoding - the character encoding of the binary data, or null if not available
Returns:
reader for the extracted text content
Throws:
IOException - on transient errors


Copyright © 2004-2007 The Apache Software Foundation. All Rights Reserved.