You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2013/06/04 06:22:05 UTC

svn commit: r1489284 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ZipFile.java test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Author: bodewig
Date: Tue Jun  4 04:22:05 2013
New Revision: 1489284

URL: http://svn.apache.org/r1489284
Log:
COMPRESS-227 return Iterable rather than Iterator in new methods

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java?rev=1489284&r1=1489283&r2=1489284&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java Tue Jun  4 04:22:05 2013
@@ -316,14 +316,14 @@ public class ZipFile {
      * the archive's central directory.
      *
      * @param name name of the entry.
-     * @return the Iterator<ZipArchiveEntry> corresponding to the
+     * @return the Iterable<ZipArchiveEntry> corresponding to the
      * given name
      * @since 1.6
      */
-    public Iterator<ZipArchiveEntry> getEntries(String name) {
+    public Iterable<ZipArchiveEntry> getEntries(String name) {
         List<ZipArchiveEntry> entriesOfThatName = nameMap.get(name);
-        return entriesOfThatName != null ? entriesOfThatName.iterator()
-            : Collections.<ZipArchiveEntry>emptyList().iterator();
+        return entriesOfThatName != null ? entriesOfThatName
+            : Collections.<ZipArchiveEntry>emptyList();
     }
 
     /**
@@ -331,17 +331,17 @@ public class ZipFile {
      * appear within the archive.
      *
      * @param name name of the entry.
-     * @return the Iterator<ZipArchiveEntry> corresponding to the
+     * @return the Iterable<ZipArchiveEntry> corresponding to the
      * given name
      * @since 1.6
      */
-    public Iterator<ZipArchiveEntry> getEntriesInPhysicalOrder(String name) {
+    public Iterable<ZipArchiveEntry> getEntriesInPhysicalOrder(String name) {
         ZipArchiveEntry[] entriesOfThatName = new ZipArchiveEntry[0];
         if (nameMap.containsKey(name)) {
             entriesOfThatName = nameMap.get(name).toArray(entriesOfThatName);
             Arrays.sort(entriesOfThatName, OFFSET_COMPARATOR);
         }
-        return Arrays.asList(entriesOfThatName).iterator();
+        return Arrays.asList(entriesOfThatName);
     }
 
     /**

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1489284&r1=1489283&r2=1489284&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java Tue Jun  4 04:22:05 2013
@@ -217,11 +217,9 @@ public class ZipFileTest extends TestCas
         assertNotNull(zf.getInputStream(ze));
 
         int numberOfEntries = 0;
-        for (Iterator<ZipArchiveEntry> it = zf.getEntries("test1.txt");
-             it.hasNext(); ) {
+        for (ZipArchiveEntry entry : zf.getEntries("test1.txt")) {
             numberOfEntries++;
-            ze = it.next();
-            assertNotNull(zf.getInputStream(ze));
+            assertNotNull(zf.getInputStream(entry));
         }
         assertEquals(2, numberOfEntries);
     }