Browse Source

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
master
Matthew Jason Benson 18 years ago
parent
commit
339e72629f
1 changed files with 21 additions and 4 deletions
  1. +21
    -4
      src/main/org/apache/tools/ant/PropertyHelper.java

+ 21
- 4
src/main/org/apache/tools/ant/PropertyHelper.java View File

@@ -57,7 +57,7 @@ import java.util.Enumeration;
* *
* @since Ant 1.6 * @since Ant 1.6
*/ */
public class PropertyHelper {
public class PropertyHelper implements Cloneable {


/** /**
* Marker interface for a PropertyHelper delegate. * Marker interface for a PropertyHelper delegate.
@@ -198,6 +198,7 @@ public class PropertyHelper {
* least for non-dynamic properties) * least for non-dynamic properties)
* *
* @param next the next property helper in the chain. * @param next the next property helper in the chain.
* @deprecated
*/ */
public void setNext(PropertyHelper next) { public void setNext(PropertyHelper next) {
this.next = next; this.next = next;
@@ -207,6 +208,7 @@ public class PropertyHelper {
* Get the next property helper in the chain. * Get the next property helper in the chain.
* *
* @return the next property helper. * @return the next property helper.
* @deprecated
*/ */
public PropertyHelper getNext() { public PropertyHelper getNext() {
return next; return next;
@@ -707,7 +709,6 @@ public class PropertyHelper {
* the return value is also <code>null</code>. * the return value is also <code>null</code>.
* @return the property value, or <code>null</code> for no match * @return the property value, or <code>null</code> for no match
* or if a <code>null</code> name is provided. * or if a <code>null</code> name is provided.
* @deprecated namespaces are unnecessary.
*/ */
public synchronized Object getUserProperty(String name) { public synchronized Object getUserProperty(String name) {
if (name == null) { if (name == null) {
@@ -909,9 +910,10 @@ public class PropertyHelper {
list = new ArrayList(); list = new ArrayList();
delegates.put(key, list); 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; 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;
}
} }

Loading…
Cancel
Save