commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1154517 - in /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress: archivers/tar/TarArchiveInputStream.java changes/ChangeSet.java changes/ChangeSetPerformer.java
Date Sat, 06 Aug 2011 13:38:40 GMT
Author: bodewig
Date: Sat Aug  6 13:38:39 2011
New Revision: 1154517

URL: http://svn.apache.org/viewvc?rev=1154517&view=rev
Log:
foreach loops

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java?rev=1154517&r1=1154516&r2=1154517&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
Sat Aug  6 13:38:39 2011
@@ -28,7 +28,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -305,11 +304,9 @@ public class TarArchiveInputStream exten
          * size
          * uid,uname
          */
-        Iterator hdrs = headers.entrySet().iterator();
-        while(hdrs.hasNext()){
-            Entry ent = (Entry) hdrs.next();
-            String key = (String) ent.getKey();
-            String val = (String) ent.getValue();
+        for (Entry<String, String> ent : headers.entrySet()){
+            String key = ent.getKey();
+            String val = ent.getValue();
             if ("path".equals(key)){
                 currEntry.setName(val);
             } else if ("linkpath".equals(key)){

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java?rev=1154517&r1=1154516&r2=1154517&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSet.java
Sat Aug  6 13:38:39 2011
@@ -97,8 +97,8 @@ public final class ChangeSet {
         }
 
         if (!changes.isEmpty()) {
-            for (Iterator it = changes.iterator(); it.hasNext();) {
-                Change change = (Change) it.next();
+            for (Iterator<Change> it = changes.iterator(); it.hasNext();) {
+                Change change = it.next();
                 if (change.type() == Change.TYPE_ADD
                         && change.getEntry() != null) {
                     ArchiveEntry entry = change.getEntry();
@@ -134,8 +134,8 @@ public final class ChangeSet {
         String source = pChange.targetFile();
 
         if (!changes.isEmpty()) {
-            for (Iterator it = changes.iterator(); it.hasNext();) {
-                Change change = (Change) it.next();
+            for (Iterator<Change> it = changes.iterator(); it.hasNext();) {
+                Change change = it.next();
                 if (change.type() == Change.TYPE_ADD
                         && change.getEntry() != null) {
                     String target = change.getEntry().getName();

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java?rev=1154517&r1=1154516&r2=1154517&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/changes/ChangeSetPerformer.java
Sat Aug  6 13:38:39 2011
@@ -84,8 +84,8 @@ public class ChangeSetPerformer {
         while ((entry = in.getNextEntry()) != null) {
             boolean copy = true;
 
-            for (Iterator it = workingSet.iterator(); it.hasNext();) {
-                Change change = (Change) it.next();
+            for (Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
+                Change change = it.next();
 
                 final int type = change.type();
                 final String name = entry.getName();
@@ -115,8 +115,8 @@ public class ChangeSetPerformer {
         }
         
         // Adds files which hasn't been added from the original and do not have replace mode
on
-        for (Iterator it = workingSet.iterator(); it.hasNext();) {
-            Change change = (Change) it.next();
+        for (Iterator<Change> it = workingSet.iterator(); it.hasNext();) {
+            Change change = it.next();
 
             if (change.type() == Change.TYPE_ADD && 
                 !change.isReplaceMode() && 
@@ -139,12 +139,11 @@ public class ChangeSetPerformer {
      *            the entry to check
      * @return true, if this entry has an deletion change later, false otherwise
      */
-    private boolean isDeletedLater(Set workingSet, ArchiveEntry entry) {
+    private boolean isDeletedLater(Set<Change> workingSet, ArchiveEntry entry) {
         String source = entry.getName();
 
         if (!workingSet.isEmpty()) {
-            for (Iterator it = workingSet.iterator(); it.hasNext();) {
-                Change change = (Change) it.next();
+            for (Change change : workingSet) {
                 final int type = change.type();
                 String target = change.targetFile();
                 if (type == Change.TYPE_DELETE && source.equals(target)) {



Mime
View raw message