From de1a987f23e027a486e6b07ddc8ab2edecd7dd3a Mon Sep 17 00:00:00 2001 From: Magesh Umasankar Date: Sun, 24 Feb 2002 01:56:58 +0000 Subject: [PATCH] Stefan's prediction coming true: AntFilterReader has its own classpath attribute and nested classpath element. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271521 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/types/AntFilterReader.java | 64 +++++++++++++++---- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java index 47cd10b1d..80f20b648 100644 --- a/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java +++ b/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java @@ -58,6 +58,7 @@ import java.util.Hashtable; import java.util.Vector; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; /** * An AntFileReader is a wrapper class that encloses the classname @@ -65,24 +66,18 @@ import org.apache.tools.ant.BuildException; * * @author Magesh Umasankar */ -public final class AntFilterReader { +public final class AntFilterReader + extends DataType + implements Cloneable { private String className; private final Vector parameters = new Vector(); + private Path classpath; + public final void setClassName(final String className) { - try { - final Class c = Class.forName(className); - if (FilterReader.class.isAssignableFrom(c)) { - this.className = className; - } else { - throw new BuildException(className + - " does not extend java.io.FilterReader"); - } - } catch (final ClassNotFoundException cnfe) { - throw new BuildException(cnfe); - } + this.className = className; } public final String getClassName() { @@ -93,6 +88,51 @@ public final class AntFilterReader { parameters.addElement(param); } + /** + * Set the classpath to load the FilterReader through (attribute). + */ + public final void setClasspath(Path classpath) { + if (isReference()) { + throw tooManyAttributes(); + } + if (this.classpath == null) { + this.classpath = classpath; + } else { + this.classpath.append(classpath); + } + } + + /** + * Set the classpath to load the FilterReader through (nested element). + */ + public final Path createClasspath() { + if (isReference()) { + throw noChildrenAllowed(); + } + if (this.classpath == null) { + this.classpath = new Path(getProject()); + } + return this.classpath.createPath(); + } + + /** + * Get the classpath + */ + public final Path getClasspath() { + return classpath; + } + + /** + * Set the classpath to load the FilterReader through via + * reference (attribute). + */ + public void setClasspathRef(Reference r) { + if (isReference()) { + throw tooManyAttributes(); + } + createClasspath().setRefid(r); + } + public final Parameter[] getParams() { Parameter[] params = new Parameter[parameters.size()]; parameters.copyInto(params);