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 2010/01/07 13:57:52 UTC

svn commit: r896868 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hsmf: datatypes/Chunks.java datatypes/Types.java parsers/POIFSChunkParser.java

Author: nick
Date: Thu Jan  7 12:56:39 2010
New Revision: 896868

URL: http://svn.apache.org/viewvc?rev=896868&view=rev
Log:
Add a couple more HSMF chunk types, and use Generics in a few places

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.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=896868&r1=896867&r2=896868&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 Thu Jan  7 12:56:39 2010
@@ -44,17 +44,30 @@
 	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) {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java?rev=896868&r1=896867&r2=896868&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Types.java Thu Jan  7 12:56:39 2010
@@ -20,10 +20,14 @@
 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;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java?rev=896868&r1=896867&r2=896868&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java Thu Jan  7 12:56:39 2010
@@ -35,6 +35,7 @@
 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 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 @@
 	 * @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;



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