ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r1326760 [1/2] - in /ant/core/trunk/src: main/org/apache/tools/ant/helper/ main/org/apache/tools/ant/taskdefs/ main/org/apache/tools/ant/taskdefs/condition/ main/org/apache/tools/ant/taskdefs/email/ main/org/apache/tools/ant/taskdefs/option...
Date Mon, 16 Apr 2012 19:30:21 GMT
Author: jglick
Date: Mon Apr 16 19:30:18 2012
New Revision: 1326760

URL: http://svn.apache.org/viewvc?rev=1326760&view=rev
Log:
#52829: ResourceCollection now Iterable<Resource>.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/CloseResources.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Replace.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SignJar.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Truncate.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Unpack.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/PropertySet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ResourceCollection.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Difference.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FailFast.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/First.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Intersect.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Last.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceList.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Restrict.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Sort.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ZipResource.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/CollectionUtils.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/ConcatResourceInputStream.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipExtraFieldTest.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Mon Apr 16 19:30:18 2012
@@ -104,7 +104,7 @@ public class ProjectHelper2 extends Proj
      */
     public UnknownElement parseAntlibDescriptor(Project containingProject,
                                                 Resource resource) {
-        URLProvider up = (URLProvider) resource.as(URLProvider.class);
+        URLProvider up = resource.as(URLProvider.class);
         if (up == null) {
             throw new BuildException("Unsupported resource type: " + resource);
         }
@@ -235,12 +235,12 @@ public class ProjectHelper2 extends Proj
             url = (URL) source;
         } else if (source instanceof Resource) {
             FileProvider fp =
-                (FileProvider) ((Resource) source).as(FileProvider.class);
+                ((Resource) source).as(FileProvider.class);
             if (fp != null) {
                 buildFile = fp.getFile();
             } else {
                 URLProvider up =
-                    (URLProvider) ((Resource) source).as(URLProvider.class);
+                    ((Resource) source).as(URLProvider.class);
                 if (up != null) {
                     url = up.getURL();
                 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Checksum.java Mon Apr 16 19:30:18 2012
@@ -30,7 +30,6 @@ import java.io.IOException;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Iterator;
 import java.util.Hashtable;
 import java.util.Enumeration;
 import java.util.Set;
@@ -394,9 +393,8 @@ public class Checksum extends MatchingTa
         }
         try {
             if (resources != null) {
-                for (Iterator i = resources.iterator(); i.hasNext();) {
-                    Resource r = (Resource) i.next();
-                    File src = ((FileProvider) r.as(FileProvider.class))
+                for (Resource r : resources) {
+                    File src = r.as(FileProvider.class)
                         .getFile();
                     if (totalproperty != null || todir != null) {
                         // Use '/' to calculate digest based on file name.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/CloseResources.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/CloseResources.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/CloseResources.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/CloseResources.java Mon Apr 16 19:30:18 2012
@@ -20,7 +20,6 @@ package org.apache.tools.ant.taskdefs;
 
 import java.io.IOException;
 import java.net.URL;
-import java.util.Iterator;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
@@ -44,9 +43,8 @@ public class CloseResources extends Task
     }
 
     public void execute() {
-        for (Iterator it = resources.iterator(); it.hasNext(); ) {
-            Resource r = (Resource) it.next();
-            URLProvider up = (URLProvider) r.as(URLProvider.class);
+        for (Resource r : resources) {
+            URLProvider up = r.as(URLProvider.class);
             if (up != null) {
                 URL u = up.getURL();
                 try {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java Mon Apr 16 19:30:18 2012
@@ -814,9 +814,9 @@ public class Concat extends Task impleme
      * Implement ResourceCollection.
      * @return Iterator<Resource>.
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         validate();
-        return Collections.singletonList(new ConcatResource(getResources())).iterator();
+        return Collections.<Resource>singletonList(new ConcatResource(getResources())).iterator();
     }
 
     /**
@@ -905,8 +905,8 @@ public class Concat extends Task impleme
         Restrict noexistRc = new Restrict();
         noexistRc.add(NOT_EXISTS);
         noexistRc.add(rc);
-        for (Iterator i = noexistRc.iterator(); i.hasNext();) {
-            log(i.next() + " does not exist.", Project.MSG_ERR);
+        for (Resource r : noexistRc) {
+            log(r + " does not exist.", Project.MSG_ERR);
         }
         Restrict result = new Restrict();
         result.add(EXISTS);
@@ -918,8 +918,7 @@ public class Concat extends Task impleme
         if (dest == null || forceOverwrite) {
             return false;
         }
-        for (Iterator i = c.iterator(); i.hasNext();) {
-            Resource r = (Resource) i.next();
+        for (Resource r : c) {
             if (SelectorUtils.isOutOfDate(r, dest, FILE_UTILS.getFileTimestampGranularity())) {
                 return false;
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java Mon Apr 16 19:30:18 2012
@@ -517,9 +517,7 @@ public class Copy extends Task {
                                    "Only FileSystem resources are supported.");
                     }
 
-                    Iterator resources = rc.iterator();
-                    while (resources.hasNext()) {
-                        Resource r = (Resource) resources.next();
+                    for (Resource r : rc) {
                         if (!r.isExists()) {
                             String message = "Warning: Could not find resource "
                                 + r.toLongString() + " to copy.";
@@ -535,7 +533,7 @@ public class Copy extends Task {
 
                         File baseDir = NULL_FILE_PLACEHOLDER;
                         String name = r.getName();
-                        FileProvider fp = (FileProvider) r.as(FileProvider.class);
+                        FileProvider fp = r.as(FileProvider.class);
                         if (fp != null) {
                             FileResource fr = ResourceUtils.asFileResource(fp);
                             baseDir = getKeyFile(fr.getBaseDir());
@@ -702,8 +700,8 @@ public class Copy extends Task {
                 if (rc.size() == 0) {
                     throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE);
                 } else if (rc.size() == 1) {
-                    Resource res = (Resource) rc.iterator().next();
-                    FileProvider r = (FileProvider) res.as(FileProvider.class);
+                    Resource res = rc.iterator().next();
+                    FileProvider r = res.as(FileProvider.class);
                     if (file == null) {
                         if (r != null) {
                             file = r.getFile();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Delete.java Mon Apr 16 19:30:18 2012
@@ -95,7 +95,7 @@ public class Delete extends MatchingTask
             this.dirs = dirs;
             Arrays.sort(this.dirs, REVERSE);
         }
-        public Iterator iterator() {
+        public Iterator<Resource> iterator() {
             return new FileResourceIterator(project, basedir, dirs);
         }
         public boolean isFilesystemOnly() { return true; }
@@ -640,7 +640,7 @@ public class Delete extends MatchingTask
                         public int size() {
                             return files.length;
                         }
-                        public Iterator iterator() {
+                        public Iterator<Resource> iterator() {
                             return new FileResourceIterator(getProject(),
                                                             fsDir, files);
                         }
@@ -683,11 +683,10 @@ public class Delete extends MatchingTask
         }
         try {
             if (resourcesToDelete.isFilesystemOnly()) {
-                for (Iterator iter = resourcesToDelete.iterator(); iter.hasNext();) {
+                for (Resource r : resourcesToDelete) {
                     // nonexistent resources could only occur if we already
                     // deleted something from a fileset:
-                    Resource r = (Resource) iter.next();
-                    File f = ((FileProvider) r.as(FileProvider.class))
+                    File f = r.as(FileProvider.class)
                               .getFile();
                     if (!f.exists()) {
                         continue;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/DependSet.java Mon Apr 16 19:30:18 2012
@@ -101,7 +101,7 @@ public class DependSet extends MatchingT
         private HideMissingBasedir(FileSet fs) {
             this.fs = fs;
         }
-        public Iterator iterator() {
+        public Iterator<Resource> iterator() {
             return basedirExists() ? fs.iterator() : Resources.EMPTY_ITERATOR;
         }
         public int size() {
@@ -252,20 +252,20 @@ public class DependSet extends MatchingT
         Restrict r = new Restrict();
         r.add(rsel);
         r.add(rc);
-        for (Iterator i = r.iterator(); i.hasNext();) {
-            log("Warning: " + i.next() + " modified in the future.", Project.MSG_WARN);
+        for (Resource res : r) {
+            log("Warning: " + res + " modified in the future.", Project.MSG_WARN);
         }
     }
 
     private Resource getXest(ResourceCollection rc, ResourceComparator c) {
-        Iterator i = rc.iterator();
+        Iterator<Resource> i = rc.iterator();
         if (!i.hasNext()) {
             return null;
 
         }
-        Resource xest = (Resource) i.next();
+        Resource xest = i.next();
         while (i.hasNext()) {
-            Resource next = (Resource) i.next();
+            Resource next = i.next();
             if (c.compare(xest, next) < 0) {
                 xest = next;
             }
@@ -289,8 +289,7 @@ public class DependSet extends MatchingT
 
     private void logMissing(ResourceCollection missing, String what) {
         if (verbose) {
-            for (Iterator i = missing.iterator(); i.hasNext(); ) {
-                Resource r = (Resource) i.next();
+            for (Resource r : missing) {
                 log("Expected " + what + " " + r.toLongString()
                     + " is missing.");
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Echo.java Mon Apr 16 19:30:18 2012
@@ -103,7 +103,7 @@ public class Echo extends Task {
             throw new BuildException("Cannot set > 1 output target");
         }
         this.output = output;
-        FileProvider fp = (FileProvider) output.as(FileProvider.class);
+        FileProvider fp = output.as(FileProvider.class);
         this.file = fp != null ? fp.getFile() : null;
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java Mon Apr 16 19:30:18 2012
@@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs;
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Vector;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
@@ -417,9 +416,7 @@ public class ExecuteOn extends ExecTask 
             }
 
             if (resources != null) {
-                Iterator iter = resources.iterator();
-                while (iter.hasNext()) {
-                    Resource res = (Resource) iter.next();
+                for (Resource res : resources) {
 
                     if (!res.isExists() && ignoreMissing) {
                         continue;
@@ -427,7 +424,7 @@ public class ExecuteOn extends ExecTask 
 
                     File base = null;
                     String name = res.getName();
-                    FileProvider fp = (FileProvider) res.as(FileProvider.class);
+                    FileProvider fp = res.as(FileProvider.class);
                     if (fp != null) {
                         FileResource fr = ResourceUtils.asFileResource(fp);
                         base = fr.getBaseDir();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Expand.java Mon Apr 16 19:30:18 2012
@@ -132,15 +132,13 @@ public class Expand extends Task {
                 expandFile(FILE_UTILS, source, dest);
             }
         }
-        Iterator iter = resources.iterator();
-        while (iter.hasNext()) {
-            Resource r = (Resource) iter.next();
+        for (Resource r : resources) {
             if (!r.isExists()) {
                 log("Skipping '" + r.getName() + "' because it doesn't exist.");
                 continue;
             }
 
-            FileProvider fp = (FileProvider) r.as(FileProvider.class);
+            FileProvider fp = r.as(FileProvider.class);
             if (fp != null) {
                 expandFile(FILE_UTILS, fp.getFile(), dest);
             } else {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java Mon Apr 16 19:30:18 2012
@@ -29,7 +29,6 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Date;
-import java.util.Iterator;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -84,9 +83,8 @@ public class Get extends Task {
     public void execute() throws BuildException {
         checkAttributes();
 
-        for (Iterator iter = sources.iterator(); iter.hasNext(); ) {
-            Resource r = (Resource) iter.next();
-            URLProvider up = (URLProvider) r.as(URLProvider.class);
+        for (Resource r : sources) {
+            URLProvider up = r.as(URLProvider.class);
             URL source = up.getURL();
 
             File dest = destination;
@@ -157,9 +155,8 @@ public class Get extends Task {
     public boolean doGet(int logLevel, DownloadProgress progress)
             throws IOException {
         checkAttributes();
-        for (Iterator iter = sources.iterator(); iter.hasNext(); ) {
-            Resource r = (Resource) iter.next();
-            URLProvider up = (URLProvider) r.as(URLProvider.class);
+        for (Resource r : sources) {
+            URLProvider up = r.as(URLProvider.class);
             URL source = up.getURL();
             return doGet(source, destination, logLevel, progress);
         }
@@ -251,8 +248,8 @@ public class Get extends Task {
             throw new BuildException("at least one source is required",
                                      getLocation());
         }
-        for (Iterator iter = sources.iterator(); iter.hasNext(); ) {
-            Object up = ((Resource) iter.next()).as(URLProvider.class);
+        for (Resource r : sources) {
+            URLProvider up = r.as(URLProvider.class);
             if (up == null) {
                 throw new BuildException("Only URLProvider resources are"
                                          + " supported", getLocation());

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ImportTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ImportTask.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ImportTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ImportTask.java Mon Apr 16 19:30:18 2012
@@ -159,8 +159,8 @@ public class ImportTask extends Task {
         if (fromFileAttribute != null) {
             resources.add(fromFileAttribute);
         }
-        for (Iterator i = resourcesToImport.iterator(); i.hasNext(); ) {
-            importResource(helper, (Resource) i.next());
+        for (Resource r : resourcesToImport) {
+            importResource(helper, r);
         }
     }
 
@@ -184,7 +184,7 @@ public class ImportTask extends Task {
         }
 
         File importedFile = null;
-        FileProvider fp = (FileProvider) importedResource.as(FileProvider.class);
+        FileProvider fp = importedResource.as(FileProvider.class);
         if (fp != null) {
             importedFile = fp.getFile();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Mon Apr 16 19:30:18 2012
@@ -2307,11 +2307,8 @@ public class Javadoc extends Task {
                     rc = fs2;
                 }
             }
-            Iterator iter = rc.iterator();
-            while (iter.hasNext()) {
-                Resource r = (Resource) iter.next();
-                sf.addElement(new SourceFile(((FileProvider) r.as(FileProvider.class))
-                                             .getFile()));
+            for (Resource r : rc) {
+                sf.addElement(new SourceFile(r.as(FileProvider.class).getFile()));
             }
         }
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Length.java Mon Apr 16 19:30:18 2012
@@ -230,8 +230,7 @@ public class Length extends Task impleme
     }
 
     private void handleResources(Handler h) {
-        for (Iterator i = resources.iterator(); i.hasNext();) {
-            Resource r = (Resource) i.next();
+        for (Resource r : resources) {
             if (!r.isExists()) {
                 log(r + " does not exist", Project.MSG_WARN);
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadProperties.java Mon Apr 16 19:30:18 2012
@@ -232,7 +232,7 @@ public class LoadProperties extends Task
             throw new BuildException(
                     "only single-element resource collections are supported");
         }
-        src = (Resource) a.iterator().next();
+        src = a.iterator().next();
     }
 
     private synchronized JavaResource getRequiredJavaResource() {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/LoadResource.java Mon Apr 16 19:30:18 2012
@@ -229,7 +229,7 @@ public class LoadResource extends Task {
             throw new BuildException("only single argument resource collections"
                                      + " are supported");
         }
-        src = (Resource) a.iterator().next();
+        src = a.iterator().next();
     }
 
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Pack.java Mon Apr 16 19:30:18 2012
@@ -75,7 +75,7 @@ public abstract class Pack extends Task 
         if (src.isDirectory()) {
             throw new BuildException("the source can't be a directory");
         }
-        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        FileProvider fp = src.as(FileProvider.class);
         if (fp != null) {
             source = fp.getFile();
         } else if (!supportsNonFileResources()) {
@@ -98,7 +98,7 @@ public abstract class Pack extends Task 
                     + " cannot handle multiple resources at once. (" + a.size()
                     + " resources were selected.)");
         }
-        setSrcResource((Resource) a.iterator().next());
+        setSrcResource(a.iterator().next());
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PathConvert.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PathConvert.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PathConvert.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PathConvert.java Mon Apr 16 19:30:18 2012
@@ -32,6 +32,7 @@ import org.apache.tools.ant.types.Mapper
 import org.apache.tools.ant.types.Reference;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.resources.Resources;
 import org.apache.tools.ant.types.resources.Union;
 import org.apache.tools.ant.util.FileNameMapper;
@@ -361,8 +362,8 @@ public class PathConvert extends Task {
             ResourceCollection resources = isPreserveDuplicates() ? (ResourceCollection) path : new Union(path);
             List ret = new ArrayList();
             FileNameMapper mapperImpl = mapper == null ? new IdentityMapper() : mapper.getImplementation();
-            for (Iterator iter = resources.iterator(); iter.hasNext(); ) {
-                String[] mapped = mapperImpl.mapFileName(String.valueOf(iter.next()));
+            for (Resource r : resources) {
+                String[] mapped = mapperImpl.mapFileName(String.valueOf(r));
                 for (int m = 0; mapped != null && m < mapped.length; ++m) {
                     ret.add(mapped[m]);
                 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Replace.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Replace.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Replace.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Replace.java Mon Apr 16 19:30:18 2012
@@ -541,10 +541,9 @@ public class Replace extends MatchingTas
             }
 
             if (resources != null) {
-                for (Iterator i = resources.iterator(); i.hasNext(); ) {
+                for (Resource r : resources) {
                     FileProvider fp =
-                        (FileProvider) ((Resource) i.next())
-                        .as(FileProvider.class);
+                    r.as(FileProvider.class);
                     processFile(fp.getFile());
                 }
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java Mon Apr 16 19:30:18 2012
@@ -597,9 +597,7 @@ public class SQLExec extends JDBCTask {
 
             if (resources != null) {
                 // deal with the resources
-                Iterator iter = resources.iterator();
-                while (iter.hasNext()) {
-                    Resource r = (Resource) iter.next();
+                for (Resource r : resources) {
                     // Make a transaction for each resource
                     Transaction t = createTransaction();
                     t.setSrcResource(r);
@@ -623,13 +621,13 @@ public class SQLExec extends JDBCTask {
                         log("Opening PrintStream to output Resource " + output, Project.MSG_VERBOSE);
                         OutputStream os = null;
                         FileProvider fp =
-                            (FileProvider) output.as(FileProvider.class);
+                            output.as(FileProvider.class);
                         if (fp != null) {
                             os = new FileOutputStream(fp.getFile(), append);
                         } else {
                             if (append) {
                                 Appendable a =
-                                    (Appendable) output.as(Appendable.class);
+                                    output.as(Appendable.class);
                                 if (a != null) {
                                     os = a.getAppendOutputStream();
                                 }
@@ -1030,7 +1028,7 @@ public class SQLExec extends JDBCTask {
                 throw new BuildException("only single argument resource "
                                          + "collections are supported.");
             }
-            setSrcResource((Resource) a.iterator().next());
+            setSrcResource(a.iterator().next());
         }
 
         /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SignJar.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SignJar.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SignJar.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SignJar.java Mon Apr 16 19:30:18 2012
@@ -385,11 +385,9 @@ public class SignJar extends AbstractJar
             //and the mapper is ready to map from source dirs to dest files
             //now we iterate through every JAR giving source and dest names
             // deal with the paths
-            Iterator iter = sources.iterator();
-            while (iter.hasNext()) {
-                Resource r = (Resource) iter.next();
+            for (Resource r : sources) {
                 FileResource fr = ResourceUtils
-                    .asFileResource((FileProvider) r.as(FileProvider.class));
+                    .asFileResource(r.as(FileProvider.class));
 
                 //calculate our destination directory; it is either the destDir
                 //attribute, or the base dir of the fileset (for in situ updates)

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java Mon Apr 16 19:30:18 2012
@@ -568,11 +568,9 @@ public class Tar extends MatchingTask {
         } else if (rc.isFilesystemOnly()) {
             HashSet basedirs = new HashSet();
             HashMap basedirToFilesMap = new HashMap();
-            Iterator iter = rc.iterator();
-            while (iter.hasNext()) {
-                Resource res = (Resource) iter.next();
+            for (Resource res : rc) {
                 FileResource r = ResourceUtils
-                    .asFileResource((FileProvider) res.as(FileProvider.class));
+                    .asFileResource(res.as(FileProvider.class));
                 File base = r.getBaseDir();
                 if (base == null) {
                     base = Copy.NULL_FILE_PLACEHOLDER;
@@ -589,7 +587,7 @@ public class Tar extends MatchingTask {
                     files.add(r.getName());
                 }
             }
-            iter = basedirs.iterator();
+            Iterator iter = basedirs.iterator();
             while (iter.hasNext()) {
                 File base = (File) iter.next();
                 Vector f = (Vector) basedirToFilesMap.get(base);
@@ -599,9 +597,9 @@ public class Tar extends MatchingTask {
                           files);
             }
         } else { // non-file resources
-            Iterator iter = rc.iterator();
+            Iterator<Resource> iter = rc.iterator();
             while (upToDate && iter.hasNext()) {
-                Resource r = (Resource) iter.next();
+                Resource r = iter.next();
                 upToDate = archiveIsUpToDate(r);
             }
         }
@@ -667,16 +665,12 @@ public class Tar extends MatchingTask {
                 tarFile(f, tOut, name, tfs);
             }
         } else if (rc.isFilesystemOnly()) {
-            Iterator iter = rc.iterator();
-            while (iter.hasNext()) {
-                Resource r = (Resource) iter.next();
-                File f = ((FileProvider) r.as(FileProvider.class)).getFile();
+            for (Resource r : rc) {
+                File f = r.as(FileProvider.class).getFile();
                 tarFile(f, tOut, f.getName(), tfs);
             }
         } else { // non-file resources
-            Iterator iter = rc.iterator();
-            while (iter.hasNext()) {
-                Resource r = (Resource) iter.next();
+            for (Resource r : rc) {
                 tarResource(r, tOut, r.getName(), tfs);
             }
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java Mon Apr 16 19:30:18 2012
@@ -296,10 +296,8 @@ public class Touch extends Task {
             return;
         }
         // deal with the resource collections
-        Iterator iter = resources.iterator();
-        while (iter.hasNext()) {
-            Resource r = (Resource) iter.next();
-            Touchable t = (Touchable) r.as(Touchable.class);
+        for (Resource r : resources) {
+            Touchable t = r.as(Touchable.class);
             if (t == null) {
                 throw new BuildException("Can't touch " + r);
             }
@@ -341,12 +339,12 @@ public class Touch extends Task {
 
     private void touch(Resource r, long defaultTimestamp) {
         if (fileNameMapper == null) {
-            FileProvider fp = (FileProvider) r.as(FileProvider.class);
+            FileProvider fp = r.as(FileProvider.class);
             if (fp != null) {
                 // use this to create file and deal with non-writable files
                 touch(fp.getFile(), defaultTimestamp);
             } else {
-                ((Touchable) r.as(Touchable.class)).touch(defaultTimestamp);
+                r.as(Touchable.class).touch(defaultTimestamp);
             }
         } else {
             String[] mapped = fileNameMapper.mapFileName(r.getName());

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Truncate.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Truncate.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Truncate.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Truncate.java Mon Apr 16 19:30:18 2012
@@ -126,9 +126,8 @@ public class Truncate extends Task {
         if (path == null) {
             throw new BuildException(NO_CHILD);
         }
-        for (Iterator it = path.iterator(); it.hasNext();) {
-            Resource r = (Resource) it.next();
-            File f = ((FileProvider) r.as(FileProvider.class)).getFile();
+        for (Resource r : path) {
+            File f = r.as(FileProvider.class).getFile();
             if (shouldProcess(f)) {
                 process(f);
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Unpack.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Unpack.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Unpack.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Unpack.java Mon Apr 16 19:30:18 2012
@@ -91,7 +91,7 @@ public abstract class Unpack extends Tas
             throw new BuildException(
                 "the archive " + src.getName() + " can't be a directory");
         }
-        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        FileProvider fp = src.as(FileProvider.class);
         if (fp != null) {
             source = fp.getFile();
         } else if (!supportsNonFileResources()) {
@@ -113,7 +113,7 @@ public abstract class Unpack extends Tas
             throw new BuildException("only single argument resource collections"
                                      + " are supported as archives");
         }
-        setSrcResource((Resource) a.iterator().next());
+        setSrcResource(a.iterator().next());
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java Mon Apr 16 19:30:18 2012
@@ -89,10 +89,8 @@ public class VerifyJar extends AbstractJ
 
         try {
             Path sources = createUnifiedSourcePath();
-            Iterator iter = sources.iterator();
-            while (iter.hasNext()) {
-                Resource r = (Resource) iter.next();
-                FileProvider fr = (FileProvider) r.as(FileProvider.class);
+            for (Resource r : sources) {
+                FileProvider fr = r.as(FileProvider.class);
                 verifyOneJar(fr.getFile());
             }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java Mon Apr 16 19:30:18 2012
@@ -19,7 +19,6 @@ package org.apache.tools.ant.taskdefs;
 
 import java.io.File;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.Vector;
 import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.BuildException;
@@ -277,7 +276,7 @@ public class XSLTProcess extends Matchin
             handleError("The style element must be specified with exactly one"
                         + " nested resource.");
         } else {
-            setXslResource((Resource) rc.iterator().next());
+            setXslResource(rc.iterator().next());
         }
     }
 
@@ -749,15 +748,13 @@ public class XSLTProcess extends Matchin
      * @since Ant 1.7
      */
     private void processResources(Resource stylesheet) {
-        Iterator iter = resources.iterator();
-        while (iter.hasNext()) {
-            Resource r = (Resource) iter.next();
+        for (Resource r : resources) {
             if (!r.isExists()) {
                 continue;
             }
             File base = baseDir;
             String name = r.getName();
-            FileProvider fp = (FileProvider) r.as(FileProvider.class);
+            FileProvider fp = r.as(FileProvider.class);
             if (fp != null) {
                 FileResource f = ResourceUtils.asFileResource(fp);
                 base = f.getBaseDir();
@@ -1173,7 +1170,7 @@ public class XSLTProcess extends Matchin
                 // a resource, but we can set it as a file. So,
                 // we make an attempt to get it as a file
                 FileProvider fp =
-                    (FileProvider) stylesheet.as(FileProvider.class);
+                    stylesheet.as(FileProvider.class);
                 if (fp != null) {
                     liaison.setStylesheet(fp.getFile());
                 } else {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java Mon Apr 16 19:30:18 2012
@@ -244,7 +244,7 @@ public class XmlProperty extends org.apa
               DocumentBuilder builder = factory.newDocumentBuilder();
               builder.setEntityResolver(getEntityResolver());
               Document document = null;
-              FileProvider fp = (FileProvider) src.as(FileProvider.class);
+              FileProvider fp = src.as(FileProvider.class);
               if (fp != null) {
                   document = builder.parse(fp.getFile());
               } else {
@@ -591,7 +591,7 @@ public class XmlProperty extends org.apa
             throw new BuildException(
                     "only single argument resource collections are supported as archives");
         }
-        setSrcResource((Resource) a.iterator().next());
+        setSrcResource(a.iterator().next());
     }
 
     /**
@@ -670,7 +670,7 @@ public class XmlProperty extends org.apa
      * @return the file attribute.
      */
     protected File getFile () {
-        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        FileProvider fp = src.as(FileProvider.class);
         return fp != null ? fp.getFile() : null;
     }
 
@@ -681,7 +681,7 @@ public class XmlProperty extends org.apa
         // delegate this way around to support subclasses that
         // overwrite getFile
         File f = getFile();
-        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        FileProvider fp = src.as(FileProvider.class);
         return f == null ? src : fp != null
                 && fp.getFile().equals(f) ? src : new FileResource(f);
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Zip.java Mon Apr 16 19:30:18 2012
@@ -1077,7 +1077,7 @@ public class Zip extends MatchingTask {
                 continue;
             }
             File base = null;
-            FileProvider fp = (FileProvider) resources[i].as(FileProvider.class);
+            FileProvider fp = resources[i].as(FileProvider.class);
             if (fp != null) {
                 base = ResourceUtils.asFileResource(fp).getBaseDir();
             }
@@ -1481,7 +1481,7 @@ public class Zip extends MatchingTask {
 
             for (int j = 0; j < initialResources[i].length; j++) {
                 FileProvider fp =
-                    (FileProvider) initialResources[i][j].as(FileProvider.class);
+                    initialResources[i][j].as(FileProvider.class);
                 if (fp != null && zipFile.equals(fp.getFile())) {
                     throw new BuildException("A zip file cannot include "
                                              + "itself", getLocation());
@@ -1585,11 +1585,9 @@ public class Zip extends MatchingTask {
     protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs) {
         Resource[][] result = new Resource[rcs.length][];
         for (int i = 0; i < rcs.length; i++) {
-            Iterator iter = rcs[i].iterator();
             ArrayList dirs = new ArrayList();
             ArrayList files = new ArrayList();
-            while (iter.hasNext()) {
-                Resource r = (Resource) iter.next();
+            for (Resource r : rcs[i]) {
                 if (r.isExists()) {
                     if (r.isDirectory()) {
                         dirs.add(r);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourcesMatch.java Mon Apr 16 19:30:18 2012
@@ -71,7 +71,7 @@ public class ResourcesMatch implements C
                 "You must specify one or more nested resource collections");
         }
         if (resources.size() > 1) {
-            Iterator i = resources.iterator();
+            Iterator<Resource> i = resources.iterator();
             Resource r1 = (Resource) i.next();
             Resource r2 = null;
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/email/EmailTask.java Mon Apr 16 19:30:18 2012
@@ -531,11 +531,8 @@ public class EmailTask extends Task {
             // identify which files should be attached
             Vector files = new Vector();
             if (attachments != null) {
-                Iterator iter = attachments.iterator();
-
-                while (iter.hasNext()) {
-                    Resource r = (Resource) iter.next();
-                    files.addElement(((FileProvider) r.as(FileProvider.class))
+                for (Resource r : attachments) {
+                    files.addElement(r.as(FileProvider.class)
                                      .getFile());
                 }
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java Mon Apr 16 19:30:18 2012
@@ -520,9 +520,9 @@ public class ReplaceRegExp extends Task 
         }
 
         if (resources != null) {
-            for (Iterator i = resources.iterator(); i.hasNext(); ) {
+            for (Resource r : resources) {
                 FileProvider fp =
-                    (FileProvider) ((Resource) i.next()).as(FileProvider.class);
+                    r.as(FileProvider.class);
                 File f = fp.getFile();
 
                 if (f.exists()) {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java Mon Apr 16 19:30:18 2012
@@ -267,11 +267,11 @@ public class TraXLiaison implements XSLT
     }
 
     private String resourceToURI(Resource resource) {
-        FileProvider fp = (FileProvider) resource.as(FileProvider.class);
+        FileProvider fp = resource.as(FileProvider.class);
         if (fp != null) {
             return FILE_UTILS.toURI(fp.getFile().getAbsolutePath());
         }
-        URLProvider up = (URLProvider) resource.as(URLProvider.class);
+        URLProvider up = resource.as(URLProvider.class);
         if (up != null) {
             URL u = up.getURL();
             return String.valueOf(u);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java Mon Apr 16 19:30:18 2012
@@ -144,9 +144,7 @@ public final class BatchTest extends Bas
      */
     private String[] getFilenames() {
         Vector v = new Vector();
-        Iterator iter = resources.iterator();
-        while (iter.hasNext()) {
-            Resource r = (Resource) iter.next();
+        for (Resource r : resources) {
             if (r.isExists()) {
                 String pathname = r.getName();
                 if (pathname.endsWith(".java")) {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java Mon Apr 16 19:30:18 2012
@@ -126,7 +126,7 @@ public abstract class ArchiveFileSet ext
             throw new BuildException("only single argument resource collections"
                                      + " are supported as archives");
         }
-        setSrcResource((Resource) a.iterator().next());
+        setSrcResource(a.iterator().next());
     }
 
     /**
@@ -188,7 +188,7 @@ public abstract class ArchiveFileSet ext
         }
         dieOnCircularReference();
         if (src != null) {
-            FileProvider fp = (FileProvider) src.as(FileProvider.class);
+            FileProvider fp = src.as(FileProvider.class);
             if (fp != null) {
                 return fp.getFile();
             }
@@ -308,7 +308,7 @@ public abstract class ArchiveFileSet ext
      * @return Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((ResourceCollection) (getRef(getProject()))).iterator();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveScanner.java Mon Apr 16 19:30:18 2012
@@ -131,7 +131,7 @@ public abstract class ArchiveScanner ext
      */
     public void setSrc(Resource src) {
         this.src = src;
-        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        FileProvider fp = src.as(FileProvider.class);
         if (fp != null) {
             srcFile = fp.getFile();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/DirSet.java Mon Apr 16 19:30:18 2012
@@ -63,7 +63,7 @@ public class DirSet extends AbstractFile
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((DirSet) getRef(getProject())).iterator();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/FileList.java Mon Apr 16 19:30:18 2012
@@ -188,7 +188,7 @@ public class FileList extends DataType i
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((FileList) getRef(getProject())).iterator();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/FileSet.java Mon Apr 16 19:30:18 2012
@@ -62,7 +62,7 @@ public class FileSet extends AbstractFil
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((FileSet) getRef(getProject())).iterator();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Path.java Mon Apr 16 19:30:18 2012
@@ -121,7 +121,7 @@ public class Path extends DataType imple
          * Create an iterator.
          * @return an iterator.
          */
-        public Iterator iterator() {
+        public Iterator<Resource> iterator() {
             return new FileResourceIterator(getProject(), null, parts);
         }
 
@@ -701,7 +701,7 @@ public class Path extends DataType imple
      * are added to this container while the Iterator is in use.
      * @return a "fail-fast" Iterator.
      */
-    public final synchronized Iterator iterator() {
+    public final synchronized Iterator<Resource> iterator() {
         if (isReference()) {
             return ((Path) getCheckedRef()).iterator();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/PropertySet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/PropertySet.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/PropertySet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/PropertySet.java Mon Apr 16 19:30:18 2012
@@ -502,7 +502,7 @@ public class PropertySet extends DataTyp
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return getRef().iterator();
         }
@@ -514,11 +514,11 @@ public class PropertySet extends DataTyp
         final FileNameMapper m = myMapper == null ? null : myMapper.getImplementation();
         final Iterator iter = names.iterator();
 
-        return new Iterator() {
+        return new Iterator<Resource>() {
             public boolean hasNext() {
                 return iter.hasNext();
             }
-            public Object next() {
+            public Resource next() {
                 PropertyResource p = new PropertyResource(getProject(), (String) iter.next());
                 return m == null ? (Resource) p : new MappedResource(p, m);
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Resource.java Mon Apr 16 19:30:18 2012
@@ -36,7 +36,7 @@ import org.apache.tools.ant.types.resour
  * @since Ant 1.5.2
  * @see org.apache.tools.ant.types.resources.Touchable
  */
-public class Resource extends DataType implements Cloneable, Comparable, ResourceCollection {
+public class Resource extends DataType implements Comparable<Resource>, ResourceCollection {
 
     /** Constant unknown size */
     public static final long UNKNOWN_SIZE = -1;
@@ -270,13 +270,9 @@ public class Resource extends DataType i
      *         is less than, equal to, or greater than the specified Resource.
      * @since Ant 1.6
      */
-    public int compareTo(Object other) {
+    public int compareTo(Resource other) {
         if (isReference()) {
-            return ((Comparable) getCheckedRef()).compareTo(other);
-        }
-        if (!(other instanceof Resource)) {
-            throw new IllegalArgumentException(
-                "Can only be compared with Resources");
+            return ((Resource) getCheckedRef()).compareTo(other);
         }
         return toString().compareTo(other.toString());
     }
@@ -291,7 +287,7 @@ public class Resource extends DataType i
         if (isReference()) {
             return getCheckedRef().equals(other);
         }
-        return other.getClass().equals(getClass()) && compareTo(other) == 0;
+        return other.getClass().equals(getClass()) && compareTo((Resource) other) == 0;
     }
 
     /**
@@ -344,14 +340,14 @@ public class Resource extends DataType i
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         return isReference() ? ((Resource) getCheckedRef()).iterator()
-            : new Iterator() {
+            : new Iterator<Resource>() {
             private boolean done = false;
             public boolean hasNext() {
                 return !done;
             }
-            public Object next() {
+            public Resource next() {
                 if (done) {
                     throw new NoSuchElementException();
                 }
@@ -436,7 +432,7 @@ public class Resource extends DataType i
      *
      * @since Ant 1.8.0
      */
-    public Object as(Class clazz) {
-        return clazz.isAssignableFrom(getClass()) ? this : null;
+    public <T> T as(Class<T> clazz) {
+        return clazz.isAssignableFrom(getClass()) ? clazz.cast(this) : null;
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ResourceCollection.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ResourceCollection.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ResourceCollection.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ResourceCollection.java Mon Apr 16 19:30:18 2012
@@ -24,14 +24,13 @@ import org.apache.tools.ant.types.resour
  * Interface describing a collection of Resources.
  * @since Ant 1.7
  */
-public interface ResourceCollection {
+public interface ResourceCollection extends Iterable<Resource> {
 
     /**
-     * Get an Iterator over the contents of this ResourceCollection, whose elements
-     * are {@link Resource} instances.
-     * @return an Iterator of Resources.
+     * Gets the contents of this collection.
+     * @return all resources in the collection
      */
-    Iterator iterator();
+    Iterator<Resource> iterator();
 
     /**
      * Learn the number of contained Resources.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ZipScanner.java Mon Apr 16 19:30:18 2012
@@ -59,7 +59,7 @@ public class ZipScanner extends ArchiveS
         ZipFile zf = null;
 
         File srcFile = null;
-        FileProvider fp = (FileProvider) src.as(FileProvider.class);
+        FileProvider fp = src.as(FileProvider.class);
         if (fp != null) {
             srcFile = fp.getFile();
         } else {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/AbstractResourceCollectionWrapper.java Mon Apr 16 19:30:18 2012
@@ -85,7 +85,7 @@ public abstract class AbstractResourceCo
      * Fulfill the ResourceCollection contract.
      * @return an Iterator of Resources.
      */
-    public final synchronized Iterator iterator() {
+    public final synchronized Iterator<Resource> iterator() {
         if (isReference()) {
             return ((AbstractResourceCollectionWrapper) getCheckedRef()).iterator();
         }
@@ -101,7 +101,7 @@ public abstract class AbstractResourceCo
      * 
      * @return the iterator on the resource collection
      */
-    protected abstract Iterator createIterator();
+    protected abstract Iterator<Resource> createIterator();
 
     /**
      * Fulfill the ResourceCollection contract.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ArchiveResource.java Mon Apr 16 19:30:18 2012
@@ -110,7 +110,7 @@ public abstract class ArchiveResource ex
             throw new BuildException("only single argument resource collections"
                                      + " are supported as archives");
         }
-        archive = (Resource) a.iterator().next();
+        archive = a.iterator().next();
     }
 
     /**
@@ -199,7 +199,7 @@ public abstract class ArchiveResource ex
      * @return a negative integer, zero, or a positive integer as this Resource
      *         is less than, equal to, or greater than the specified Resource.
      */
-    public int compareTo(Object another) {
+    public int compareTo(Resource another) {
         return this.equals(another) ? 0 : super.compareTo(another);
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Archives.java Mon Apr 16 19:30:18 2012
@@ -86,15 +86,15 @@ public class Archives extends DataType
     /**
      * Merges the nested collections.
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((Archives) getCheckedRef()).iterator();
         }
         dieOnCircularReference();
-        List l = new LinkedList();
-        for (Iterator i = grabArchives(); i.hasNext(); ) {
+        List<Resource> l = new LinkedList<Resource>();
+        for (Iterator<ArchiveFileSet> i = grabArchives(); i.hasNext(); ) {
             l.addAll(CollectionUtils
-                     .asCollection(((ResourceCollection) i.next()).iterator()));
+                     .asCollection(i.next().iterator()));
         }
         return l.iterator();
     }
@@ -144,15 +144,13 @@ public class Archives extends DataType
      * Turns all nested resources into corresponding ArchiveFileSets
      * and returns an iterator over the collected archives.
      */
-    protected Iterator/*<ArchiveFileset>*/ grabArchives() {
-        List l = new LinkedList();
-        for (Iterator iter = zips.iterator(); iter.hasNext(); ) {
-            l.add(configureArchive(new ZipFileSet(),
-                                   (Resource) iter.next()));
-        }
-        for (Iterator iter = tars.iterator(); iter.hasNext(); ) {
-            l.add(configureArchive(new TarFileSet(),
-                                   (Resource) iter.next()));
+    protected Iterator<ArchiveFileSet> grabArchives() {
+        List<ArchiveFileSet> l = new LinkedList<ArchiveFileSet>();
+        for (Resource r : zips) {
+            l.add(configureArchive(new ZipFileSet(), r));
+        }
+        for (Resource r : tars) {
+            l.add(configureArchive(new TarFileSet(), r));
         }
         return l.iterator();
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BCFileSet.java Mon Apr 16 19:30:18 2012
@@ -20,6 +20,7 @@ package org.apache.tools.ant.types.resou
 import java.util.Iterator;
 
 import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Resource;
 
 /**
  * Utility FileSet that includes directories for backwards-compatibility
@@ -46,7 +47,7 @@ public class BCFileSet extends FileSet {
      * @return an Iterator of Resources.
      * @since Ant 1.7
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((FileSet) getRef(getProject())).iterator();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionContainer.java Mon Apr 16 19:30:18 2012
@@ -37,8 +37,8 @@ import org.apache.tools.ant.types.Resour
  */
 public abstract class BaseResourceCollectionContainer
         extends DataType implements ResourceCollection, Cloneable {
-    private List rc = new ArrayList();
-    private Collection coll = null;
+    private List<ResourceCollection> rc = new ArrayList<ResourceCollection>();
+    private Collection<Resource> coll = null;
     private boolean cache = true;
 
     /**
@@ -134,7 +134,7 @@ public abstract class BaseResourceCollec
      * are added to this container while the Iterator is in use.
      * @return a "fail-fast" Iterator.
      */
-    public final synchronized Iterator iterator() {
+    public final synchronized Iterator<Resource> iterator() {
         if (isReference()) {
             return ((BaseResourceCollectionContainer) getCheckedRef()).iterator();
         }
@@ -211,7 +211,7 @@ public abstract class BaseResourceCollec
      * Get the nested ResourceCollections.
      * @return List.
      */
-    public final synchronized List getResourceCollections() {
+    public final synchronized List<ResourceCollection> getResourceCollections() {
         dieOnCircularReference();
         return Collections.unmodifiableList(rc);
     }
@@ -220,7 +220,7 @@ public abstract class BaseResourceCollec
      * Template method for subclasses to return a Collection object of Resources.
      * @return Collection.
      */
-    protected abstract Collection getCollection();
+    protected abstract Collection<Resource> getCollection();
 
     /**
      * Implement clone.  The set of nested resource
@@ -260,7 +260,7 @@ public abstract class BaseResourceCollec
         return sb.toString();
     }
 
-    private synchronized Collection cacheCollection() {
+    private synchronized Collection<Resource> cacheCollection() {
         if (coll == null || !isCache()) {
             coll = getCollection();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/BaseResourceCollectionWrapper.java Mon Apr 16 19:30:18 2012
@@ -19,6 +19,7 @@ package org.apache.tools.ant.types.resou
 
 import java.util.Collection;
 import java.util.Iterator;
+import org.apache.tools.ant.types.Resource;
 
 /**
  * Base class for a ResourceCollection that wraps a single nested
@@ -28,9 +29,9 @@ import java.util.Iterator;
 public abstract class BaseResourceCollectionWrapper
     extends AbstractResourceCollectionWrapper {
 
-    private Collection coll = null;
+    private Collection<Resource> coll = null;
 
-    protected Iterator createIterator() {
+    protected Iterator<Resource> createIterator() {
         return cacheCollection().iterator();
     }
 
@@ -42,9 +43,9 @@ public abstract class BaseResourceCollec
      * Template method for subclasses to return a Collection of Resources.
      * @return Collection.
      */
-    protected abstract Collection getCollection();
+    protected abstract Collection<Resource> getCollection();
 
-    private synchronized Collection cacheCollection() {
+    private synchronized Collection<Resource> cacheCollection() {
         if (coll == null || !isCache()) {
             coll = getCollection();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java Mon Apr 16 19:30:18 2012
@@ -113,13 +113,13 @@ public abstract class ContentTransformin
     /**
      * Suppress FileProvider, re-implement Appendable
      */
-    public Object as(Class clazz) {
+    public <T> T as(Class<T> clazz) {
         if (Appendable.class.isAssignableFrom(clazz)) {
             if (isAppendSupported()) {
                 final Appendable a =
-                    (Appendable) getResource().as(Appendable.class);
+                    getResource().as(Appendable.class);
                 if (a != null) {
-                    return new Appendable() {
+                    return clazz.cast(new Appendable() {
                         public OutputStream getAppendOutputStream()
                                 throws IOException {
                             OutputStream out = a.getAppendOutputStream();
@@ -128,7 +128,7 @@ public abstract class ContentTransformin
                             }
                             return out;
                         }
-                    };
+                    });
                 }
             }
             return null;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Difference.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Difference.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Difference.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Difference.java Mon Apr 16 19:30:18 2012
@@ -17,13 +17,13 @@
  */
 package org.apache.tools.ant.types.resources;
 
-import java.util.List;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.Collection;
-
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 
 /**
@@ -37,31 +37,26 @@ public class Difference extends BaseReso
      * Calculate the difference of the nested ResourceCollections.
      * @return a Collection of Resources.
      */
-    protected Collection getCollection() {
-        List rc = getResourceCollections();
-        int size = rc.size();
+    protected Collection<Resource> getCollection() {
+        List<ResourceCollection> rcs = getResourceCollections();
+        int size = rcs.size();
         if (size < 2) {
             throw new BuildException("The difference of " + size
                 + " resource collection" + ((size == 1) ? "" : "s")
                 + " is undefined.");
         }
-        HashSet hs = new HashSet();
-        ArrayList al = new ArrayList();
-        for (Iterator rcIter = rc.iterator(); rcIter.hasNext();) {
-            for (Iterator r = nextRC(rcIter).iterator(); r.hasNext();) {
-                Object next = r.next();
-                if (hs.add(next)) {
-                    al.add(next);
+        Set<Resource> hs = new HashSet<Resource>();
+        List<Resource> al = new ArrayList<Resource>();
+        for (ResourceCollection rc : rcs) {
+            for (Resource r : rc) {
+                if (hs.add(r)) {
+                    al.add(r);
                 } else {
-                    al.remove(next);
+                    al.remove(r);
                 }
             }
         }
         return al;
     }
 
-    private static ResourceCollection nextRC(Iterator i) {
-        return (ResourceCollection) i.next();
-    }
-
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FailFast.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FailFast.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FailFast.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FailFast.java Mon Apr 16 19:30:18 2012
@@ -23,13 +23,14 @@ import java.util.Iterator;
 import java.util.WeakHashMap;
 import java.util.NoSuchElementException;
 import java.util.ConcurrentModificationException;
+import org.apache.tools.ant.types.Resource;
 
 /**
  * Helper class for ResourceCollections to return Iterators
  * that fail on changes to the object.
  * @since Ant 1.7
  */
-/*package-private*/ class FailFast implements Iterator {
+/*package-private*/ class FailFast implements Iterator<Resource> {
     private static final WeakHashMap MAP = new WeakHashMap();
 
     /**
@@ -67,7 +68,7 @@ import java.util.ConcurrentModificationE
     }
 
     private Object parent;
-    private Iterator wrapped;
+    private Iterator<Resource> wrapped;
 
     /**
      * Construct a new FailFast Iterator wrapping the specified Iterator
@@ -75,7 +76,7 @@ import java.util.ConcurrentModificationE
      * @param o the parent Object.
      * @param i the wrapped Iterator.
      */
-    FailFast(Object o, Iterator i) {
+    FailFast(Object o, Iterator<Resource> i) {
         if (o == null) {
             throw new IllegalArgumentException("parent object is null");
         }
@@ -106,7 +107,7 @@ import java.util.ConcurrentModificationE
      * @return the next element.
      * @throws NoSuchElementException if no more elements.
      */
-    public Object next() {
+    public Resource next() {
         if (wrapped == null || !wrapped.hasNext()) {
             throw new NoSuchElementException();
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java Mon Apr 16 19:30:18 2012
@@ -262,27 +262,24 @@ public class FileResource extends Resour
      * @return a negative integer, zero, or a positive integer as this FileResource
      *         is less than, equal to, or greater than the specified Resource.
      */
-    public int compareTo(Object another) {
+    public int compareTo(Resource another) {
         if (isReference()) {
-            return ((Comparable) getCheckedRef()).compareTo(another);
+            return ((Resource) getCheckedRef()).compareTo(another);
         }
         if (this.equals(another)) {
             return 0;
         }
-        if (another instanceof Resource) {
-            Resource r = (Resource) another;
-            FileProvider otherFP = (FileProvider) r.as(FileProvider.class);
-            if (otherFP != null) {
-                File f = getFile();
-                if (f == null) {
-                    return -1;
-                }
-                File of = otherFP.getFile();
-                if (of == null) {
-                    return 1;
-                }
-                return f.compareTo(of);
+        FileProvider otherFP = another.as(FileProvider.class);
+        if (otherFP != null) {
+            File f = getFile();
+            if (f == null) {
+                return -1;
             }
+            File of = otherFP.getFile();
+            if (of == null) {
+                return 1;
+            }
+            return f.compareTo(of);
         }
         return super.compareTo(another);
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResourceIterator.java Mon Apr 16 19:30:18 2012
@@ -22,12 +22,13 @@ import java.util.Iterator;
 import java.util.NoSuchElementException;
 
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Resource;
 
 /**
  * Iterator of FileResources from filenames.
  * @since Ant 1.7
  */
-public class FileResourceIterator implements Iterator {
+public class FileResourceIterator implements Iterator<Resource> {
     private Project project;
     private File basedir;
     private String[] files;
@@ -121,7 +122,7 @@ public class FileResourceIterator implem
      * Get the next element from this FileResourceIterator.
      * @return the next Object.
      */
-    public Object next() {
+    public Resource next() {
         return nextResource();
     }
 



Mime
View raw message