FileDocCategorySizeDatePackage
TypeFound.javaAPI DocApache Ant 1.703055Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.condition

TypeFound

public class TypeFound extends org.apache.tools.ant.ProjectComponent implements Condition
looks for a task or other Ant type that exists. Existence is defined as the type is defined, and its implementation class is present. This will work for datatypes and preset, script and macro definitions.

Fields Summary
private String
name
private String
uri
Constructors Summary
Methods Summary
protected booleandoesTypeExist(java.lang.String typename)
test for a task or other ant type existing in the current project

param
typename the name of the type
return
true if the typename exists


        ComponentHelper helper =
            ComponentHelper.getComponentHelper(getProject());
        String componentName = ProjectHelper.genComponentName(uri, typename);
        AntTypeDefinition def = helper.getDefinition(componentName);
        if (def == null) {
            return false;
        }
        //now verify that the class has an implementation
        boolean found = def.getExposedClass(getProject()) != null;
        if (!found) {
            String text = helper.diagnoseCreationFailure(componentName, "type");
            log(text, Project.MSG_VERBOSE);
        }
        return found;
    
public booleaneval()
Is this condition true?

return
true if the condition is true
exception
BuildException if an error occurs

        if (name == null) {
            throw new BuildException("No type specified");
        }
        return doesTypeExist(name);
    
public voidsetName(java.lang.String name)
the task or other type to look for

param
name the name of the type

        this.name = name;
    
public voidsetURI(java.lang.String uri)
The URI for this definition.

param
uri the namespace URI. If this is not set, use the default ant namespace.

        this.uri = uri;