Methods Summary |
---|
public void | addParam(org.apache.tools.ant.types.Parameter p)Create new parameters to pass to custom selector.
paramVec.addElement(p);
|
public final org.apache.tools.ant.types.Path | createClasspath()Specify the classpath to use to load the Selector (nested element).
if (isReference()) {
throw noChildrenAllowed();
}
if (this.classpath == null) {
this.classpath = new Path(getProject());
}
return this.classpath.createPath();
|
public final org.apache.tools.ant.types.Path | getClasspath()Get the classpath
return classpath;
|
public boolean | isSelected(java.io.File basedir, java.lang.String filename, java.io.File file)Allows the custom selector to choose whether to select a file. This
is also where the Parameters are passed to the custom selector,
since we know we must have them all by now. And since we must know
both classpath and classname, creating the class is deferred to here
as well.
validate();
if (paramVec.size() > 0 && dynselector instanceof ExtendFileSelector) {
Parameter[] paramArray = new Parameter[paramVec.size()];
paramVec.copyInto(paramArray);
// We know that dynselector must be non-null if no error message
((ExtendFileSelector) dynselector).setParameters(paramArray);
}
return dynselector.isSelected(basedir, filename, file);
|
public void | selectorCreate()Instantiates the identified custom selector class.
if (classname != null && classname.length() > 0) {
try {
Class c = null;
if (classpath == null) {
c = Class.forName(classname);
} else {
AntClassLoader al
= getProject().createClassLoader(classpath);
c = Class.forName(classname, true, al);
}
dynselector = (FileSelector) c.newInstance();
final Project p = getProject();
if (p != null) {
p.setProjectReference(dynselector);
}
} catch (ClassNotFoundException cnfexcept) {
setError("Selector " + classname
+ " not initialized, no such class");
} catch (InstantiationException iexcept) {
setError("Selector " + classname
+ " not initialized, could not create class");
} catch (IllegalAccessException iaexcept) {
setError("Selector " + classname
+ " not initialized, class not accessible");
}
} else {
setError("There is no classname specified");
}
|
public void | setClassname(java.lang.String classname)Sets the classname of the custom selector.
this.classname = classname;
|
public final void | setClasspath(org.apache.tools.ant.types.Path classpath)Set the classpath to load the classname specified using an attribute.
if (isReference()) {
throw tooManyAttributes();
}
if (this.classpath == null) {
this.classpath = classpath;
} else {
this.classpath.append(classpath);
}
|
public void | setClasspathref(org.apache.tools.ant.types.Reference r)Set the classpath to use for loading a custom selector by using
a reference.
if (isReference()) {
throw tooManyAttributes();
}
createClasspath().setRefid(r);
|
public void | verifySettings()These are errors specific to ExtendSelector only. If there are
errors in the custom selector, it should throw a BuildException
when isSelected() is called.
// Creation is done here rather than in isSelected() because some
// containers may do a validation pass before running isSelected(),
// but we need to check for the existence of the created class.
if (dynselector == null) {
selectorCreate();
}
if (classname == null || classname.length() < 1) {
setError("The classname attribute is required");
} else if (dynselector == null) {
setError("Internal Error: The custom selector was not created");
} else if (!(dynselector instanceof ExtendFileSelector)
&& (paramVec.size() > 0)) {
setError("Cannot set parameters on custom selector that does not "
+ "implement ExtendFileSelector");
}
|