FileDocCategorySizeDatePackage
InstanceOf.javaAPI DocApache Ant 1.703795Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.types.resources.selectors

InstanceOf

public class InstanceOf extends Object implements ResourceSelector
InstanceOf ResourceSelector.
since
Ant 1.7

Fields Summary
private static final String
ONE_ONLY
private org.apache.tools.ant.Project
project
private Class
clazz
private String
type
private String
uri
Constructors Summary
Methods Summary
public java.lang.ClassgetCheckClass()
Get the comparison class.

return
the Class object.

        return clazz;
    
public java.lang.StringgetType()
Get the comparison type.

return
the String typename.

        return type;
    
public java.lang.StringgetURI()
Get the type's URI.

return
the String URI.

        return uri;
    
public booleanisSelected(org.apache.tools.ant.types.Resource r)
Return true if this Resource is selected.

param
r the Resource to check.
return
whether the Resource was selected.
throws
BuildException if an error occurs.

        if ((clazz == null) == (type == null)) {
            throw new BuildException(ONE_ONLY);
        }
        Class c = clazz;
        if (type != null) {
            if (project == null) {
                throw new BuildException(
                    "No project set for InstanceOf ResourceSelector; "
                    + "the type attribute is invalid.");
            }
            AntTypeDefinition d = ComponentHelper.getComponentHelper(
                project).getDefinition(ProjectHelper.genComponentName(uri, type));
            if (d == null) {
                throw new BuildException("type " + type + " not found.");
            }
            try {
                c = d.innerGetTypeClass();
            } catch (ClassNotFoundException e) {
                throw new BuildException(e);
            }
        }
        return c.isAssignableFrom(r.getClass());
    
public voidsetClass(java.lang.Class c)
Set the class to compare against.

param
c the class.

        if (clazz != null) {
            throw new BuildException("The class attribute has already been set.");
        }
        clazz = c;
    
public voidsetProject(org.apache.tools.ant.Project p)
Set the Project instance for this InstanceOf selector.

param
p the Project instance used for type comparisons.


                          
        
        project = p;
    
public voidsetType(java.lang.String s)
Set the Ant type to compare against.

param
s the type name.

        type = s;
    
public voidsetURI(java.lang.String u)
Set the URI in which the Ant type, if specified, should be defined.

param
u the URI.

        uri = u;