From 339e72629fad1800cda37f42e15919bab4d74bf1 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 17 Jul 2007 18:55:42 +0000 Subject: [PATCH] Cloneable; update Delegate order on re-add git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@557025 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/PropertyHelper.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index 4ab1951f8..5c560a951 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -57,7 +57,7 @@ import java.util.Enumeration; * * @since Ant 1.6 */ -public class PropertyHelper { +public class PropertyHelper implements Cloneable { /** * Marker interface for a PropertyHelper delegate. @@ -198,6 +198,7 @@ public class PropertyHelper { * least for non-dynamic properties) * * @param next the next property helper in the chain. + * @deprecated */ public void setNext(PropertyHelper next) { this.next = next; @@ -207,6 +208,7 @@ public class PropertyHelper { * Get the next property helper in the chain. * * @return the next property helper. + * @deprecated */ public PropertyHelper getNext() { return next; @@ -707,7 +709,6 @@ public class PropertyHelper { * the return value is also null. * @return the property value, or null for no match * or if a null name is provided. - * @deprecated namespaces are unnecessary. */ public synchronized Object getUserProperty(String name) { if (name == null) { @@ -909,9 +910,10 @@ public class PropertyHelper { list = new ArrayList(); delegates.put(key, list); } - if (!list.contains(delegate)) { - list.add(0, delegate); + if (list.contains(delegate)) { + list.remove(delegate); } + list.add(0, delegate); } } @@ -942,4 +944,19 @@ public class PropertyHelper { } return result; } + + /** + * Make a clone of this PropertyHelper. + * @return the cloned PropertyHelper. + * @since Ant 1.8 + */ + public Object clone() { + PropertyHelper result; + try { + result = (PropertyHelper) super.clone(); + } catch (CloneNotSupportedException e) { + throw new BuildException(e); + } + return result; + } }