ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r469781 - in /ant/core/trunk/src/main/org/apache/tools/ant: ProjectComponent.java types/AbstractFileSet.java types/DataType.java types/PatternSet.java
Date Wed, 01 Nov 2006 05:11:28 GMT
Author: antoine
Date: Tue Oct 31 21:11:27 2006
New Revision: 469781

URL: http://svn.apache.org/viewvc?view=rev&rev=469781
Log:
reactivate mergePatterns in AbstractFileSet, implement clone in DataType and ProjectComponent

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/ProjectComponent.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/PatternSet.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ProjectComponent.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ProjectComponent.java?view=diff&rev=469781&r1=469780&r2=469781
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ProjectComponent.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ProjectComponent.java Tue Oct 31 21:11:27
2006
@@ -18,12 +18,13 @@
 
 package org.apache.tools.ant;
 
+
 /**
  * Base class for components of a project, including tasks and data types.
  * Provides common facilities.
  *
  */
-public abstract class ProjectComponent {
+public abstract class ProjectComponent implements Cloneable {
 
     /**
      * Project object of this component.
@@ -121,5 +122,15 @@
                 System.err.println(msg);
             }
         }
+    }
+    /**
+     * @since Ant 1.7
+     * @return a shallow copy of this projectcomponent.
+     */
+    public Object clone() throws CloneNotSupportedException {
+        ProjectComponent pc = (ProjectComponent) super.clone();
+        pc.setLocation(getLocation());
+        pc.setProject(getProject());
+        return pc;
     }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java?view=diff&rev=469781&r1=469780&r2=469781
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/AbstractFileSet.java Tue Oct 31 21:11:27
2006
@@ -459,16 +459,12 @@
         }
         ds.setBasedir(dir);
 
-        final int count = additionalPatterns.size();
-        for (int i = 0; i < count; i++) {
-            Object o = additionalPatterns.elementAt(i);
-            defaultPatterns.append((PatternSet) o, p);
-        }
+        PatternSet ps = mergePatterns(p);
         p.log(getDataTypeName() + ": Setup scanner in dir " + dir
-            + " with " + defaultPatterns, Project.MSG_DEBUG);
+            + " with " + ps, Project.MSG_DEBUG);
 
-        ds.setIncludes(defaultPatterns.getIncludePatterns(p));
-        ds.setExcludes(defaultPatterns.getExcludePatterns(p));
+        ds.setIncludes(ps.getIncludePatterns(p));
+        ds.setExcludes(ps.getExcludePatterns(p));
         if (ds instanceof SelectorScanner) {
             SelectorScanner ss = (SelectorScanner) ds;
             ss.setSelectors(getSelectors(p));
@@ -803,8 +799,7 @@
         if (isReference()) {
             return getRef(p).mergePatterns(p);
         }
-        PatternSet ps = new PatternSet();
-        ps.append(defaultPatterns, p);
+        PatternSet ps = (PatternSet) defaultPatterns.clone();
         final int count = additionalPatterns.size();
         for (int i = 0; i < count; i++) {
             Object o = additionalPatterns.elementAt(i);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java?view=diff&rev=469781&r1=469780&r2=469781
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/DataType.java Tue Oct 31 21:11:27 2006
@@ -37,7 +37,7 @@
  * but not &lt;path&gt;).</p>
  *
  */
-public abstract class DataType extends ProjectComponent {
+public abstract class DataType extends ProjectComponent implements Cloneable {
 
     /**
      * The description the user has set.
@@ -352,5 +352,18 @@
         return d == null ? getDataTypeName() : getDataTypeName() + " " + d;
     }
 
+    /**
+     * @since Ant 1.7
+     * @return a shallow copy of this DataType.
+     */
+    public Object clone() throws CloneNotSupportedException {
+        DataType dt = (DataType) super.clone();
+        dt.setDescription(getDescription());
+        if (getRefid() != null) {
+	    dt.setRefid(getRefid());
+	}
+        dt.setChecked(isChecked());
+        return dt;
+    }
 }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/PatternSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/PatternSet.java?view=diff&rev=469781&r1=469780&r2=469781
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/PatternSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/PatternSet.java Tue Oct 31 21:11:27
2006
@@ -497,19 +497,15 @@
      * @return a clone of this patternset.
      */
     public Object clone() {
-        if (isReference()) {
-            return getRef(getProject()).clone();
-        } else {
-            try {
-                PatternSet ps = (PatternSet) super.clone();
-                ps.includeList = (Vector) includeList.clone();
-                ps.excludeList = (Vector) excludeList.clone();
-                ps.includesFileList = (Vector) includesFileList.clone();
-                ps.excludesFileList = (Vector) excludesFileList.clone();
-                return ps;
-            } catch (CloneNotSupportedException e) {
-                throw new BuildException(e);
-            }
+        try {
+            PatternSet ps = (PatternSet) super.clone();
+            ps.includeList = (Vector) includeList.clone();
+            ps.excludeList = (Vector) excludeList.clone();
+            ps.includesFileList = (Vector) includesFileList.clone();
+            ps.excludesFileList = (Vector) excludesFileList.clone();
+            return ps;
+        } catch (CloneNotSupportedException e) {
+            throw new BuildException(e);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message