ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1553417 - in /ant/core/trunk/src/main/org/apache/tools/ant/types/resources: MappedResource.java MappedResourceCollection.java
Date Wed, 25 Dec 2013 21:20:12 GMT
Author: hibou
Date: Wed Dec 25 21:20:12 2013
New Revision: 1553417

URL: http://svn.apache.org/r1553417
Log:
Add toString() method for easier debugging

Modified:
    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

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=1553417&r1=1553416&r2=1553417&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 Wed Dec
25 21:20:12 2013
@@ -17,6 +17,9 @@
  */
 package org.apache.tools.ant.types.resources;
 
+import java.io.File;
+import java.util.Iterator;
+
 import org.apache.tools.ant.types.Reference;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.util.FileNameMapper;
@@ -99,4 +102,12 @@ public class MappedResource extends Reso
         return (myName == null ? otherName == null : myName.equals(otherName))
             && getResource().equals(m.getResource());
     }
+
+    public String toString() {
+        if (isReference()) {
+            return getCheckedRef().toString();
+        }
+        return getName();
+    }
+
 }

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=1553417&r1=1553416&r2=1553417&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
Wed Dec 25 21:20:12 2013
@@ -17,6 +17,7 @@
  */
 package org.apache.tools.ant.types.resources;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -239,4 +240,27 @@ public class MappedResourceCollection
         }
         return collected;
     }
+
+    /**
+     * Format this resource collection as a String.
+     * @return a descriptive <code>String</code>.
+     */
+    public String toString() {
+        if (isReference()) {
+            return getCheckedRef().toString();
+        }
+        Iterator<Resource> i = iterator();
+        if (!i.hasNext()) {
+            return "";
+        }
+        StringBuffer sb = new StringBuffer();
+        while (i.hasNext()) {
+            if (sb.length() > 0) {
+                sb.append(File.pathSeparatorChar);
+            }
+            sb.append(i.next());
+        }
+        return sb.toString();
+    }
+
 }



Mime
View raw message