public class ComponentHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_HELPER_REFERENCE
reference under which we register ourselves with a project -"ant.ComponentHelper"
|
Modifier | Constructor and Description |
---|---|
protected |
ComponentHelper()
Creates a new ComponentHelper instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addDataTypeDefinition(AntTypeDefinition def)
Describe
addDataTypeDefinition method here. |
void |
addDataTypeDefinition(String typeName,
Class<?> typeClass)
Adds a new datatype definition.
|
void |
addTaskDefinition(String taskName,
Class<?> taskClass)
Adds a new task definition to the project.
|
void |
checkTaskClass(Class<?> taskClass)
Checks whether or not a class is suitable for serving as Ant task.
|
Object |
createComponent(String componentName)
Create an object for a component.
|
Object |
createComponent(UnknownElement ue,
String ns,
String componentType)
Factory method to create the components.
|
Object |
createDataType(String typeName)
Creates a new instance of a data type.
|
Task |
createTask(String taskType)
Creates a new instance of a task.
|
String |
diagnoseCreationFailure(String componentName,
String type)
Handler called to do decent diagnosis on instantiation failure.
|
void |
enterAntLib(String uri)
Called at the start of processing an antlib.
|
void |
exitAntLib()
Called at the end of processing an antlib.
|
Hashtable<String,AntTypeDefinition> |
getAntTypeTable()
Returns the current datatype definition hashtable.
|
Class<?> |
getComponentClass(String componentName)
Return the class of the component name.
|
static ComponentHelper |
getComponentHelper(Project project)
Find a project component for a specific project, creating
it if it does not exist.
|
String |
getCurrentAntlibUri() |
Hashtable<String,Class<?>> |
getDataTypeDefinitions()
Returns the current type definition hashtable.
|
AntTypeDefinition |
getDefinition(String componentName)
Return the antTypeDefinition for a componentName.
|
String |
getElementName(Object element)
Returns a description of the type of the given element.
|
String |
getElementName(Object o,
boolean brief)
Returns a description of the type of the given element.
|
static String |
getElementName(Project p,
Object o,
boolean brief)
Convenient way to get some element name even when you may not have a
Project context.
|
ComponentHelper |
getNext()
Get the next chained component helper.
|
Project |
getProject()
Get the project.
|
List<AntTypeDefinition> |
getRestrictedDefinitions(String componentName)
This returns a list of restricted definitions for a name.
|
Hashtable<String,Class<?>> |
getTaskDefinitions()
Returns the current task definition hashtable.
|
void |
initDefaultDefinitions()
This method is initialization code implementing the original ant component
loading from /org/apache/tools/ant/taskdefs/default.properties
and /org/apache/tools/ant/types/default.properties.
|
void |
initSubProject(ComponentHelper helper)
Used with creating child projects.
|
void |
setNext(ComponentHelper next)
Set the next chained component helper.
|
void |
setProject(Project project)
Sets the project for this component helper.
|
public static final String COMPONENT_HELPER_REFERENCE
protected ComponentHelper()
public void addDataTypeDefinition(AntTypeDefinition def)
addDataTypeDefinition
method here.def
- an AntTypeDefinition
value.public void addDataTypeDefinition(String typeName, Class<?> typeClass)
typeName
- The name of the datatype.
Must not be null
.typeClass
- The full name of the class implementing the datatype.
Must not be null
.public void addTaskDefinition(String taskName, Class<?> taskClass)
taskName
- The name of the task to add.
Must not be null
.taskClass
- The full name of the class implementing the task.
Must not be null
.BuildException
- if the class is unsuitable for being an Ant
task. An error level message is logged before
this exception is thrown.checkTaskClass(Class)
public void checkTaskClass(Class<?> taskClass) throws BuildException
taskClass
- The class to be checked.
Must not be null
.BuildException
- if the class is unsuitable for being an Ant
task. An error level message is logged before
this exception is thrown.public Object createComponent(String componentName)
componentName
- the name of the component, if
the component is in a namespace, the
name is prefixed with the namespace uri and ":".public Object createComponent(UnknownElement ue, String ns, String componentType) throws BuildException
ue
- The Unknown Element creating this component.ns
- Namespace URI. Also available as ue.getNamespace().componentType
- The component type,
Also available as ue.getComponentName().BuildException
- if an error occurs.public Object createDataType(String typeName) throws BuildException
typeName
- The name of the data type to create an instance of.
Must not be null
.null
if
the data type name is not recognised.BuildException
- if the data type name is recognised but
instance creation fails.public Task createTask(String taskType) throws BuildException
taskType
- The name of the task to create an instance of.
Must not be null
.null
if
the task name is not recognised.BuildException
- if the task name is recognised but task
creation fails.public String diagnoseCreationFailure(String componentName, String type)
componentName
- component name.type
- component type, used in error messagespublic void enterAntLib(String uri)
uri
- the uri that is associated with this antlib.public void exitAntLib()
public Hashtable<String,AntTypeDefinition> getAntTypeTable()
AntTypeDefinition
).public Class<?> getComponentClass(String componentName)
componentName
- the name of the component, if
the component is in a namespace, the
name is prefixed with the namespace uri and ":".public static ComponentHelper getComponentHelper(Project project)
project
- the project.public String getCurrentAntlibUri()
public Hashtable<String,Class<?>> getDataTypeDefinitions()
public AntTypeDefinition getDefinition(String componentName)
componentName
- the name of the component.public String getElementName(Object element)
This is useful for logging purposes.
element
- The element to describe.
Must not be null
.public String getElementName(Object o, boolean brief)
This is useful for logging purposes.
o
- The element to describe.
Must not be null
.brief
- whether to use a brief description.public static String getElementName(Project p, Object o, boolean brief)
p
- The optional Project instance.o
- The element to describe.
Must not be null
.brief
- whether to use a brief description.public ComponentHelper getNext()
public Project getProject()
public List<AntTypeDefinition> getRestrictedDefinitions(String componentName)
componentName
- the name to use.public Hashtable<String,Class<?>> getTaskDefinitions()
public void initDefaultDefinitions()
public void initSubProject(ComponentHelper helper)
helper
- the component helper of the parent project.public void setNext(ComponentHelper next)
next
- the next chained component helper.public void setProject(Project project)
project
- the project for this helper.