]> source.dussan.org Git - poi.git/commitdiff
Add a couple more HSMF chunk types, and use Generics in a few places
authorNick Burch <nick@apache.org>
Thu, 7 Jan 2010 12:56:39 +0000 (12:56 +0000)
committerNick Burch <nick@apache.org>
Thu, 7 Jan 2010 12:56:39 +0000 (12:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@896868 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java
src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java

index ae7e77b70dfaa5678dbb9778cb20d44f7d8e9e17..68dcc0728013cb45bea4f3b7cd6f41d5360829df 100644 (file)
@@ -44,17 +44,30 @@ public final class Chunks {
        public StringChunk conversationTopic;
        /** Type of server that the message originated from (SMTP, etc). */
        public StringChunk sentByServerType;
+       /** TODO */
+       public StringChunk dateChunk; 
+       /** TODO */
+       public StringChunk emailFromChunk; 
+       /** TODO */
+       public StringChunk recipientSearchChunk; 
+       /** TODO */
+       public StringChunk recipientEmailChunk; 
 
        private Chunks(boolean newStringType) {
-               messageClass = new StringChunk(0x001A, newStringType);
-               textBodyChunk = new StringChunk(0x1000, newStringType);
-               subjectChunk = new StringChunk(0x0037, newStringType);
-               displayToChunk = new StringChunk(0x0E04, newStringType);
-               displayFromChunk = new StringChunk(0x0C1A, newStringType);
-               displayCCChunk = new StringChunk(0x0E03, newStringType);
-               displayBCCChunk = new StringChunk(0x0E02, newStringType);
+               messageClass      = new StringChunk(0x001A, newStringType);
+               subjectChunk      = new StringChunk(0x0037, newStringType);
+               dateChunk         = new StringChunk(0x0047, newStringType);
                conversationTopic = new StringChunk(0x0070, newStringType);
-               sentByServerType = new StringChunk(0x0075, newStringType);
+               sentByServerType =  new StringChunk(0x0075, newStringType);
+               // RECEIVEDEMAIL = 76
+               displayToChunk    = new StringChunk(0x0E04, newStringType);
+               displayFromChunk  = new StringChunk(0x0C1A, newStringType);
+               emailFromChunk    = new StringChunk(0x0C1F, newStringType);
+               displayCCChunk    = new StringChunk(0x0E03, newStringType);
+               displayBCCChunk   = new StringChunk(0x0E02, newStringType);
+               recipientSearchChunk = new StringChunk(0x300B, newStringType);
+               recipientEmailChunk = new StringChunk(0x39FE, newStringType);
+               textBodyChunk     = new StringChunk(0x1000, newStringType);
        }
 
        public static Chunks getInstance(boolean newStringType) {
index 2949ba19081b4250ed7d12fd685fd79221ffac03..3deaa97e24a9cede80fc07cbdd8bad719664c98c 100644 (file)
@@ -20,10 +20,14 @@ package org.apache.poi.hsmf.datatypes;
 public final class Types {
        public static int BINARY = 0x0102;
 
-       /** A string, until Outlook 3.0 */
-       public static int OLD_STRING = 0x001E;
-       /** A string, from Outlook 3.0 onwards */
-       public static int NEW_STRING = 0x001F;
+       /** 
+        * An 8-bit string, probably in US-ASCII, but don't quote us...
+        * Normally used for everything before Outlook 3.0, and some
+        *  fields in Outlook 3.0  
+        */
+       public static int ASCII_STRING = 0x001E;
+       /** A string, from Outlook 3.0 onwards. Normally unicode */
+       public static int UNICODE_STRING = 0x001F;
 
        public static int LONG = 0x0003;
        public static int TIME = 0x0040;
index 47af9dfc523fd5d9ca7ea35fe15cf201546b81fa..a278996a187e197bb62486c01d45d9053fc68209 100644 (file)
@@ -35,6 +35,7 @@ import org.apache.poi.hsmf.exceptions.DirectoryChunkNotFoundException;
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.DocumentNode;
+import org.apache.poi.poifs.filesystem.Entry;
 import org.apache.poi.poifs.filesystem.POIFSDocument;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.property.DirectoryProperty;
@@ -77,7 +78,7 @@ public final class POIFSChunkParser {
        public void reparseFileSystem() throws IOException {
                // first clear this object of all chunks
                DirectoryEntry root = this.fs.getRoot();
-               Iterator iter = root.getEntries();
+               Iterator<Entry> iter = root.getEntries();
 
                this.directoryMap = this.processPOIIterator(iter);
        }
@@ -219,33 +220,24 @@ public final class POIFSChunkParser {
         * @return
         * @throws IOException
         */
-       private HashMap processPOIIterator(Iterator iter) throws IOException {
-               HashMap currentNode = new HashMap();
+       private HashMap<String, HashMap<?,?>> processPOIIterator(Iterator<Entry> iter) throws IOException {
+               HashMap<String, HashMap<?,?>> currentNode = new HashMap<String, HashMap<?,?>>();
 
                while(iter.hasNext()) {
-                       Object obj = iter.next();
-                       if(obj instanceof DocumentNode) {
-                               this.processDocumentNode((DocumentNode)obj, currentNode);
-                       } else if(obj instanceof DirectoryNode) {
-                               String blockName = ((DirectoryNode)obj).getName();
-                               Iterator viewIt = null;
-                               if( ((DirectoryNode)obj).preferArray()) {
-                                       Object[] arr = ((DirectoryNode)obj).getViewableArray();
-                                       ArrayList viewList = new ArrayList(arr.length);
-
-                                       for(int i = 0; i < arr.length; i++) {
-                                               viewList.add(arr[i]);
-                                       }
-                                       viewIt = viewList.iterator();
-                               } else {
-                                               viewIt = ((DirectoryNode)obj).getViewableIterator();
-                               }
-                               //store the next node on the hashmap
-                               currentNode.put(blockName, processPOIIterator(viewIt));
-                       } else if(obj instanceof DirectoryProperty) {
+                       Entry entry = iter.next();
+                       if(entry instanceof DocumentNode) {
+                               this.processDocumentNode((DocumentNode)entry, currentNode);
+                       } else if(entry instanceof DirectoryNode) {
+                          DirectoryNode dir = (DirectoryNode)entry;
+                          
+                               String blockName = dir.getName();
+                               
+                               // Recurse down, storing on the hashmap
+                               currentNode.put(blockName, processPOIIterator(dir.getEntries()));
+                       } else if(entry instanceof DirectoryProperty) {
                                //don't do anything with the directory property chunk...
                        } else {
-                                       System.err.println("Unknown node: " + obj.toString());
+                                       System.err.println("Unknown node: " + entry.toString());
                        }
                }
                return currentNode;