Browse Source

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
master
Magesh Umasankar 23 years ago
parent
commit
de1a987f23
1 changed files with 52 additions and 12 deletions
  1. +52
    -12
      proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java

+ 52
- 12
proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java View File

@@ -58,6 +58,7 @@ import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;


/** /**
* An AntFileReader is a wrapper class that encloses the classname * An AntFileReader is a wrapper class that encloses the classname
@@ -65,24 +66,18 @@ import org.apache.tools.ant.BuildException;
* *
* @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a> * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
*/ */
public final class AntFilterReader {
public final class AntFilterReader
extends DataType
implements Cloneable {


private String className; private String className;


private final Vector parameters = new Vector(); private final Vector parameters = new Vector();


private Path classpath;

public final void setClassName(final String className) { 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() { public final String getClassName() {
@@ -93,6 +88,51 @@ public final class AntFilterReader {
parameters.addElement(param); 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() { public final Parameter[] getParams() {
Parameter[] params = new Parameter[parameters.size()]; Parameter[] params = new Parameter[parameters.size()];
parameters.copyInto(params); parameters.copyInto(params);


Loading…
Cancel
Save