Add some helper methods for working with attachments

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1359542 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2012-07-10 09:43:49 +00:00
parent 76c19d6545
commit 062959aae1
1 changed files with 33 additions and 0 deletions

View File

@ -31,10 +31,13 @@ import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_MIME_TAG;
import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_RENDERING;
import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_SIZE;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.apache.poi.hsmf.MAPIMessage;
/**
* Collection of convenence chunks for standard parts of the MSG file attachment.
*/
@ -68,6 +71,36 @@ public class AttachmentChunks implements ChunkGroup {
this.poifsName = poifsName;
}
/**
* Is this Attachment an embedded MAPI message?
*/
public boolean isEmbeddedMessage() {
return (attachmentDirectory != null);
}
/**
* Returns the embedded MAPI message, if the attachment
* is an embedded message, or null otherwise
*/
public MAPIMessage getEmbeddedMessage() throws IOException {
if (attachmentDirectory != null) {
return attachmentDirectory.getAsEmbededMessage();
}
return null;
}
/**
* Returns the embedded object, if the attachment is an
* object based embedding (image, document etc), or null
* if it's an embedded message
*/
public byte[] getEmbeddedAttachmentObject() {
if (attachData != null) {
return attachData.getValue();
}
return null;
}
public Chunk[] getAll() {
return allChunks.toArray(new Chunk[allChunks.size()]);
}