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