poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1590148 - in /poi/trunk/src/java/org/apache/poi/poifs/filesystem: DirectoryEntry.java DirectoryNode.java FilteringDirectoryNode.java
Date Fri, 25 Apr 2014 21:10:53 GMT
Author: nick
Date: Fri Apr 25 21:10:52 2014
New Revision: 1590148

URL: http://svn.apache.org/r1590148
Log:
Add a getEntryNames() method to POIFS/NPOIFS directory entries, to make listing easier

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java?rev=1590148&r1=1590147&r2=1590148&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryEntry.java Fri Apr 25 21:10:52
2014
@@ -23,6 +23,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Iterator;
+import java.util.Set;
 
 import org.apache.poi.hpsf.ClassID;
 
@@ -49,6 +50,17 @@ public interface DirectoryEntry
      */
 
     public Iterator<Entry> getEntries();
+    
+    /**
+     * get the names of all the Entries contained directly in this
+     * instance (in other words, names of children only; no grandchildren
+     * etc).
+     *
+     * @return the names of all the entries that may be retrieved with
+     *         getEntry(String), which may be empty (if this 
+     *         DirectoryEntry is empty)
+     */
+    public Set<String> getEntryNames();
 
     /**
      * is this DirectoryEntry empty?

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java?rev=1590148&r1=1590147&r2=1590148&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java Fri Apr 25 21:10:52
2014
@@ -27,6 +27,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.poi.hpsf.ClassID;
 import org.apache.poi.poifs.dev.POIFSViewable;
@@ -317,6 +318,20 @@ public class DirectoryNode
     {
         return _entries.iterator();
     }
+    
+    /**
+     * get the names of all the Entries contained directly in this
+     * instance (in other words, names of children only; no grandchildren
+     * etc).
+     *
+     * @return the names of all the entries that may be retrieved with
+     *         getEntry(String), which may be empty (if this 
+     *         DirectoryEntry is empty)
+     */
+    public Set<String> getEntryNames()
+    {
+        return _byname.keySet();
+    }
 
     /**
      * is this DirectoryEntry empty?

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java?rev=1590148&r1=1590147&r2=1590148&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/FilteringDirectoryNode.java Fri Apr
25 21:10:52 2014
@@ -114,6 +114,16 @@ public class FilteringDirectoryNode impl
       }
       return size;
    }
+   
+   public Set<String> getEntryNames() {
+       Set<String> names = new HashSet<String>();
+       for (String name : directory.getEntryNames()) {
+           if (!excludes.contains(name)) {
+               names.add(name);
+           }
+       }
+       return names;
+   }
 
    public boolean isEmpty() {
       return (getEntryCount() == 0);



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


Mime
View raw message