aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java')
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
index fe15102b2a..29be005b8b 100644
--- a/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
+++ b/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
@@ -19,9 +19,14 @@
package org.apache.poi.poifs.filesystem;
-import java.io.*;
-
-import java.util.*;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.apache.poi.hpsf.ClassID;
import org.apache.poi.poifs.dev.POIFSViewable;
@@ -162,7 +167,6 @@ public class DirectoryNode
* @exception IOException if the document does not exist or the
* name is that of a DirectoryEntry
*/
-
public DocumentInputStream createDocumentInputStream(
final String documentName)
throws IOException
@@ -178,6 +182,33 @@ public class DirectoryNode
}
/**
+ * open a document in the directory's entry's list of entries
+ *
+ * @param documentEntry the document to be opened
+ *
+ * @return a newly opened DocumentInputStream or NDocumentInputStream
+ *
+ * @exception IOException if the document does not exist or the
+ * name is that of a DirectoryEntry
+ */
+ public InputStream createDocumentInputStream(
+ final Entry document)
+ throws IOException
+ {
+ if (!document.isDocumentEntry()) {
+ throw new IOException("Entry '" + document.getName()
+ + "' is not a DocumentEntry");
+ }
+
+ DocumentEntry entry = (DocumentEntry)document;
+ if(_ofilesystem != null) {
+ return new DocumentInputStream(entry);
+ } else {
+ return new NDocumentInputStream(entry);
+ }
+ }
+
+ /**
* create a new DocumentEntry
*
* @param document the new document