poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1207445 - in /poi/trunk/src: documentation/content/xdocs/status.xml java/org/apache/poi/poifs/filesystem/EntryUtils.java
Date Mon, 28 Nov 2011 17:00:13 GMT
Author: nick
Date: Mon Nov 28 17:00:11 2011
New Revision: 1207445

URL: http://svn.apache.org/viewvc?rev=1207445&view=rev
Log:
Convert POIFS EntryUtils.copyNodes(POFS,POIFS) to use FilteringDirectoryNode, so can exclude
from copying nodes not just directly under the root

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1207445&r1=1207444&r2=1207445&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Nov 28 17:00:11 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="add">POIFS EntryUtils.copyNodes(POFS,POIFS)
now uses FilteringDirectoryNode, so can exclude from copying nodes not just directly under
the root</action>
            <action dev="poi-developers" type="add">POIFS Helper FilteringDirectoryNode,
which wraps a DirectoryEntry and allows certain parts to be ignored</action>
            <action dev="poi-developers" type="fix">52209 - fixed inserting multiple
pictures in XSLF </action>
            <action dev="poi-developers" type="fix">51803 - fixed HSLF TextExtractor
to extract content from master slide </action>

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java?rev=1207445&r1=1207444&r2=1207445&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/EntryUtils.java Mon Nov 28 17:00:11
2011
@@ -59,14 +59,47 @@ public class EntryUtils
     }
 
     /**
-     * Copies nodes from one POIFS to the other minus the excepts
+     * Copies all the nodes from one POIFS Directory to another
      * 
      * @param source
-     *            is the source POIFS to copy from
+     *            is the source Directory to copy from
      * @param target
-     *            is the target POIFS to copy to
+     *            is the target Directory to copy to
+     * @param excepts
+     *            is a list of Strings specifying what nodes NOT to copy
+     */
+    public static void copyNodes(DirectoryEntry sourceRoot,
+            DirectoryEntry targetRoot) throws IOException
+    {
+        for (Entry entry : sourceRoot) {
+            copyNodeRecursively( entry, targetRoot );
+        }
+    }
+
+    /**
+     * Copies nodes from one Directory to the other minus the excepts
+     * 
+     * @param source The filtering source Directory to copy from
+     * @param target The filtering target Directory to copy to
+     */
+    public static void copyNodes( FilteringDirectoryNode filteredSource,
+            FilteringDirectoryNode filteredTarget ) throws IOException
+    {
+        // Nothing special here, just overloaded types to make the
+        //  recommended new way to handle this clearer
+        copyNodes( (DirectoryEntry)filteredSource, (DirectoryEntry)filteredTarget );
+    }
+
+    /**
+     * Copies nodes from one Directory to the other minus the excepts
+     * 
+     * @param source
+     *            is the source Directory to copy from
+     * @param target
+     *            is the target Directory to copy to
      * @param excepts
      *            is a list of Strings specifying what nodes NOT to copy
+     * @deprecated use {@link FilteringDirectoryNode} instead
      */
     public static void copyNodes( DirectoryEntry sourceRoot,
             DirectoryEntry targetRoot, List<String> excepts )
@@ -84,20 +117,36 @@ public class EntryUtils
     }
 
     /**
-     * Copies nodes from one POIFS to the other minus the excepts
+     * Copies all nodes from one POIFS to the other
      * 
      * @param source
      *            is the source POIFS to copy from
      * @param target
      *            is the target POIFS to copy to
-     * @param excepts
-     *            is a list of Strings specifying what nodes NOT to copy
+     */
+    public static void copyNodes( POIFSFileSystem source,
+            POIFSFileSystem target ) throws IOException
+    {
+        copyNodes( source.getRoot(), target.getRoot() );
+    }
+    
+    /**
+     * Copies nodes from one POIFS to the other, minus the excepts.
+     * This delegates the filtering work to {@link FilteringDirectoryNode},
+     *  so excepts can be of the form "NodeToExclude" or
+     *  "FilteringDirectory/ExcludedChildNode"
+     * 
+     * @param source is the source POIFS to copy from
+     * @param target is the target POIFS to copy to
+     * @param excepts is a list of Entry Names to be excluded from the copy
      */
     public static void copyNodes( POIFSFileSystem source,
             POIFSFileSystem target, List<String> excepts ) throws IOException
     {
-        // System.err.println("CopyNodes called");
-        copyNodes( source.getRoot(), target.getRoot(), excepts );
+        copyNodes(
+              new FilteringDirectoryNode(source.getRoot(), excepts),
+              new FilteringDirectoryNode(target.getRoot(), excepts)
+        );
     }
     
     /**



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


Mime
View raw message