You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2012/07/10 11:43:50 UTC
svn commit: r1359542 -
/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
Author: nick
Date: Tue Jul 10 09:43:49 2012
New Revision: 1359542
URL: http://svn.apache.org/viewvc?rev=1359542&view=rev
Log:
Add some helper methods for working with attachments
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java?rev=1359542&r1=1359541&r2=1359542&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java Tue Jul 10 09:43:49 2012
@@ -31,10 +31,13 @@ import static org.apache.poi.hsmf.dataty
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
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()]);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org