More converting of HSMF code to use strongly type attributes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1057712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5fa971d0bf
commit
babc3f173e
@ -30,24 +30,6 @@ import java.util.List;
|
|||||||
* http://msdn.microsoft.com/en-us/library/ms526356%28v=exchg.10%29.aspx
|
* http://msdn.microsoft.com/en-us/library/ms526356%28v=exchg.10%29.aspx
|
||||||
*/
|
*/
|
||||||
public final class Chunks implements ChunkGroup {
|
public final class Chunks implements ChunkGroup {
|
||||||
// 0x0050 -> 0x006F seem to be routing info or similar
|
|
||||||
public static final int CONVERSATION_TOPIC = 0x0070;
|
|
||||||
public static final int CONVERSATION_INDEX = 0x0071;
|
|
||||||
public static final int SENT_BY_SERVER_TYPE = 0x0075;
|
|
||||||
public static final int RECEIVED_BY_ADDRESS = 0x0076;
|
|
||||||
public static final int RECEIVED_REPRESENTING_ADDRESS = 0x0078;
|
|
||||||
public static final int MESSAGE_HEADERS = 0x007D;
|
|
||||||
// RECEIVEDEMAIL = 76
|
|
||||||
public static final int DISPLAY_TO = 0x0E04;
|
|
||||||
public static final int DISPLAY_FROM = 0x0C1A;
|
|
||||||
public static final int EMAIL_FROM = 0x0C1F;
|
|
||||||
public static final int DISPLAY_CC = 0x0E03;
|
|
||||||
public static final int DISPLAY_BCC = 0x0E02;
|
|
||||||
// 0x0E1D seems a duplicate of 0x0070 !
|
|
||||||
public static final int TEXT_BODY = 0x1000;
|
|
||||||
public static final int MESSAGE_ID = 0x1035;
|
|
||||||
// 0x8??? ones are outlook specific, and not standard MAPI
|
|
||||||
|
|
||||||
/** Holds all the chunks that were found. */
|
/** Holds all the chunks that were found. */
|
||||||
private List<Chunk> allChunks = new ArrayList<Chunk>();
|
private List<Chunk> allChunks = new ArrayList<Chunk>();
|
||||||
|
|
||||||
@ -92,50 +74,50 @@ public final class Chunks implements ChunkGroup {
|
|||||||
if(chunk.getChunkId() == MAPIAttribute.MESSAGE_CLASS.id) {
|
if(chunk.getChunkId() == MAPIAttribute.MESSAGE_CLASS.id) {
|
||||||
messageClass = (StringChunk)chunk;
|
messageClass = (StringChunk)chunk;
|
||||||
}
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.INTERNET_MESSAGE_ID.id) {
|
||||||
|
messageId = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.MESSAGE_SUBMISSION_ID.id) {
|
||||||
|
// TODO - parse
|
||||||
|
submissionChunk = (MessageSubmissionChunk)chunk;
|
||||||
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.RECEIVED_BY_ADDRTYPE.id) {
|
||||||
|
sentByServerType = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.TRANSPORT_MESSAGE_HEADERS.id) {
|
||||||
|
messageHeaders = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.CONVERSATION_TOPIC.id) {
|
||||||
|
conversationTopic = (StringChunk)chunk;
|
||||||
|
}
|
||||||
else if(chunk.getChunkId() == MAPIAttribute.SUBJECT.id) {
|
else if(chunk.getChunkId() == MAPIAttribute.SUBJECT.id) {
|
||||||
subjectChunk = (StringChunk)chunk;
|
subjectChunk = (StringChunk)chunk;
|
||||||
}
|
}
|
||||||
else if(chunk.getChunkId() == MAPIAttribute.ORIGINAL_SUBJECT.id) {
|
else if(chunk.getChunkId() == MAPIAttribute.ORIGINAL_SUBJECT.id) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
else if(chunk.getChunkId() == MAPIAttribute.MESSAGE_SUBMISSION_ID.id) {
|
|
||||||
// TODO - parse
|
else if(chunk.getChunkId() == MAPIAttribute.DISPLAY_TO.id) {
|
||||||
submissionChunk = (MessageSubmissionChunk)chunk;
|
displayToChunk = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.DISPLAY_CC.id) {
|
||||||
|
displayCCChunk = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.DISPLAY_BCC.id) {
|
||||||
|
displayBCCChunk = (StringChunk)chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(chunk.getChunkId()) {
|
else if(chunk.getChunkId() == MAPIAttribute.SENDER_EMAIL_ADDRESS.id) {
|
||||||
case MESSAGE_ID:
|
|
||||||
messageId = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case CONVERSATION_TOPIC:
|
|
||||||
conversationTopic = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case SENT_BY_SERVER_TYPE:
|
|
||||||
sentByServerType = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case MESSAGE_HEADERS:
|
|
||||||
messageHeaders = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case DISPLAY_TO:
|
|
||||||
displayToChunk = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case DISPLAY_FROM:
|
|
||||||
displayFromChunk = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case EMAIL_FROM:
|
|
||||||
emailFromChunk = (StringChunk)chunk;
|
emailFromChunk = (StringChunk)chunk;
|
||||||
break;
|
|
||||||
case DISPLAY_CC:
|
|
||||||
displayCCChunk = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case DISPLAY_BCC:
|
|
||||||
displayBCCChunk = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
case TEXT_BODY:
|
|
||||||
textBodyChunk = (StringChunk)chunk;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.SENDER_NAME.id) {
|
||||||
|
displayFromChunk = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
else if(chunk.getChunkId() == MAPIAttribute.BODY.id) {
|
||||||
|
textBodyChunk = (StringChunk)chunk;
|
||||||
|
}
|
||||||
|
|
||||||
// And add to the main list
|
// And add to the main list
|
||||||
allChunks.add(chunk);
|
allChunks.add(chunk);
|
||||||
}
|
}
|
||||||
|
@ -1020,6 +1020,8 @@ public final class MAPIAttribute {
|
|||||||
public static final MAPIAttribute UNKNOWN =
|
public static final MAPIAttribute UNKNOWN =
|
||||||
new MAPIAttribute(-1, -1, "Unknown", null);
|
new MAPIAttribute(-1, -1, "Unknown", null);
|
||||||
|
|
||||||
|
// 0x8??? ones are outlook specific, and not standard MAPI
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
public final int id;
|
public final int id;
|
||||||
|
@ -17,11 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.poi.hsmf.datatypes;
|
package org.apache.poi.hsmf.datatypes;
|
||||||
|
|
||||||
import org.apache.poi.hsmf.datatypes.Chunk;
|
|
||||||
import org.apache.poi.hsmf.datatypes.Chunks;
|
|
||||||
import org.apache.poi.hsmf.datatypes.StringChunk;
|
|
||||||
import org.apache.poi.hsmf.datatypes.Types;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,23 +53,23 @@ public final class TestChunkData extends TestCase {
|
|||||||
|
|
||||||
public void testTextBodyChunk() {
|
public void testTextBodyChunk() {
|
||||||
StringChunk chunk = new StringChunk(0x1000, Types.UNICODE_STRING);
|
StringChunk chunk = new StringChunk(0x1000, Types.UNICODE_STRING);
|
||||||
assertEquals(chunk.getChunkId(), Chunks.TEXT_BODY);
|
assertEquals(chunk.getChunkId(), MAPIAttribute.BODY.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisplayToChunk() {
|
public void testDisplayToChunk() {
|
||||||
StringChunk chunk = new StringChunk(0x0E04, Types.UNICODE_STRING);
|
StringChunk chunk = new StringChunk(0x0E04, Types.UNICODE_STRING);
|
||||||
assertEquals(chunk.getChunkId(), Chunks.DISPLAY_TO);
|
assertEquals(chunk.getChunkId(), MAPIAttribute.DISPLAY_TO.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testDisplayCCChunk() {
|
public void testDisplayCCChunk() {
|
||||||
StringChunk chunk = new StringChunk(0x0E03, Types.UNICODE_STRING);
|
StringChunk chunk = new StringChunk(0x0E03, Types.UNICODE_STRING);
|
||||||
assertEquals(chunk.getChunkId(), Chunks.DISPLAY_CC);
|
assertEquals(chunk.getChunkId(), MAPIAttribute.DISPLAY_CC.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisplayBCCChunk() {
|
public void testDisplayBCCChunk() {
|
||||||
StringChunk chunk = new StringChunk(0x0E02, Types.UNICODE_STRING);
|
StringChunk chunk = new StringChunk(0x0E02, Types.UNICODE_STRING);
|
||||||
assertEquals(chunk.getChunkId(), Chunks.DISPLAY_BCC);
|
assertEquals(chunk.getChunkId(), MAPIAttribute.DISPLAY_BCC.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSubjectChunk() {
|
public void testSubjectChunk() {
|
||||||
|
@ -60,7 +60,7 @@ public final class TestPOIFSChunkParser extends TestCase {
|
|||||||
(new StringChunk(MAPIAttribute.SUBJECT.id, Types.ASCII_STRING)).getEntryName()
|
(new StringChunk(MAPIAttribute.SUBJECT.id, Types.ASCII_STRING)).getEntryName()
|
||||||
);
|
);
|
||||||
simple.getRoot().getEntry(
|
simple.getRoot().getEntry(
|
||||||
(new StringChunk(Chunks.DISPLAY_FROM, Types.ASCII_STRING)).getEntryName()
|
(new StringChunk(MAPIAttribute.SENDER_NAME.id, Types.ASCII_STRING)).getEntryName()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Now load the file
|
// Now load the file
|
||||||
|
Loading…
Reference in New Issue
Block a user