Top Description Fields Constructors Methods
org.apache.tools.ant

public Class AntTypeDefinition

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.MacroDef.MyAntTypeDefinition, org.apache.tools.ant.taskdefs.PreSetDef.PreSetDefinition
Imports
java.lang.reflect.Constructor, .InvocationTargetException

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

Field Summary

Modifier and TypeField and Description
private Class<?>
private Class<?>
private ClassLoader
private String
private Class<?>
private String
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
checkClass(Project
the current project.
project
)

Checks if the attributes are correct.

public Object

Returns:

the created object.
create
(Project
the current project.
project
)

Create an instance of the definition.

private Object

Returns:

the instantiated Object, will never be null.
createAndSet
(Project project, Class<?> c)

Get the constructor of the definition and invoke it.

private String
public ClassLoader

Returns:

the classloader for this definition.
getClassLoader
()

Get the classloader for this definition.

public String

Returns:

the name of the class of this definition.
getClassName
()

Get the classname of the definition.

public Class<?>

Returns:

the exposed class - may return null if unable to load the class
getExposedClass
(Project
the current project.
project
)

Get the exposed class for this definition.

public String

Returns:

the name of the definition.
getName
()

Return the definition's name.

public Class<?>

Returns:

the type of the definition.
getTypeClass
(Project
the current project.
project
)

Get the definition class.

private Object

Returns:

the component as an Object.
icreate
(Project project)

Create a component object based on its definition.

public <
return type of the method
T
>
T

Returns:

a newly constructed and bound instance.
innerCreateAndSet
(Class<T>
class to create
newclass
,
Project
the project to use
project
)

Inner implementation of the createAndSet(Project, Class) logic, with no exception catching.

public Class<?>

Returns:

the class that implements this component
innerGetTypeClass
()

Try and load a class, with no attempt to catch any fault.

public boolean

Returns:

the restrict attribute.
isRestrict
()

Get the restrict attribute.

public boolean

Returns:

true if the definitions are the same.
sameDefinition
(AntTypeDefinition
another definition.
other
,
Project
the project the definition.
project
)

Equality method for this definition (assumes the names are the same).

public void
setAdapterClass(Class<?>
the adapterClass.
adapterClass
)

Set the adapter class for this definition.

public void
setAdaptToClass(Class<?>
the assignable class.
adaptToClass
)

Set the assignable class for this definition.

public void
setClass(Class<?>
the class of this definition.
clazz
)

Set the class of the definition.

public void
setClassLoader(ClassLoader
the ClassLoader.
classLoader
)

Set the classloader to use to create an instance of the definition.

public void
setClassName(String
the classname of this definition.
className
)

Set the classname of the definition.

public void
setName(String
the name of the definition.
name
)

Set the definition's name.

public void
setRestrict(boolean
the value to set.
restrict
)

Set the restrict attribute.

public boolean

Returns:

true if the definitions are the same.
similarDefinition
(AntTypeDefinition
the definition to compare to.
other
,
Project
the current project.
project
)

Similar definition; used to compare two definitions defined twice with the same name and the same types.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

adapterClassback to summary
private Class<?> adapterClass
adaptToClassback to summary
private Class<?> adaptToClass
classLoaderback to summary
private ClassLoader classLoader
classNameback to summary
private String className
clazzback to summary
private Class<?> clazz
nameback to summary
private String name
restrictback to summary
private boolean restrict

Constructor Detail

AntTypeDefinitionback to summary
public AntTypeDefinition()

Method Detail

checkClassback to summary
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 adapter
  • if the type can be used with the adapter class
Parameters
project:Project

the current project.

createback to summary
public Object create(Project project)

Create an instance of the definition. The instance may be wrapped in a proxy class.

Parameters
project:Project

the current project.

Returns:Object

the created object.

createAndSetback to summary
private Object createAndSet(Project project, Class<?> c)

Get the constructor of the definition and invoke it.

Returns:Object

the instantiated Object, will never be null.

extractClassnameback to summary
private String extractClassname(Class<?> c)
getClassLoaderback to summary
public ClassLoader getClassLoader()

Get the classloader for this definition.

Returns:ClassLoader

the classloader for this definition.

getClassNameback to summary
public String getClassName()

Get the classname of the definition.

Returns:String

the name of the class of this definition.

getExposedClassback to summary
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:Project

the current project.

Returns:Class<?>

the exposed class - may return null if unable to load the class

getNameback to summary
public String getName()

Return the definition's name.

Returns:String

the name of the definition.

getTypeClassback to summary
public Class<?> getTypeClass(Project project)

Get the definition class.

Parameters
project:Project

the current project.

Returns:Class<?>

the type of the definition.

icreateback to summary
private Object icreate(Project project)

Create a component object based on its definition.

Returns:Object

the component as an Object.

innerCreateAndSetback to summary
public <T> T innerCreateAndSet(Class<T> newclass, Project project) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException

Inner implementation of the createAndSet(Project, Class) logic, with no exception catching.

Parameters
<T>
return type of the method
newclass:Class<T>

class to create

project:Project

the project to use

Returns:T

a newly constructed and bound instance.

Exceptions
NoSuchMethodException:
no good constructor.
InstantiationException:
cannot initialize the object.
IllegalAccessException:
cannot access the object.
InvocationTargetException:
error in invocation.
innerGetTypeClassback to summary
public Class<?> innerGetTypeClass() throws ClassNotFoundException

Try and load a class, with no attempt to catch any fault.

Returns:Class<?>

the class that implements this component

Exceptions
ClassNotFoundException:
if the class cannot be found.
NoClassDefFoundError:
if the there is an error finding the class.
isRestrictback to summary
public boolean isRestrict()

Get the restrict attribute.

Returns:boolean

the restrict attribute.

sameDefinitionback to summary
public boolean sameDefinition(AntTypeDefinition other, Project project)

Equality method for this definition (assumes the names are the same).

Parameters
other:AntTypeDefinition

another definition.

project:Project

the project the definition.

Returns:boolean

true if the definitions are the same.

setAdapterClassback to summary
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:Class<?>

the adapterClass.

setAdaptToClassback to summary
public void setAdaptToClass(Class<?> adaptToClass)

Set the assignable class for this definition.

Parameters
adaptToClass:Class<?>

the assignable class.

setClassback to summary
public void setClass(Class<?> clazz)

Set the class of the definition. As a side-effect may set the classloader and classname.

Parameters
clazz:Class<?>

the class of this definition.

setClassLoaderback to summary
public void setClassLoader(ClassLoader classLoader)

Set the classloader to use to create an instance of the definition.

Parameters
classLoader:ClassLoader

the ClassLoader.

setClassNameback to summary
public void setClassName(String className)

Set the classname of the definition.

Parameters
className:String

the classname of this definition.

setNameback to summary
public void setName(String name)

Set the definition's name.

Parameters
name:String

the name of the definition.

setRestrictback to summary
public void setRestrict(boolean restrict)

Set the restrict attribute.

Parameters
restrict:boolean

the value to set.

similarDefinitionback to summary
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:AntTypeDefinition

the definition to compare to.

project:Project

the current project.

Returns:boolean

true if the definitions are the same.