From 712c6513f3847277e64e4f126ef6531abab14233 Mon Sep 17 00:00:00 2001 From: Magesh Umasankar Date: Tue, 16 Apr 2002 20:35:03 +0000 Subject: [PATCH] Make FilterChain truly referenceable. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272476 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/types/FilterChain.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/types/FilterChain.java b/src/main/org/apache/tools/ant/types/FilterChain.java index b53bb77b7..c25163a70 100644 --- a/src/main/org/apache/tools/ant/types/FilterChain.java +++ b/src/main/org/apache/tools/ant/types/FilterChain.java @@ -55,6 +55,7 @@ package org.apache.tools.ant.types; import java.util.Vector; +import org.apache.tools.ant.BuildException; import org.apache.tools.ant.filters.ClassConstants; import org.apache.tools.ant.filters.ExpandProperties; import org.apache.tools.ant.filters.HeadFilter; @@ -75,7 +76,7 @@ import org.apache.tools.ant.filters.TailFilter; */ public final class FilterChain extends DataType implements Cloneable { - private final Vector filterReaders = new Vector(); + private Vector filterReaders = new Vector(); public final void addFilterReader(final AntFilterReader filterReader) { filterReaders.addElement(filterReader); @@ -136,4 +137,30 @@ public final class FilterChain extends DataType implements Cloneable { public final void addTailFilter(final TailFilter tailFilter) { filterReaders.addElement(tailFilter); } + + /** + * Makes this instance in effect a reference to another FilterChain instance + * + *

You must not set another attribute or nest elements inside + * this element if you make it a reference.

+ * + * @param r the reference to which this instance is associated + * @exception BuildException if this instance already has been configured. + */ + public void setRefid(Reference r) throws BuildException { + if (!filterReaders.isEmpty()) { + throw tooManyAttributes(); + } + // change this to get the objects from the other reference + Object o = r.getReferencedObject(getProject()); + if (o instanceof FilterChain) { + FilterChain fc = (FilterChain) o; + filterReaders = fc.getFilterReaders(); + } else { + String msg = r.getRefId() + " doesn\'t refer to a FilterChain"; + throw new BuildException(msg); + } + + super.setRefid(r); + } }