ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r1326760 [2/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
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Files.java Mon Apr 16 19:30:18
2012
@@ -27,6 +27,7 @@ import org.apache.tools.ant.BuildExcepti
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.types.Reference;
 import org.apache.tools.ant.types.PatternSet;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.selectors.FileSelector;
 import org.apache.tools.ant.types.selectors.AbstractSelectorContainer;
@@ -38,8 +39,8 @@ import org.apache.tools.ant.types.select
 public class Files extends AbstractSelectorContainer
     implements ResourceCollection {
 
-    private static final Iterator EMPTY_ITERATOR
-        = Collections.EMPTY_SET.iterator();
+    private static final Iterator<Resource> EMPTY_ITERATOR
+        = Collections.<Resource>emptySet().iterator();
 
     private PatternSet defaultPatterns = new PatternSet();
     private Vector additionalPatterns = new Vector();
@@ -309,7 +310,7 @@ public class Files extends AbstractSelec
      * Fulfill the ResourceCollection contract.
      * @return an Iterator of Resources.
      */
-    public synchronized Iterator iterator() {
+    public synchronized Iterator<Resource> iterator() {
         if (isReference()) {
             return getRef().iterator();
         }
@@ -385,7 +386,7 @@ public class Files extends AbstractSelec
         if (isReference()) {
             return getRef().toString();
         }
-        Iterator i = iterator();
+        Iterator<Resource> i = iterator();
         if (!i.hasNext()) {
             return "";
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/First.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/First.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/First.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/First.java Mon Apr 16 19:30:18
2012
@@ -20,6 +20,8 @@ package org.apache.tools.ant.types.resou
 import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
+import org.apache.tools.ant.types.Resource;
 
 /**
  * ResourceCollection that contains the first <code>count</code> elements of
@@ -32,10 +34,10 @@ public class First extends SizeLimitColl
      * Take the first <code>count</code> elements.
      * @return a Collection of Resources.
      */
-    protected Collection getCollection() {
+    protected Collection<Resource> getCollection() {
         int ct = getValidCount();
-        Iterator iter = getResourceCollection().iterator();
-        ArrayList al = new ArrayList(ct);
+        Iterator<Resource> iter = getResourceCollection().iterator();
+        List<Resource> al = new ArrayList<Resource>(ct);
         for (int i = 0; i < ct && iter.hasNext(); i++) {
             al.add(iter.next());
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Intersect.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Intersect.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Intersect.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Intersect.java Mon Apr 16
19:30:18 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 
 /**
@@ -36,16 +37,16 @@ public class Intersect extends BaseResou
      * Calculate the intersection of the nested ResourceCollections.
      * @return a Collection of Resources.
      */
-    protected Collection getCollection() {
-        List rcs = getResourceCollections();
+    protected Collection<Resource> getCollection() {
+        List<ResourceCollection> rcs = getResourceCollections();
         int size = rcs.size();
         if (size < 2) {
             throw new BuildException("The intersection of " + size
                 + " resource collection" + ((size == 1) ? "" : "s")
                 + " is undefined.");
         }
-        ArrayList al = new ArrayList();
-        Iterator rc = rcs.iterator();
+        List<Resource> al = new ArrayList<Resource>();
+        Iterator<ResourceCollection> rc = rcs.iterator();
         al.addAll(collect(rc.next()));
         while (rc.hasNext()) {
             al.retainAll(collect(rc.next()));
@@ -53,10 +54,10 @@ public class Intersect extends BaseResou
         return al;
     }
 
-    private ArrayList collect(Object o) {
-        ArrayList result = new ArrayList();
-        for (Iterator i = ((ResourceCollection) o).iterator(); i.hasNext();) {
-            result.add(i.next());
+    private List<Resource> collect(ResourceCollection rc) {
+        List<Resource> result = new ArrayList<Resource>();
+        for (Resource r : rc) {
+            result.add(r);
         }
         return result;
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/JavaResource.java Mon Apr
16 19:30:18 2012
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.net.URL;
 
 import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Resource;
 
 /**
  * A Resource representation of something loadable via a Java classloader.
@@ -102,9 +103,9 @@ public class JavaResource extends Abstra
      * JavaResource 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 (another.getClass().equals(getClass())) {
             JavaResource otherjr = (JavaResource) another;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Last.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Last.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Last.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Last.java Mon Apr 16 19:30:18
2012
@@ -20,9 +20,11 @@ package org.apache.tools.ant.types.resou
 import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 
 /**
@@ -36,17 +38,17 @@ public class Last extends SizeLimitColle
      * Take the last <code>count</code> elements.
      * @return a Collection of Resources.
      */
-    protected Collection getCollection() {
+    protected Collection<Resource> getCollection() {
         int count = getValidCount();
         ResourceCollection rc = getResourceCollection();
         int i = count;
-        Iterator iter = rc.iterator();
+        Iterator<Resource> iter = rc.iterator();
         int size = rc.size();
         for (; i < size; i++) {
             iter.next();
         }
 
-        ArrayList al = new ArrayList(count);
+        List<Resource> al = new ArrayList<Resource>(count);
         for (; iter.hasNext(); i++) {
             al.add(iter.next());
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/LazyResourceCollectionWrapper.java
Mon Apr 16 19:30:18 2012
@@ -4,7 +4,6 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
-
 import org.apache.tools.ant.types.Resource;
 
 /**
@@ -15,12 +14,12 @@ public class LazyResourceCollectionWrapp
         AbstractResourceCollectionWrapper {
 
     /** List of cached resources */
-    private List cachedResources = new ArrayList();
+    private final List<Resource> cachedResources = new ArrayList<Resource>();
 
     private FilteringIterator filteringIterator;
 
-    protected Iterator createIterator() {
-        Iterator iterator;
+    protected Iterator<Resource> createIterator() {
+        Iterator<Resource> iterator;
         if (isCache()) {
             if (filteringIterator == null) {
                 // no worry of thread safety here, see function's contract
@@ -37,7 +36,7 @@ public class LazyResourceCollectionWrapp
     protected int getSize() {
         // to compute the size, just iterate: the iterator will take care of
         // caching
-        Iterator it = createIterator();
+        Iterator<Resource> it = createIterator();
         int size = 0;
         while (it.hasNext()) {
             it.next();
@@ -57,15 +56,15 @@ public class LazyResourceCollectionWrapp
         return false;
     }
 
-    private class FilteringIterator implements Iterator {
+    private class FilteringIterator implements Iterator<Resource> {
 
         Resource next = null;
 
         boolean ended = false;
 
-        protected final Iterator it;
+        protected final Iterator<Resource> it;
 
-        public FilteringIterator(Iterator it) {
+        public FilteringIterator(Iterator<Resource> it) {
             this.it = it;
         }
 
@@ -78,7 +77,7 @@ public class LazyResourceCollectionWrapp
                     ended = true;
                     return false;
                 }
-                next = (Resource) it.next();
+                next = it.next();
                 if (filterResource(next)) {
                     next = null;
                 }
@@ -86,7 +85,7 @@ public class LazyResourceCollectionWrapp
             return true;
         }
 
-        public Object next() {
+        public Resource next() {
             if (!hasNext()) {
                 throw new UnsupportedOperationException();
             }
@@ -104,11 +103,11 @@ public class LazyResourceCollectionWrapp
      * Iterator that will put in the shared cache array list the selected
      * resources
      */
-    private class CachedIterator implements Iterator {
+    private class CachedIterator implements Iterator<Resource> {
 
         int cusrsor = 0;
 
-        private final Iterator it;
+        private final Iterator<Resource> it;
 
         /**
          * Default constructor
@@ -117,7 +116,7 @@ public class LazyResourceCollectionWrapp
          *            the iterator which will provide the resources to put in
          *            cache
          */
-        public CachedIterator(Iterator it) {
+        public CachedIterator(Iterator<Resource> it) {
             this.it = it;
         }
 
@@ -132,13 +131,13 @@ public class LazyResourceCollectionWrapp
                     return false;
                 }
                 // put in cache the next resource
-                Resource r = (Resource) it.next();
+                Resource r = it.next();
                 cachedResources.add(r);
             }
             return true;
         }
 
-        public Object next() {
+        public Resource next() {
             // first check that we have some to deliver
             if (!hasNext()) {
                 throw new NoSuchElementException();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResource.java Mon Apr
16 19:30:18 2012
@@ -70,7 +70,7 @@ public class MappedResource extends Reso
      * Suppress FileProvider
      * @param clazz the type to implement
      */
-    public Object as(Class clazz) {
+    public <T> T as(Class<T> clazz) {
         return FileProvider.class.isAssignableFrom(clazz) 
                 ? null : getResource().as(clazz);
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/MappedResourceCollection.java
Mon Apr 16 19:30:18 2012
@@ -44,7 +44,7 @@ public class MappedResourceCollection
     private Mapper mapper = null;
     private boolean enableMultipleMappings = false;
     private boolean cache = false;
-    private Collection cachedColl = null;
+    private Collection<Resource> cachedColl = null;
 
     /**
      * Adds the required nested ResourceCollection.
@@ -142,7 +142,7 @@ public class MappedResourceCollection
     /**
      * {@inheritDoc}
      */
-    public Iterator iterator() {
+    public Iterator<Resource> iterator() {
         if (isReference()) {
             return ((MappedResourceCollection) getCheckedRef()).iterator();
         }
@@ -212,19 +212,18 @@ public class MappedResourceCollection
         dieOnCircularReference();
     }
 
-    private synchronized Collection cacheCollection() {
+    private synchronized Collection<Resource> cacheCollection() {
         if (cachedColl == null || !cache) {
             cachedColl = getCollection();
         }
         return cachedColl;
     }
 
-    private Collection getCollection() {
-        Collection collected = new ArrayList();
+    private Collection<Resource> getCollection() {
+        Collection<Resource> collected = new ArrayList<Resource>();
         FileNameMapper m =
             mapper != null ? mapper.getImplementation() : new IdentityMapper();
-        for (Iterator iter = nested.iterator(); iter.hasNext(); ) {
-            Resource r = (Resource) iter.next();
+        for (Resource r : nested) {
             if (enableMultipleMappings) {
                 String[] n = m.mapFileName(r.getName());
                 if (n != null) {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceDecorator.java Mon
Apr 16 19:30:18 2012
@@ -67,7 +67,7 @@ public abstract class ResourceDecorator 
                                      + " are supported");
         }
         setChecked(false);
-        resource = (Resource) a.iterator().next();
+        resource = a.iterator().next();
     }
 
     /**
@@ -159,14 +159,14 @@ public abstract class ResourceDecorator 
     /**
      * {@inheritDoc}
      */
-    public Object as(Class clazz) {
+    public <T> T as(Class<T> clazz) {
         return getResource().as(clazz);
     }
 
     /**
      * {@inheritDoc}
      */
-    public int compareTo(Object other) {
+    public int compareTo(Resource other) {
         if (other == this) {
             return 0;
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceList.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceList.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceList.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ResourceList.java Mon Apr
16 19:30:18 2012
@@ -112,7 +112,7 @@ public class ResourceList extends DataTy
      * 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 ((ResourceList) getCheckedRef()).iterator();
         }
@@ -175,8 +175,8 @@ public class ResourceList extends DataTy
             dieOnCircularReference();
             for (Iterator iter = textDocuments.iterator(); iter.hasNext(); ) {
                 ResourceCollection rc = (ResourceCollection) iter.next();
-                for (Iterator r = rc.iterator(); r.hasNext(); ) {
-                    cachedResources.add(read((Resource) r.next()));
+                for (Resource r : rc) {
+                    cachedResources.add(read(r));
                 }
             }
             cached = true;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Resources.java Mon Apr 16
19:30:18 2012
@@ -31,6 +31,7 @@ import java.util.NoSuchElementException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.util.CollectionUtils;
 
@@ -45,7 +46,7 @@ public class Resources extends DataType 
         public boolean isFilesystemOnly() {
             return true;
         }
-        public Iterator iterator() {
+        public Iterator<Resource> iterator() {
             return EMPTY_ITERATOR;
         }
         public int size() {
@@ -54,8 +55,8 @@ public class Resources extends DataType 
     };
 
     /** static empty Iterator */
-    public static final Iterator EMPTY_ITERATOR = new Iterator() {
-        public Object next() {
+    public static final Iterator<Resource> EMPTY_ITERATOR = new Iterator<Resource>()
{
+        public Resource next() {
             throw new NoSuchElementException();
         }
         public boolean hasNext() {
@@ -66,19 +67,19 @@ public class Resources extends DataType 
         }
     };
 
-    private class MyCollection extends AbstractCollection {
-        private Collection cached;
+    private class MyCollection extends AbstractCollection<Resource> {
+        private Collection<Resource> cached;
 
         MyCollection() {
         }
         public int size() {
             return getCache().size();
         }
-        public Iterator iterator() {
+        public Iterator<Resource> iterator() {
             return getCache().iterator();
         }
-        private synchronized Collection getCache() {
-            Collection coll = cached;
+        private synchronized Collection<Resource> getCache() {
+            Collection<Resource> coll = cached;
             if (coll == null) {
                 coll = CollectionUtils.asCollection(new MyIterator());
                 if (cache) {
@@ -87,9 +88,9 @@ public class Resources extends DataType 
             }
             return coll;
         }
-        private class MyIterator implements Iterator {
+        private class MyIterator implements Iterator<Resource> {
             private Iterator rci = getNested().iterator();
-            private Iterator ri = null;
+            private Iterator<Resource> ri = null;
 
             public boolean hasNext() {
                 boolean result = ri != null && ri.hasNext();
@@ -99,7 +100,7 @@ public class Resources extends DataType 
                 }
                 return result;
             }
-            public Object next() {
+            public Resource next() {
                 if (!hasNext()) {
                     throw new NoSuchElementException();
                 }
@@ -112,7 +113,7 @@ public class Resources extends DataType 
     }
 
     private Vector rc;
-    private Collection coll;
+    private Collection<Resource> coll;
     private boolean cache = false;
 
     /**
@@ -162,7 +163,7 @@ public class Resources extends DataType 
      * Fulfill the ResourceCollection contract.
      * @return an Iterator of Resources.
      */
-    public synchronized Iterator iterator() {
+    public synchronized Iterator<Resource> iterator() {
         if (isReference()) {
             return getRef().iterator();
         }
@@ -213,11 +214,11 @@ public class Resources extends DataType 
             return "";
         }
         StringBuffer sb = new StringBuffer();
-        for (Iterator i = coll.iterator(); i.hasNext();) {
+        for (Resource r : coll) {
             if (sb.length() > 0) {
                 sb.append(File.pathSeparatorChar);
             }
-            sb.append(i.next());
+            sb.append(r);
         }
         return sb.toString();
     }

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Sort.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Sort.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Sort.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Sort.java Mon Apr 16 19:30:18
2012
@@ -26,6 +26,7 @@ import java.util.Collections;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.resources.comparators.ResourceComparator;
 import org.apache.tools.ant.types.resources.comparators.DelegatedResourceComparator;
@@ -47,13 +48,13 @@ public class Sort extends BaseResourceCo
      * Sort the contained elements.
      * @return a Collection of Resources.
      */
-    protected synchronized Collection getCollection() {
+    protected synchronized Collection<Resource> getCollection() {
         ResourceCollection rc = getResourceCollection();
-        Iterator iter = rc.iterator();
+        Iterator<Resource> iter = rc.iterator();
         if (!(iter.hasNext())) {
-            return Collections.EMPTY_SET;
+            return Collections.emptySet();
         }
-        List result = (List) CollectionUtils.asCollection(iter);
+        List<Resource> result = (List<Resource>) CollectionUtils.asCollection(iter);
         Collections.sort(result, comp);
         return result;
     }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java Mon Apr 16 19:30:18
2012
@@ -113,7 +113,7 @@ public class Union extends BaseResourceC
      *        should contain Strings instead of Resources.
      * @return a Collection of Resources.
      */
-    protected Collection getCollection(boolean asString) {
+    protected Collection getCollection(boolean asString) { // XXX untypable
         List rc = getResourceCollections();
         if (rc.isEmpty()) {
             return Collections.EMPTY_LIST;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ZipResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ZipResource.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ZipResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ZipResource.java Mon Apr
16 19:30:18 2012
@@ -75,7 +75,7 @@ public class ZipResource extends Archive
      * @return the zipfile as a File.
      */
     public File getZipfile() {
-        FileProvider fp = (FileProvider) getArchive().as(FileProvider.class);
+        FileProvider fp = getArchive().as(FileProvider.class);
         return fp.getFile();
     }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/FileSystem.java
Mon Apr 16 19:30:18 2012
@@ -38,13 +38,13 @@ public class FileSystem extends Resource
      * @throws ClassCastException if either resource is not an instance of FileResource.
      */
     protected int resourceCompare(Resource foo, Resource bar) {
-        FileProvider fooFP = (FileProvider) foo.as(FileProvider.class);
+        FileProvider fooFP = foo.as(FileProvider.class);
         if (fooFP == null) {
             throw new ClassCastException(foo.getClass()
                                          + " doesn't provide files");
         }
         File foofile = fooFP.getFile();
-        FileProvider barFP = (FileProvider) bar.as(FileProvider.class);
+        FileProvider barFP = bar.as(FileProvider.class);
         if (barFP == null) {
             throw new ClassCastException(bar.getClass()
                                          + " doesn't provide files");

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/comparators/ResourceComparator.java
Mon Apr 16 19:30:18 2012
@@ -26,7 +26,7 @@ import org.apache.tools.ant.types.Resour
  * Abstract Resource Comparator.
  * @since Ant 1.7
  */
-public abstract class ResourceComparator extends DataType implements Comparator {
+public abstract class ResourceComparator extends DataType implements Comparator<Resource>
{
 
     /**
      * Compare two objects.
@@ -36,11 +36,11 @@ public abstract class ResourceComparator
      *         argument is less than, equal to, or greater than the second.
      * @throws ClassCastException if either argument is null.
      */
-    public final int compare(Object foo, Object bar) {
+    public final int compare(Resource foo, Resource bar) {
         dieOnCircularReference();
         ResourceComparator c =
             isReference() ? (ResourceComparator) getCheckedRef() : this;
-        return c.resourceCompare((Resource) foo, (Resource) bar);
+        return c.resourceCompare(foo, bar);
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/selectors/Compare.java Mon
Apr 16 19:30:18 2012
@@ -111,8 +111,8 @@ public class Compare extends DataType im
         }
         dieOnCircularReference();
         int t = 0, f = 0;
-        for (Iterator it = control.iterator(); it.hasNext();) {
-            if (when.evaluate(comp.compare(r, (Resource) it.next()))) {
+        for (Resource res : control) {
+            if (when.evaluate(comp.compare(r, res))) {
                 t++;
             } else {
                 f++;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/ReadableSelector.java Mon
Apr 16 19:30:18 2012
@@ -39,7 +39,7 @@ public class ReadableSelector implements
     }
 
     public boolean isSelected(Resource r) {
-        FileProvider fp = (FileProvider) r.as(FileProvider.class);
+        FileProvider fp = r.as(FileProvider.class);
         if (fp != null) {
             return isSelected(null, null, fp.getFile());
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/WritableSelector.java Mon
Apr 16 19:30:18 2012
@@ -39,7 +39,7 @@ public class WritableSelector implements
     }
 
     public boolean isSelected(Resource r) {
-        FileProvider fp = (FileProvider) r.as(FileProvider.class);
+        FileProvider fp = r.as(FileProvider.class);
         if (fp != null) {
             return isSelected(null, null, fp.getFile());
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/CollectionUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/CollectionUtils.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/CollectionUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/CollectionUtils.java Mon Apr 16 19:30:18
2012
@@ -213,8 +213,8 @@ public class CollectionUtils {
      *
      * @since Ant 1.8.0
      */
-    public static Collection asCollection(final Iterator iter) {
-        List l = new ArrayList();
+    public static <T> Collection<T> asCollection(final Iterator<? extends
T> iter) {
+        List<T> l = new ArrayList<T>();
         while (iter.hasNext()) {
             l.add(iter.next());
         }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ConcatResourceInputStream.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ConcatResourceInputStream.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ConcatResourceInputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ConcatResourceInputStream.java Mon Apr
16 19:30:18 2012
@@ -37,7 +37,7 @@ public class ConcatResourceInputStream e
 
     private static final int EOF = -1;
     private boolean eof = false;
-    private Iterator iter;
+    private Iterator<Resource> iter;
     private InputStream currentStream;
     private ProjectComponent managingPc;
     private boolean ignoreErrors = false;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java Mon Apr 16 19:30:18
2012
@@ -189,8 +189,7 @@ public class ResourceUtils {
         source = Union.getInstance(source);
 
         Union result = new Union();
-        for (Iterator iter = source.iterator(); iter.hasNext();) {
-            final Resource sr = (Resource) iter.next();
+        for (Resource sr : source) {
             String srName = sr.getName();
             srName = srName == null
                 ? srName : srName.replace('/', File.separatorChar);
@@ -223,7 +222,7 @@ public class ResourceUtils {
             r.add(targetColl);
             if (r.size() > 0) {
                 result.add(sr);
-                Resource t = (Resource) (r.iterator().next());
+                Resource t = r.iterator().next();
                 logTo.log(sr.getName() + " added as " + t.getName()
                     + (t.isExists() ? " is outdated." : " doesn\'t exist."),
                     Project.MSG_VERBOSE);
@@ -397,7 +396,7 @@ public class ResourceUtils {
 
         File destFile = null;
         if (dest.as(FileProvider.class) != null) {
-            destFile = ((FileProvider) dest.as(FileProvider.class)).getFile();
+            destFile = dest.as(FileProvider.class).getFile();
         }
         if (destFile != null && destFile.isFile() && !destFile.canWrite())
{
             if (!force) {
@@ -504,7 +503,7 @@ public class ResourceUtils {
         } else if (source.as(FileProvider.class) != null
                    && destFile != null) {
             File sourceFile =
-                ((FileProvider) source.as(FileProvider.class)).getFile();
+                source.as(FileProvider.class).getFile();
 
             File parent = destFile.getParentFile();
             if (parent != null && !parent.isDirectory()
@@ -557,7 +556,7 @@ public class ResourceUtils {
             }
         }
         if (preserveLastModified) {
-            Touchable t = (Touchable) dest.as(Touchable.class);
+            Touchable t = dest.as(Touchable.class);
             if (t != null) {
                 setLastModified(t, source.getLastModified());
             }
@@ -759,16 +758,15 @@ public class ResourceUtils {
         Restrict future = new Restrict();
         future.add(sel);
         future.add(rc);
-        for (Iterator iter = future.iterator(); iter.hasNext();) {
-            logTo.log("Warning: " + ((Resource) iter.next()).getName()
-                     + " modified in the future.", Project.MSG_WARN);
+        for (Resource r : future) {
+            logTo.log("Warning: " + r.getName() + " modified in the future.", Project.MSG_WARN);
         }
     }
 
     private static OutputStream getOutputStream(Resource resource, boolean append, Project
project)
             throws IOException {
         if (append) {
-            Appendable a = (Appendable) resource.as(Appendable.class);
+            Appendable a = resource.as(Appendable.class);
             if (a != null) {
                 return a.getAppendOutputStream();
             }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java Mon Apr 16 19:30:18
2012
@@ -249,9 +249,7 @@ public abstract class ScriptRunnerBase {
      * @throws BuildException if a resource cannot be read
      */
     public void loadResources(ResourceCollection collection) {
-        Iterator resources = collection.iterator();
-        while (resources.hasNext()) {
-            Resource resource = (Resource) resources.next();
+        for (Resource resource : collection) {
             loadResource(resource);
         }
     }

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipExtraFieldTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipExtraFieldTest.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipExtraFieldTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipExtraFieldTest.java Mon
Apr 16 19:30:18 2012
@@ -23,9 +23,11 @@ import java.io.File;
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 
 import junit.framework.TestCase;
+import org.apache.tools.ant.types.Resource;
 
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.resources.ZipResource;
@@ -68,10 +70,8 @@ public class ZipExtraFieldTest extends T
             testInstance.add(new ResourceCollection() {
                     public boolean isFilesystemOnly() { return false; }
                     public int size() { return 1; }
-                    public Iterator iterator() {
-                        ArrayList l = new ArrayList();
-                        l.add(r);
-                        return l.iterator();
+                    public Iterator<Resource> iterator() {
+                        return Collections.<Resource>singleton(r).iterator();
                     }
                 });
             testInstance.execute();

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java?rev=1326760&r1=1326759&r2=1326760&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
Mon Apr 16 19:30:18 2012
@@ -39,7 +39,7 @@ public class LazyResourceCollectionTest 
             return resources.size();
         }
 
-        public Iterator iterator() {
+        public Iterator<Resource> iterator() {
             StringResourceIterator it = new StringResourceIterator();
             createdIterators.add(it);
             return it;
@@ -75,7 +75,7 @@ public class LazyResourceCollectionTest 
         LazyResourceCollectionWrapper lazyCollection = new LazyResourceCollectionWrapper();
         lazyCollection.add(collectionTest);
 
-        Iterator it = lazyCollection.iterator();
+        Iterator<Resource> it = lazyCollection.iterator();
         assertOneCreatedIterator(collectionTest);
         StringResourceIterator stringResourceIterator = (StringResourceIterator) collectionTest.createdIterators
                 .get(0);
@@ -120,9 +120,9 @@ public class LazyResourceCollectionTest 
         lazyCollection.add(collectionTest);
 
         assertTrue(lazyCollection.isCache());
-        Iterator it1 = lazyCollection.iterator();
+        Iterator<Resource> it1 = lazyCollection.iterator();
         assertOneCreatedIterator(collectionTest);
-        Iterator it2 = lazyCollection.iterator();
+        Iterator<Resource> it2 = lazyCollection.iterator();
         assertOneCreatedIterator(collectionTest);
 
         StringResourceIterator stringResourceIterator = (StringResourceIterator) collectionTest.createdIterators



Mime
View raw message