|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.IntrospectionHelper
Helper class that collects the methods a task or nested element holds to set attributes, create nested elements or hold PCDATA elements. The class is final as it has a private constructor.
Nested Class Summary | |
static class |
IntrospectionHelper.Creator
creator - allows use of create/store external to IntrospectionHelper. |
Method Summary | |
void |
addText(Project project,
java.lang.Object element,
java.lang.String text)
Adds PCDATA to an element, using the element's void addText(String) method, if it has one. |
void |
buildFinished(BuildEvent event)
Clears all storage used by this class, including the static cache of helpers. |
void |
buildStarted(BuildEvent event)
Empty implementation to satisfy the BuildListener interface. |
java.lang.Object |
createElement(Project project,
java.lang.Object parent,
java.lang.String elementName)
Deprecated. This is not a namespace aware method. |
java.util.Enumeration |
getAttributes()
Returns an enumeration of the names of the attributes supported by the introspected class. |
java.lang.Class |
getAttributeType(java.lang.String attributeName)
Returns the type of a named attribute. |
IntrospectionHelper.Creator |
getElementCreator(Project project,
java.lang.String parentUri,
java.lang.Object parent,
java.lang.String elementName,
UnknownElement ue)
returns an object that creates and stores an object for an element of a parent. |
protected java.lang.String |
getElementName(Project project,
java.lang.Object element)
Returns a description of the type of the given element in relation to a given project. |
java.lang.Class |
getElementType(java.lang.String elementName)
Returns the type of a named nested element. |
static IntrospectionHelper |
getHelper(java.lang.Class c)
Returns a helper for the given class, either from the cache or by creating a new instance. |
static IntrospectionHelper |
getHelper(Project p,
java.lang.Class c)
Returns a helper for the given class, either from the cache or by creating a new instance. |
java.util.Enumeration |
getNestedElements()
Returns an enumeration of the names of the nested elements supported by the introspected class. |
void |
messageLogged(BuildEvent event)
Empty implementation to satisfy the BuildListener interface. |
void |
setAttribute(Project p,
java.lang.Object element,
java.lang.String attributeName,
java.lang.String value)
Sets the named attribute in the given element, which is part of the given project. |
void |
storeElement(Project project,
java.lang.Object parent,
java.lang.Object child,
java.lang.String elementName)
Stores a named nested element using a storage method determined by the initial introspection. |
boolean |
supportsCharacters()
Returns whether or not the introspected class supports PCDATA. |
boolean |
supportsNestedElement(java.lang.String elementName)
Indicate if this element supports a nested element of the given name. |
boolean |
supportsNestedElement(java.lang.String parentUri,
java.lang.String elementName)
Indicate if this element supports a nested element of the given name. |
void |
targetFinished(BuildEvent event)
Empty implementation to satisfy the BuildListener interface. |
void |
targetStarted(BuildEvent event)
Empty implementation to satisfy the BuildListener interface. |
void |
taskFinished(BuildEvent event)
Empty implementation to satisfy the BuildListener interface. |
void |
taskStarted(BuildEvent event)
Empty implementation to satisfy the BuildListener interface. |
void |
throwNotSupported(Project project,
java.lang.Object parent,
java.lang.String elementName)
Utility method to throw a NotSupported exception |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static IntrospectionHelper getHelper(java.lang.Class c)
c
- The class for which a helper is required.
Must not be null
.
public static IntrospectionHelper getHelper(Project p, java.lang.Class c)
p
- the project instancec
- The class for which a helper is required.
Must not be null
.
public void setAttribute(Project p, java.lang.Object element, java.lang.String attributeName, java.lang.String value) throws BuildException
p
- The project containing the element. This is used when files
need to be resolved. Must not be null
.element
- The element to set the attribute in. Must not be
null
.attributeName
- The name of the attribute to set. Must not be
null
.value
- The value to set the attribute to. This may be interpreted
or converted to the necessary type if the setter method
doesn't just take a string. Must not be null
.
BuildException
- if the introspected class doesn't support
the given attribute, or if the setting
method fails.public void addText(Project project, java.lang.Object element, java.lang.String text) throws BuildException
void addText(String)
method, if it has one. If no
such method is present, a BuildException is thrown if the
given text contains non-whitespace.
project
- The project which the element is part of.
Must not be null
.element
- The element to add the text to.
Must not be null
.text
- The text to add.
Must not be null
.
BuildException
- if non-whitespace text is provided and no
method is available to handle it, or if
the handling method fails.public void throwNotSupported(Project project, java.lang.Object parent, java.lang.String elementName)
project
- the Project instance.parent
- the object which doesn't support a requested elementelementName
- the name of the Element which is trying to be created.public java.lang.Object createElement(Project project, java.lang.Object parent, java.lang.String elementName) throws BuildException
project
- Project to which the parent object belongs.
Must not be null
. If the resulting
object is an instance of ProjectComponent, its
Project reference is set to this parameter value.parent
- Parent object used to create the instance.
Must not be null
.elementName
- Name of the element to create an instance of.
Must not be null
.
BuildException
- if no method is available to create the
element instance, or if the creating method
fails.public IntrospectionHelper.Creator getElementCreator(Project project, java.lang.String parentUri, java.lang.Object parent, java.lang.String elementName, UnknownElement ue)
project
- Project to which the parent object belongs.parentUri
- The namespace uri of the parent object.parent
- Parent object used to create the creator object to
create and store and instance of a subelement.elementName
- Name of the element to create an instance of.ue
- The unknown element associated with the element.
public boolean supportsNestedElement(java.lang.String elementName)
elementName
- the name of the nested element being checked
public boolean supportsNestedElement(java.lang.String parentUri, java.lang.String elementName)
parentUri
- the uri of the parentelementName
- the name of the nested element being checked
public void storeElement(Project project, java.lang.Object parent, java.lang.Object child, java.lang.String elementName) throws BuildException
project
- Ignored in this implementation.
May be null
.parent
- Parent instance to store the child in.
Must not be null
.child
- Child instance to store in the parent.
Should not be null
.elementName
- Name of the child element to store.
May be null
, in which case
this method returns immediately.
BuildException
- if the storage method fails.public java.lang.Class getElementType(java.lang.String elementName) throws BuildException
elementName
- The name of the element to find the type of.
Must not be null
.
null
.
BuildException
- if the introspected class does not
support the named nested element.public java.lang.Class getAttributeType(java.lang.String attributeName) throws BuildException
attributeName
- The name of the attribute to find the type of.
Must not be null
.
null
.
BuildException
- if the introspected class does not
support the named attribute.public boolean supportsCharacters()
public java.util.Enumeration getAttributes()
public java.util.Enumeration getNestedElements()
protected java.lang.String getElementName(Project project, java.lang.Object element)
project
- The project the element is defined in.
Must not be null
.element
- The element to describe.
Must not be null
.
public void buildFinished(BuildEvent event)
buildFinished
in interface BuildListener
event
- Ignored in this implementation.BuildEvent.getException()
public void buildStarted(BuildEvent event)
buildStarted
in interface BuildListener
event
- Ignored in this implementation.public void targetStarted(BuildEvent event)
targetStarted
in interface BuildListener
event
- Ignored in this implementation.BuildEvent.getTarget()
public void targetFinished(BuildEvent event)
targetFinished
in interface BuildListener
event
- Ignored in this implementation.BuildEvent.getException()
public void taskStarted(BuildEvent event)
taskStarted
in interface BuildListener
event
- Ignored in this implementation.BuildEvent.getTask()
public void taskFinished(BuildEvent event)
taskFinished
in interface BuildListener
event
- Ignored in this implementation.BuildEvent.getException()
public void messageLogged(BuildEvent event)
messageLogged
in interface BuildListener
event
- Ignored in this implementation.BuildEvent.getMessage()
,
BuildEvent.getPriority()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |