poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1057712 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hsmf/datatypes/ testcases/org/apache/poi/hsmf/datatypes/ testcases/org/apache/poi/hsmf/parsers/
Date Tue, 11 Jan 2011 16:11:23 GMT
Author: nick
Date: Tue Jan 11 16:11:23 2011
New Revision: 1057712

URL: http://svn.apache.org/viewvc?rev=1057712&view=rev
Log:
More converting of HSMF code to use strongly type attributes

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIAttribute.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java?rev=1057712&r1=1057711&r2=1057712&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java Tue Jan 11 16:11:23
2011
@@ -30,24 +30,6 @@ import java.util.List;
  *  http://msdn.microsoft.com/en-us/library/ms526356%28v=exchg.10%29.aspx
  */
 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. */
    private List<Chunk> allChunks = new ArrayList<Chunk>();
    
@@ -92,50 +74,50 @@ public final class Chunks implements Chu
       if(chunk.getChunkId() == MAPIAttribute.MESSAGE_CLASS.id) {
          messageClass = (StringChunk)chunk;
       }
-      else if(chunk.getChunkId() == MAPIAttribute.SUBJECT.id) {
-         subjectChunk = (StringChunk)chunk;
-      }
-      else if(chunk.getChunkId() == MAPIAttribute.ORIGINAL_SUBJECT.id) {
-         // TODO
+      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;
       }
-      
-      switch(chunk.getChunkId()) {
-      case MESSAGE_ID:
-         messageId = (StringChunk)chunk;
-         break;
-      case CONVERSATION_TOPIC:
-         conversationTopic = (StringChunk)chunk;
-         break;
-      case SENT_BY_SERVER_TYPE:
+      else if(chunk.getChunkId() == MAPIAttribute.RECEIVED_BY_ADDRTYPE.id) {
          sentByServerType = (StringChunk)chunk;
-         break;
-      case MESSAGE_HEADERS:
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.TRANSPORT_MESSAGE_HEADERS.id) {
          messageHeaders = (StringChunk)chunk;
-         break;
-      case DISPLAY_TO:
+      }
+      
+      else if(chunk.getChunkId() == MAPIAttribute.CONVERSATION_TOPIC.id) {
+         conversationTopic = (StringChunk)chunk;
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.SUBJECT.id) {
+         subjectChunk = (StringChunk)chunk;
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.ORIGINAL_SUBJECT.id) {
+         // TODO
+      }
+      
+      else if(chunk.getChunkId() == MAPIAttribute.DISPLAY_TO.id) {
          displayToChunk = (StringChunk)chunk;
-         break;
-      case DISPLAY_FROM:
-         displayFromChunk = (StringChunk)chunk;
-         break;
-      case EMAIL_FROM:
-         emailFromChunk = (StringChunk)chunk;
-         break;
-      case DISPLAY_CC:
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.DISPLAY_CC.id) {
          displayCCChunk = (StringChunk)chunk;
-         break;
-      case DISPLAY_BCC:
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.DISPLAY_BCC.id) {
          displayBCCChunk = (StringChunk)chunk;
-         break;
-      case TEXT_BODY:
+      }
+      
+      else if(chunk.getChunkId() == MAPIAttribute.SENDER_EMAIL_ADDRESS.id) {
+         emailFromChunk = (StringChunk)chunk;
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.SENDER_NAME.id) {
+         displayFromChunk = (StringChunk)chunk;
+      }
+      else if(chunk.getChunkId() == MAPIAttribute.BODY.id) {
          textBodyChunk = (StringChunk)chunk;
-         break;
       }
-
+      
       // And add to the main list
       allChunks.add(chunk);
    }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIAttribute.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIAttribute.java?rev=1057712&r1=1057711&r2=1057712&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIAttribute.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/MAPIAttribute.java Tue Jan
11 16:11:23 2011
@@ -1020,6 +1020,8 @@ public final class MAPIAttribute {
    public static final MAPIAttribute UNKNOWN =
       new MAPIAttribute(-1, -1, "Unknown", null);
    
+   // 0x8??? ones are outlook specific, and not standard MAPI
+   
    /* ---------------------------------------------------------------------  */
    
    public final int id;

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java?rev=1057712&r1=1057711&r2=1057712&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/datatypes/TestChunkData.java Tue
Jan 11 16:11:23 2011
@@ -17,11 +17,6 @@
 
 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;
 
 /**
@@ -58,23 +53,23 @@ public final class TestChunkData extends
 
 	public void testTextBodyChunk() {
 		StringChunk chunk = new StringChunk(0x1000, Types.UNICODE_STRING);
-		assertEquals(chunk.getChunkId(), Chunks.TEXT_BODY);
+		assertEquals(chunk.getChunkId(), MAPIAttribute.BODY.id);
 	}
 
 	public void testDisplayToChunk() {
 		StringChunk chunk = new StringChunk(0x0E04, Types.UNICODE_STRING);
-      assertEquals(chunk.getChunkId(), Chunks.DISPLAY_TO);
+      assertEquals(chunk.getChunkId(), MAPIAttribute.DISPLAY_TO.id);
 	}
 
 
 	public void testDisplayCCChunk() {
 		StringChunk chunk = new StringChunk(0x0E03, Types.UNICODE_STRING);
-      assertEquals(chunk.getChunkId(), Chunks.DISPLAY_CC);
+      assertEquals(chunk.getChunkId(), MAPIAttribute.DISPLAY_CC.id);
 	}
 
 	public void testDisplayBCCChunk() {
 		StringChunk chunk = new StringChunk(0x0E02, Types.UNICODE_STRING);
-      assertEquals(chunk.getChunkId(), Chunks.DISPLAY_BCC);
+      assertEquals(chunk.getChunkId(), MAPIAttribute.DISPLAY_BCC.id);
 	}
 
 	public void testSubjectChunk() {

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java?rev=1057712&r1=1057711&r2=1057712&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
(original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
Tue Jan 11 16:11:23 2011
@@ -60,7 +60,7 @@ public final class TestPOIFSChunkParser 
             (new StringChunk(MAPIAttribute.SUBJECT.id, Types.ASCII_STRING)).getEntryName()
       );
       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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message