bodewig 2003/09/17 02:20:38
Modified: src/main/org/apache/tools/ant/types AbstractFileSet.java
PatternSet.java
Log:
Create a deep (well, deeper) clone in AbstractFileSet#clone
PR: 23090
Make PatternSet Clonable.
Revision Changes Path
1.29 +22 -7
ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java
Index: AbstractFileSet.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- AbstractFileSet.java 13 Sep 2003 16:35:52 -0000 1.28
+++ AbstractFileSet.java 17 Sep 2003 09:20:38 -0000 1.29
@@ -719,16 +719,31 @@
}
/**
+ * Creates a deep clone of this instance, except for the nested
+ * selectors (the list of selectors is a shallow clone of this
+ * instance's list).
+ *
* @since Ant 1.6
*/
public Object clone() {
- try {
- AbstractFileSet fs = (AbstractFileSet) super.clone();
- fs.setProject(getProject());
- return fs;
- } catch (CloneNotSupportedException e) {
- throw new BuildException(e);
+ if (isReference()) {
+ return (getRef(getProject())).clone();
+ } else {
+ try {
+ AbstractFileSet fs = (AbstractFileSet) super.clone();
+ fs.defaultPatterns = (PatternSet) defaultPatterns.clone();
+ fs.additionalPatterns = new
Vector(additionalPatterns.size());
+ Enumeration e = additionalPatterns.elements();
+ while (e.hasMoreElements()) {
+ fs.additionalPatterns
+ .addElement(((PatternSet) e.nextElement()).clone());
+ }
+ fs.selectors = (Vector) fs.selectors.clone();
+ return fs;
+ } catch (CloneNotSupportedException e) {
+ throw new BuildException(e);
+ }
}
}
-}
\ No newline at end of file
+}
1.31 +22 -2 ant/src/main/org/apache/tools/ant/types/PatternSet.java
Index: PatternSet.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/PatternSet.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- PatternSet.java 18 Jul 2003 14:21:24 -0000 1.30
+++ PatternSet.java 17 Sep 2003 09:20:38 -0000 1.31
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -77,7 +77,7 @@
* @author Jon S. Stevens <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @author Stefan Bodewig
*/
-public class PatternSet extends DataType {
+public class PatternSet extends DataType implements Cloneable {
private Vector includeList = new Vector();
private Vector excludeList = new Vector();
private Vector includesFileList = new Vector();
@@ -475,6 +475,26 @@
public String toString() {
return "patternSet{ includes: " + includeList
+ " excludes: " + excludeList + " }";
+ }
+
+ /**
+ * @since Ant 1.6
+ */
+ 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);
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]