You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/07/10 01:29:30 UTC

svn commit: r1752053 - /poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java

Author: onealj
Date: Sun Jul 10 01:29:30 2016
New Revision: 1752053

URL: http://svn.apache.org/viewvc?rev=1752053&view=rev
Log:
move string literals out to array that can be for-looped over

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java?rev=1752053&r1=1752052&r2=1752053&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java Sun Jul 10 01:29:30 2016
@@ -327,19 +327,24 @@ public class ExtractorFactory {
             return new PublisherTextExtractor(poifsDir);
         }
 
-        if (poifsDir.hasEntry("__substg1.0_1000001E") || poifsDir.hasEntry("__substg1.0_1000001F")
-                || poifsDir.hasEntry("__substg1.0_0047001E")
-                || poifsDir.hasEntry("__substg1.0_0047001F")
-                || poifsDir.hasEntry("__substg1.0_0037001E")
-                || poifsDir.hasEntry("__substg1.0_0037001F"))
-        {
-            return new OutlookTextExtactor(poifsDir);
+        final String[] outlookEntryNames = new String[] {
+                // message bodies, saved as plain text (PtypString)
+                // https://msdn.microsoft.com/en-us/library/cc433490(v=exchg.80).aspx 
+                "__substg1.0_1000001E", //PidTagBody
+                "__substg1.0_1000001F", //PidTagBody
+                "__substg1.0_0047001E", //PidTagMessageSubmissionId
+                "__substg1.0_0047001F", //PidTagMessageSubmissionId
+                "__substg1.0_0037001E", //PidTagSubject
+                "__substg1.0_0037001F", //PidTagSubject
+        };
+        for (String entryName : outlookEntryNames) {
+            if (poifsDir.hasEntry(entryName)) {
+                return new OutlookTextExtactor(poifsDir);
+            }
         }
 
-        for (Iterator<Entry> entries = poifsDir.getEntries(); entries.hasNext();) {
-            Entry entry = entries.next();
-
-            if (entry.getName().equals("Package")) {
+        for (String entryName : poifsDir.getEntryNames()) {
+            if (entryName.equals("Package")) {
                 OPCPackage pkg = OPCPackage.open(poifsDir.createDocumentInputStream("Package"));
                 return createExtractor(pkg);
             }



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