| java.lang.Object org.apache.tools.ant.IntrospectionHelper
IntrospectionHelper | final public class IntrospectionHelper (Code) | | 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.
|
Inner Class :final public static class Creator | |
Method Summary | |
public void | addText(Project project, Object element, String text) Adds PCDATA to an element, using the element's
void addText(String) method, if it has one. | public static void | clearCache() Clears the static cache of on build finished. | public Object | createElement(Project project, Object parent, String elementName) Creates a named nested element. | public Method | getAddTextMethod() Returns the addText method when the introspected
class supports nested text. | public Map | getAttributeMap() Returns a read-only map of attributes supported
by the introspected class.
an attribute name to attribute Class unmodifiable map. | public Method | getAttributeMethod(String attributeName) Returns the setter method of a named attribute.
Parameters: attributeName - The name of the attribute to find the settermethod of. | public Class | getAttributeType(String attributeName) Returns the type of a named attribute.
Parameters: attributeName - The name of the attribute to find the type of.Must not be null . | public Enumeration | getAttributes() Returns an enumeration of the names of the attributes supported
by the introspected class. | public Creator | getElementCreator(Project project, String parentUri, Object parent, String elementName, UnknownElement ue) returns an object that creates and stores an object
for an element of a parent.
Parameters: project - Project to which the parent object belongs. Parameters: parentUri - The namespace uri of the parent object. Parameters: parent - Parent object used to create the creator object tocreate and store and instance of a subelement. Parameters: elementName - Name of the element to create an instance of. Parameters: ue - The unknown element associated with the element. | public Method | getElementMethod(String elementName) Returns the adder or creator method of a named nested element.
Parameters: elementName - The name of the attribute to find the settermethod of. | protected String | getElementName(Project project, Object element) Returns a description of the type of the given element in
relation to a given project. | public Class | getElementType(String elementName) Returns the type of a named nested element.
Parameters: elementName - The name of the element to find the type of.Must not be null . | public List | getExtensionPoints() Returns a read-only list of extension points supported
by the introspected class.
A task/type or nested element with void methods named add()
or addConfigured() , taking a single class or interface
argument, supports extensions point. | public static synchronized IntrospectionHelper | getHelper(Class c) Returns a helper for the given class, either from the cache
or by creating a new instance.
Parameters: c - The class for which a helper is required.Must not be null . | public static IntrospectionHelper | getHelper(Project p, Class c) Returns a helper for the given class, either from the cache
or by creating a new instance.
The method will make sure the helper will be cleaned up at the end of
the project, and only one instance will be created for each class.
Parameters: p - the project instance. Parameters: c - The class for which a helper is required.Must not be null . | public Map | getNestedElementMap() Returns a read-only map of nested elements supported
by the introspected class.
a nested-element name to nested-element Class unmodifiable map. | public Enumeration | getNestedElements() Returns an enumeration of the names of the nested elements supported
by the introspected class. | public boolean | isContainer() Indicates whether the introspected class is a task container,
supporting arbitrary nested tasks/types. | public boolean | isDynamic() Indicates whether the introspected class is a dynamic one,
supporting arbitrary nested elements and/or attributes. | public void | setAttribute(Project p, Object element, String attributeName, String value) Sets the named attribute in the given element, which is part of the
given project.
Parameters: p - The project containing the element. | public void | storeElement(Project project, Object parent, Object child, String elementName) Stores a named nested element using a storage method determined
by the initial introspection. | public boolean | supportsCharacters() Returns whether or not the introspected class supports PCDATA. | public boolean | supportsNestedElement(String elementName) Indicates if this element supports a nested element of the
given name. | public boolean | supportsNestedElement(String parentUri, String elementName) Indicate if this element supports a nested element of the
given name. | public void | throwNotSupported(Project project, Object parent, String elementName) |
addText | public void addText(Project project, Object element, String text) throws BuildException(Code) | | Adds PCDATA to an element, using the element's
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.
Parameters: project - The project which the element is part of.Must not be null . Parameters: element - The element to add the text to.Must not be null . Parameters: text - The text to add.Must not be null . exception: BuildException - if non-whitespace text is provided and nomethod is available to handle it, or ifthe handling method fails. |
clearCache | public static void clearCache()(Code) | | Clears the static cache of on build finished.
|
createElement | public Object createElement(Project project, Object parent, String elementName) throws BuildException(Code) | | Creates a named nested element. Depending on the results of the
initial introspection, either a method in the given parent instance
or a simple no-arg constructor is used to create an instance of the
specified element type.
Parameters: project - Project to which the parent object belongs.Must not be null . If the resultingobject is an instance of ProjectComponent, itsProject reference is set to this parameter value. Parameters: parent - Parent object used to create the instance.Must not be null . Parameters: elementName - Name of the element to create an instance of.Must not be null . an instance of the specified element type exception: BuildException - if no method is available to create theelement instance, or if the creating methodfails. |
getAddTextMethod | public Method getAddTextMethod() throws BuildException(Code) | | Returns the addText method when the introspected
class supports nested text.
the method on this introspected class that adds nested text.Cannot be null . throws: BuildException - if the introspected class does notsupport the nested text. since: Ant 1.6.3 |
getAttributeMap | public Map getAttributeMap()(Code) | | Returns a read-only map of attributes supported
by the introspected class.
an attribute name to attribute Class unmodifiable map. Can be empty, but never null . since: Ant 1.6.3 |
getAttributeMethod | public Method getAttributeMethod(String attributeName) throws BuildException(Code) | | Returns the setter method of a named attribute.
Parameters: attributeName - The name of the attribute to find the settermethod of. Must not be null . the method on this introspected class that sets this attribute.This will never be null . throws: BuildException - if the introspected class does notsupport the named attribute. since: Ant 1.6.3 |
getAttributeType | public Class getAttributeType(String attributeName) throws BuildException(Code) | | Returns the type of a named attribute.
Parameters: attributeName - The name of the attribute to find the type of.Must not be null . the type of the attribute with the specified name.This will never be null . exception: BuildException - if the introspected class does notsupport the named attribute. |
getAttributes | public Enumeration getAttributes()(Code) | | Returns an enumeration of the names of the attributes supported
by the introspected class.
an enumeration of the names of the attributes supportedby the introspected class. See Also: IntrospectionHelper.getAttributeMap |
getElementCreator | public Creator getElementCreator(Project project, String parentUri, Object parent, String elementName, UnknownElement ue)(Code) | | returns an object that creates and stores an object
for an element of a parent.
Parameters: project - Project to which the parent object belongs. Parameters: parentUri - The namespace uri of the parent object. Parameters: parent - Parent object used to create the creator object tocreate and store and instance of a subelement. Parameters: elementName - Name of the element to create an instance of. Parameters: ue - The unknown element associated with the element. a creator object to create and store the element instance. |
getElementMethod | public Method getElementMethod(String elementName) throws BuildException(Code) | | Returns the adder or creator method of a named nested element.
Parameters: elementName - The name of the attribute to find the settermethod of. Must not be null . the method on this introspected class that adds or creates thisnested element. Can be null when the introspectedclass is a dynamic configurator! throws: BuildException - if the introspected class does notsupport the named nested element. since: Ant 1.6.3 |
getElementName | protected String getElementName(Project project, Object element)(Code) | | Returns a description of the type of the given element in
relation to a given project. This is used for logging purposes
when the element is asked to cope with some data it has no
way of handling.
Parameters: project - The project the element is defined in.Must not be null . Parameters: element - The element to describe.Must not be null . a description of the element type |
getElementType | public Class getElementType(String elementName) throws BuildException(Code) | | Returns the type of a named nested element.
Parameters: elementName - The name of the element to find the type of.Must not be null . the type of the nested element with the specified name.This will never be null . exception: BuildException - if the introspected class does notsupport the named nested element. |
getExtensionPoints | public List getExtensionPoints()(Code) | | Returns a read-only list of extension points supported
by the introspected class.
A task/type or nested element with void methods named add()
or addConfigured() , taking a single class or interface
argument, supports extensions point. This method returns the list of
all these void add[Configured](type) methods.
a list of void, single argument add() or addConfigured()Methods of all supported extension points.These methods are sorted such that if the argument type of amethod derives from another type also an argument of a methodof this list, the method with the most derived argument willalways appear first. Can be empty, but never null . since: Ant 1.6.3 |
getHelper | public static synchronized IntrospectionHelper getHelper(Class c)(Code) | | Returns a helper for the given class, either from the cache
or by creating a new instance.
Parameters: c - The class for which a helper is required.Must not be null . a helper for the specified class |
getHelper | public static IntrospectionHelper getHelper(Project p, Class c)(Code) | | Returns a helper for the given class, either from the cache
or by creating a new instance.
The method will make sure the helper will be cleaned up at the end of
the project, and only one instance will be created for each class.
Parameters: p - the project instance. Parameters: c - The class for which a helper is required.Must not be null . a helper for the specified class |
getNestedElementMap | public Map getNestedElementMap()(Code) | | Returns a read-only map of nested elements supported
by the introspected class.
a nested-element name to nested-element Class unmodifiable map. Can be empty, but never null . since: Ant 1.6.3 |
getNestedElements | public Enumeration getNestedElements()(Code) | | Returns an enumeration of the names of the nested elements supported
by the introspected class.
an enumeration of the names of the nested elements supportedby the introspected class. See Also: IntrospectionHelper.getNestedElementMap |
isContainer | public boolean isContainer()(Code) | | Indicates whether the introspected class is a task container,
supporting arbitrary nested tasks/types.
true if the introspected class is a container;false otherwise. since: Ant 1.6.3 See Also: TaskContainer |
isDynamic | public boolean isDynamic()(Code) | | Indicates whether the introspected class is a dynamic one,
supporting arbitrary nested elements and/or attributes.
true if the introspected class is dynamic;false otherwise. since: Ant 1.6.3 See Also: DynamicElement See Also: DynamicElementNS |
setAttribute | public void setAttribute(Project p, Object element, String attributeName, String value) throws BuildException(Code) | | Sets the named attribute in the given element, which is part of the
given project.
Parameters: p - The project containing the element. This is used when filesneed to be resolved. Must not be null . Parameters: element - The element to set the attribute in. Must not benull . Parameters: attributeName - The name of the attribute to set. Must not benull . Parameters: value - The value to set the attribute to. This may be interpretedor converted to the necessary type if the setter methoddoesn't just take a string. Must not be null . exception: BuildException - if the introspected class doesn't supportthe given attribute, or if the settingmethod fails. |
storeElement | public void storeElement(Project project, Object parent, Object child, String elementName) throws BuildException(Code) | | Stores a named nested element using a storage method determined
by the initial introspection. If no appropriate storage method
is available, this method returns immediately.
Parameters: project - Ignored in this implementation.May be null . Parameters: parent - Parent instance to store the child in.Must not be null . Parameters: child - Child instance to store in the parent.Should not be null . Parameters: elementName - Name of the child element to store.May be null , in which casethis method returns immediately. exception: BuildException - if the storage method fails. |
supportsCharacters | public boolean supportsCharacters()(Code) | | Returns whether or not the introspected class supports PCDATA.
whether or not the introspected class supports PCDATA. |
supportsNestedElement | public boolean supportsNestedElement(String elementName)(Code) | | Indicates if this element supports a nested element of the
given name.
Parameters: elementName - the name of the nested element being checked true if the given nested element is supported |
supportsNestedElement | public boolean supportsNestedElement(String parentUri, String elementName)(Code) | | Indicate if this element supports a nested element of the
given name.
Parameters: parentUri - the uri of the parent Parameters: elementName - the name of the nested element being checked true if the given nested element is supported |
throwNotSupported | public void throwNotSupported(Project project, Object parent, String elementName)(Code) | | Utility method to throw a NotSupported exception
Parameters: project - the Project instance. Parameters: parent - the object which doesn't support a requested element Parameters: elementName - the name of the Element which is trying to be created. |
|
|