Add a couple more HSMF chunk types, and use Generics in a few places

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@896868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2010-01-07 12:56:39 +00:00
parent 8f24725930
commit 643a43720b
3 changed files with 45 additions and 36 deletions

View 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) {

View 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;

View 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);
Entry entry = iter.next();
if(entry instanceof DocumentNode) {
this.processDocumentNode((DocumentNode)entry, currentNode);
} else if(entry instanceof DirectoryNode) {
DirectoryNode dir = (DirectoryNode)entry;
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) {
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;