commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1308103 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/zip/ test/java/org/apache/commons/compress/ test/java/org/apache/commons/compress/archivers/ test/java/org/apache/commons/compress/archivers/zip/
Date Sun, 01 Apr 2012 13:19:04 GMT
Author: ggregory
Date: Sun Apr  1 13:19:03 2012
New Revision: 1308103

URL: http://svn.apache.org/viewvc?rev=1308103&view=rev
Log:
Convert to enhanced for loop.

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ArchiveReadTests.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ExtraFieldUtils.java
Sun Apr  1 13:19:03 2012
@@ -197,8 +197,8 @@ public class ExtraFieldUtils {
             lastIsUnparseableHolder ? data.length - 1 : data.length;
 
         int sum = WORD * regularExtraFieldCount;
-        for (int i = 0; i < data.length; i++) {
-            sum += data[i].getLocalFileDataLength().getValue();
+        for (ZipExtraField element : data) {
+            sum += element.getLocalFileDataLength().getValue();
         }
 
         byte[] result = new byte[sum];
@@ -231,8 +231,8 @@ public class ExtraFieldUtils {
             lastIsUnparseableHolder ? data.length - 1 : data.length;
 
         int sum = WORD * regularExtraFieldCount;
-        for (int i = 0; i < data.length; i++) {
-            sum += data[i].getCentralDirectoryLength().getValue();
+        for (ZipExtraField element : data) {
+            sum += element.getCentralDirectoryLength().getValue();
         }
         byte[] result = new byte[sum];
         int start = 0;

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java
Sun Apr  1 13:19:03 2012
@@ -290,11 +290,11 @@ public class ZipArchiveEntry extends jav
      */
     public void setExtraFields(ZipExtraField[] fields) {
         extraFields = new LinkedHashMap<ZipShort, ZipExtraField>();
-        for (int i = 0; i < fields.length; i++) {
-            if (fields[i] instanceof UnparseableExtraFieldData) {
-                unparseableExtra = (UnparseableExtraFieldData) fields[i];
+        for (ZipExtraField field : fields) {
+            if (field instanceof UnparseableExtraFieldData) {
+                unparseableExtra = (UnparseableExtraFieldData) field;
             } else {
-                extraFields.put(fields[i].getHeaderId(), fields[i]);
+                extraFields.put(field.getHeaderId(), field);
             }
         }
         setExtra();
@@ -614,21 +614,21 @@ public class ZipArchiveEntry extends jav
         if (extraFields == null) {
             setExtraFields(f);
         } else {
-            for (int i = 0; i < f.length; i++) {
+            for (ZipExtraField element : f) {
                 ZipExtraField existing;
-                if (f[i] instanceof UnparseableExtraFieldData) {
+                if (element instanceof UnparseableExtraFieldData) {
                     existing = unparseableExtra;
                 } else {
-                    existing = getExtraField(f[i].getHeaderId());
+                    existing = getExtraField(element.getHeaderId());
                 }
                 if (existing == null) {
-                    addExtraField(f[i]);
+                    addExtraField(element);
                 } else {
                     if (local) {
-                        byte[] b = f[i].getLocalFileDataData();
+                        byte[] b = element.getLocalFileDataData();
                         existing.parseFromLocalFileData(b, 0, b.length);
                     } else {
-                        byte[] b = f[i].getCentralDirectoryData();
+                        byte[] b = element.getCentralDirectoryData();
                         existing.parseFromCentralDirectoryData(b, 0, b.length);
                     }
                 }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/AbstractTestCase.java
Sun Apr  1 13:19:03 2012
@@ -27,7 +27,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 
@@ -89,14 +88,14 @@ public abstract class AbstractTestCase e
     protected static void rmdir(File f) {
         String[] s = f.list();
         if (s != null) {
-            for (int i = 0; i < s.length; i++) {
-                final File file = new File(f, s[i]);
+            for (String element : s) {
+                final File file = new File(f, element);
                 if (file.isDirectory()){
                     rmdir(file);
                 }
                 boolean ok = tryHardToDelete(file);
                 if (!ok && file.exists()){
-                    System.out.println("Failed to delete "+s[i]+" in "+f.getPath());
+                    System.out.println("Failed to delete "+element+" in "+f.getPath());
                 }
             }
         }
@@ -346,8 +345,7 @@ public abstract class AbstractTestCase e
             }
             in.close();
             if (expected != null && expected.size() > 0) {
-                for (Iterator<String> iterator = expected.iterator(); iterator.hasNext();)
{
-                    String name = iterator.next();
+                for (String name : expected) {
                     fail("Expected entry: " + name);
                 }
             }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ArchiveReadTests.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ArchiveReadTests.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ArchiveReadTests.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/ArchiveReadTests.java
Sun Apr  1 13:19:03 2012
@@ -73,8 +73,7 @@ public class ArchiveReadTests extends Ab
         }
         br.close();
         File[]files=arcdir.listFiles();
-        for (int i=0; i<files.length; i++){
-            final File file = files[i];
+        for (final File file : files) {
             if (file.getName().endsWith(".txt")){
                 continue;
             }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/IOMethodsTest.java
Sun Apr  1 13:19:03 2012
@@ -101,8 +101,8 @@ public class IOMethodsTest extends Abstr
         aos2.putArchiveEntry(entry);
         ArchiveOutputStream aos3 = factory.createArchiveOutputStream(archiverName, out3);
         aos3.putArchiveEntry(entry);
-        for (int i=0; i<byteTest.length; i++){
-            aos1.write(byteTest[i]);
+        for (byte element : byteTest) {
+            aos1.write(element);
         }
         aos1.closeArchiveEntry();
         aos1.close();

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/LongPathTest.java
Sun Apr  1 13:19:03 2012
@@ -78,8 +78,7 @@ public class LongPathTest extends Abstra
         }
         br.close();
         File[]files=arcdir.listFiles();
-        for (int i=0; i<files.length; i++){
-            final File file = files[i];
+        for (final File file : files) {
             if (file.getName().endsWith(".txt")){
                 continue;
             }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java?rev=1308103&r1=1308102&r2=1308103&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Maven221MultiVolumeTest.java
Sun Apr  1 13:19:03 2012
@@ -78,8 +78,8 @@ public class Maven221MultiVolumeTest ext
 
             // these are the entries that are supposed to be processed
             // correctly without any problems
-            for (int i = 0; i < ENTRIES.length; i++) {
-                assertEquals(ENTRIES[i], zi.getNextEntry().getName());
+            for (String element : ENTRIES) {
+                assertEquals(element, zi.getNextEntry().getName());
             }
 
             // this is the last entry that is truncated



Mime
View raw message