org.apache.tools.ant

Class AntTypeDefinition

Known Direct Subclasses:
PreSetDef.PreSetDefinition

public class AntTypeDefinition
extends java.lang.Object

This class contains all the information on a particular ant type, the classname, adaptor and the class it should be assignable from. This type replaces the task/datatype split of pre ant 1.6.

Method Summary

void
checkClass(Project project)
Checks if the attributes are correct.
Object
create(Project project)
create an instance of the definition.
ClassLoader
getClassLoader()
get the classloader for this definition
String
getClassName()
get the classname of the definition
Class
getExposedClass(Project project)
get the exposed class for this definition.
String
getName()
return the definition's name
Class
getTypeClass(Project project)
get the definition class
boolean
sameDefinition(AntTypeDefinition other, Project project)
Equality method for this definition (assumes the names are the same)
void
setAdaptToClass(Class adaptToClass)
set the assignable class for this definition.
void
setAdapterClass(Class adapterClass)
set the adapter class for this definition.
void
setClass(Class clazz)
set the class of the definition.
void
setClassLoader(ClassLoader classLoader)
set the classloader to use to create an instance of the definition
void
setClassName(String className)
set the classname of the definition
void
setName(String name)
set the definition's name
boolean
similarDefinition(AntTypeDefinition other, Project project)
Similar definition used to compare two definitions defined twice with the same name and the same types.

Method Details

checkClass

public void checkClass(Project project)
Checks if the attributes are correct.
  • if the class can be created.
  • if an adapter class can be created
  • if the type is assignable from adapto
  • if the type can be used with the adapter class
  • Parameters:
    project - the current project

    create

    public Object create(Project project)
    create an instance of the definition. The instance may be wrapped in a proxy class.
    Parameters:
    project - the current project
    Returns:
    the created object

    getClassLoader

    public ClassLoader getClassLoader()
    get the classloader for this definition
    Returns:
    the classloader for this definition

    getClassName

    public String getClassName()
    get the classname of the definition
    Returns:
    the name of the class of this definition

    getExposedClass

    public Class getExposedClass(Project project)
    get the exposed class for this definition. This will be a proxy class (adapted class) if there is an adapter class and the definition class is not assignable from the assignable class.
    Parameters:
    project - the current project
    Returns:
    the exposed class

    getName

    public String getName()
    return the definition's name
    Returns:
    the name of the definition

    getTypeClass

    public Class getTypeClass(Project project)
    get the definition class
    Parameters:
    project - the current project
    Returns:
    the type of the definition

    sameDefinition

    public boolean sameDefinition(AntTypeDefinition other,
                                  Project project)
    Equality method for this definition (assumes the names are the same)
    Parameters:
    other - another definition
    project - the project the definition
    Returns:
    true if the definitions are the same

    setAdaptToClass

    public void setAdaptToClass(Class adaptToClass)
    set the assignable class for this definition.
    Parameters:
    adaptToClass - the assignable class

    setAdapterClass

    public void setAdapterClass(Class adapterClass)
    set the adapter class for this definition. this class is used to adapt the definitions class if required.
    Parameters:
    adapterClass - the adapterClass

    setClass

    public void setClass(Class clazz)
    set the class of the definition. as a side-effect may set the classloader and classname
    Parameters:
    clazz - the class of this definition

    setClassLoader

    public void setClassLoader(ClassLoader classLoader)
    set the classloader to use to create an instance of the definition
    Parameters:
    classLoader - the classLoader

    setClassName

    public void setClassName(String className)
    set the classname of the definition
    Parameters:
    className - the classname of this definition

    setName

    public void setName(String name)
    set the definition's name
    Parameters:
    name - the name of the definition

    similarDefinition

    public boolean similarDefinition(AntTypeDefinition other,
                                     Project project)
    Similar definition used to compare two definitions defined twice with the same name and the same types. the classloader may be different but have the same path so #sameDefinition cannot be used.
    Parameters:
    other - the definition to compare to
    project - the current project
    Returns:
    true if the definitions are the same

    Copyright B) 2000-2006 Apache Software Foundation. All Rights Reserved.