public abstract class EmailTextExtractorBase extends TextExtractor implements IContainer
Provides the base class for text extractors for emails.
Modifier | Constructor and Description |
---|---|
protected |
EmailTextExtractorBase(InputStream stream,
LoadOptions loadOptions)
Initializes a new instance of the
EmailTextExtractorBase class. |
Modifier and Type | Method and Description |
---|---|
protected void |
dispose(boolean disposing)
Releases the unmanaged resources used by the extractor.
|
int |
getAttachmentCount()
Gets a total count of the attachments.
|
List<Container.Entity> |
getEntities()
Gets a collection of email attachments.
|
InputStream |
getStream(int attachment)
Returns a
java.io.InputStream with a content of the attachment. |
InputStream |
openEntityStream(Container.Entity entity)
Opens a stream with the content of the container's entity.
|
protected String |
prepareLine()
Returns a line of the text.
|
void |
reset()
Resets the current document.
|
checkDisposed, close, dispose, extractAll, extractLine, extractText, extractTextLine, getEncoding, getMediaType, getPassword, isDisposed, setEncoding, setMediaType
protected EmailTextExtractorBase(InputStream stream, LoadOptions loadOptions)
Initializes a new instance of the EmailTextExtractorBase
class.
stream
- The stream of the document.loadOptions
- The options of loading the file.public int getAttachmentCount()
Gets a total count of the attachments.
public List<Container.Entity> getEntities()
Gets a collection of email attachments.
Value: A collection of email attachments. // Create an extractor factory
ExtractorFactory factory = new ExtractorFactory();
// Create an instance of EmailTextExtractor class
EmailTextExtractor extractor = new EmailTextExtractor(fileName);
// Iterate over all attachments in the message
for (int i = 0; i < extractor.getEntities().size(); i++) {
// Print the name of an attachment
System.out.println(extractor.getEntities().get(i).getName());
// Open the stream of an attachment
java.io.InputStream stream = extractor.getEntities().get(i).openStream();
// Create the text extractor for an attachment
TextExtractor attachmentExtractor = factory.createTextExtractor(stream);
// If a media type is supported
if (attachmentExtractor != null)
// Print the content of an attachment
System.out.println(attachmentExtractor.extractAll());
}
getEntities
in interface IContainer
public InputStream openEntityStream(Container.Entity entity)
Opens a stream with the content of the container's entity.
openEntityStream
in interface IContainer
entity
- A container's entity.public InputStream getStream(int attachment)
Returns a java.io.InputStream
with a content of the attachment.
attachment
- An index of the attachment.java.io.InputStream
with a content of the attachment.public void reset()
Resets the current document.
ExtractLine
method will return the first line of the document.
reset
in class TextExtractor
protected String prepareLine()
Returns a line of the text.
prepareLine
in class TextExtractor
protected void dispose(boolean disposing)
Releases the unmanaged resources used by the extractor.
dispose
in class TextExtractor
disposing
- A boolean true if invoked from Dispose; otherwise, false.Copyright © 2018. All rights reserved.