]> source.dussan.org Git - poi.git/commitdiff
Pull the Properties-Only document type out to a superclass, so other places (eg unit...
authorNick Burch <nick@apache.org>
Wed, 26 Jun 2013 00:10:43 +0000 (00:10 +0000)
committerNick Burch <nick@apache.org>
Wed, 26 Jun 2013 00:10:43 +0000 (00:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1496680 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java [new file with mode: 0644]
src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java

diff --git a/src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java b/src/java/org/apache/poi/hpsf/HPSFPropertiesOnlyDocument.java
new file mode 100644 (file)
index 0000000..196cabb
--- /dev/null
@@ -0,0 +1,26 @@
+package org.apache.poi.hpsf;
+
+import java.io.OutputStream;
+
+import org.apache.poi.POIDocument;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+
+/**
+ * A version of {@link POIDocument} which allows access to the
+ *  HPSF Properties, but no other document contents.
+ * Normally used when you want to read or alter the Document Properties,
+ *  without affecting the rest of the file
+ */
+public class HPSFPropertiesOnlyDocument extends POIDocument {
+    public HPSFPropertiesOnlyDocument(NPOIFSFileSystem fs) {
+        super(fs.getRoot());
+    }
+    public HPSFPropertiesOnlyDocument(POIFSFileSystem fs) {
+        super(fs);
+    }
+
+    public void write(OutputStream out) {
+        throw new IllegalStateException("Unable to write, only for properties!");
+    }
+}
\ No newline at end of file
index 64e0dafcbb6957c6d8b497cbde9415697bd6cfc0..7907408c0befbd1e72331921c49f96c46cbcabea 100644 (file)
@@ -19,13 +19,13 @@ package org.apache.poi.hpsf.extractor;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.util.Iterator;
 
 import org.apache.poi.POIDocument;
 import org.apache.poi.POITextExtractor;
 import org.apache.poi.hpsf.CustomProperties;
 import org.apache.poi.hpsf.DocumentSummaryInformation;
+import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument;
 import org.apache.poi.hpsf.Property;
 import org.apache.poi.hpsf.SpecialPropertySet;
 import org.apache.poi.hpsf.SummaryInformation;
@@ -47,10 +47,10 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
         super(doc);
     }
     public HPSFPropertiesExtractor(POIFSFileSystem fs) {
-        super(new PropertiesOnlyDocument(fs));
+        super(new HPSFPropertiesOnlyDocument(fs));
     }
     public HPSFPropertiesExtractor(NPOIFSFileSystem fs) {
-        super(new PropertiesOnlyDocument(fs));
+        super(new HPSFPropertiesOnlyDocument(fs));
     }
 
     public String getDocumentSummaryInformationText() {
@@ -143,23 +143,6 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
         throw new IllegalStateException("You already have the Metadata Text Extractor, not recursing!");
     }
 
-    /**
-     * So we can get at the properties of any
-     *  random OLE2 document.
-     */
-    private static final class PropertiesOnlyDocument extends POIDocument {
-        public PropertiesOnlyDocument(NPOIFSFileSystem fs) {
-            super(fs.getRoot());
-        }
-        public PropertiesOnlyDocument(POIFSFileSystem fs) {
-            super(fs);
-        }
-
-        public void write(OutputStream out) {
-            throw new IllegalStateException("Unable to write, only for properties!");
-        }
-    }
-
     public static void main(String[] args) throws IOException {
         for (String file : args) {
             HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(