IntrospectionHelper (Apache Ant API)
Keywords: org.apache.tools.ant.IntrospectionHelper class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant
Class IntrospectionHelper

    java.lang.Object
      org.apache.tools.ant.IntrospectionHelper

All Implemented Interfaces:
  BuildListener, java.util.EventListener

public class IntrospectionHelper
extends java.lang.Object
implements BuildListener

Helper class that collects the methods a task or nested element holds to set attributes, create nested elements or hold PCDATA elements.

Author:
  Stefan Bodewig

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)` Creates a named nested element.
`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.
`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.
`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.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getHelper

    public static IntrospectionHelper getHelper(java.lang.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`.
  Returns:
    a helper for the specified class

### setAttribute

    public void setAttribute(Project p,
                             java.lang.Object element,
                             java.lang.String attributeName,
                             java.lang.String value)
                      throws BuildException

  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 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`.
  Throws:
    `BuildException` - if the introspected class doesn't support the given attribute, or if the setting method fails.

### addText

    public void addText(Project project,
                        java.lang.Object element,
                        java.lang.String text)
                 throws BuildException

  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`.
    `element` - The element to add the text to. Must not be `null`.
    `text` - The text to add. Must not be `null`.
  Throws:
    `BuildException` - if non-whitespace text is provided and no method is available to handle it, or if the handling method fails.

### createElement

    public java.lang.Object createElement(Project project,
                                          java.lang.Object parent,
                                          java.lang.String elementName)
                                   throws BuildException

  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 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`.
  Returns:
    an instance of the specified element type
  Throws:
    `BuildException` - if no method is available to create the element instance, or if the creating method fails.

### storeElement

    public void storeElement(Project project,
                             java.lang.Object parent,
                             java.lang.Object child,
                             java.lang.String elementName)
                      throws BuildException

  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`.
    `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.
  Throws:
    `BuildException` - if the storage method fails.

### getElementType

    public java.lang.Class getElementType(java.lang.String elementName)
                                   throws BuildException

  Returns the type of a named nested element.

  Parameters:
    `elementName` - The name of the element to find the type of. Must not be `null`.
  Returns:
    the type of the nested element with the specified name. This will never be `null`.
  Throws:
    `BuildException` - if the introspected class does not support the named nested element.

### getAttributeType

    public java.lang.Class getAttributeType(java.lang.String attributeName)
                                     throws BuildException

  Returns the type of a named attribute.

  Parameters:
    `attributeName` - The name of the attribute to find the type of. Must not be `null`.
  Returns:
    the type of the attribute with the specified name. This will never be `null`.
  Throws:
    `BuildException` - if the introspected class does not support the named attribute.

### supportsCharacters

    public boolean supportsCharacters()

  Returns whether or not the introspected class supports PCDATA.

  Returns:
    whether or not the introspected class supports PCDATA.

### getAttributes

    public java.util.Enumeration getAttributes()

  Returns an enumeration of the names of the attributes supported by the introspected class.

  Returns:
    an enumeration of the names of the attributes supported by the introspected class.

### getNestedElements

    public java.util.Enumeration getNestedElements()

  Returns an enumeration of the names of the nested elements supported by the introspected class.

  Returns:
    an enumeration of the names of the nested elements supported by the introspected class.

### getElementName

    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. 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`.
    `element` - The element to describe. Must not be `null`.
  Returns:
    a description of the element type

### buildFinished

    public void buildFinished(BuildEvent event)

  Clears all storage used by this class, including the static cache of helpers.

  Specified by:
    `buildFinished` in interface `BuildListener`
  Parameters:
    `event` - Ignored in this implementation.
  See Also:
    `BuildEvent.getException()`

### buildStarted

    public void buildStarted(BuildEvent event)

  Empty implementation to satisfy the BuildListener interface.

  Specified by:
    `buildStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.

### targetStarted

    public void targetStarted(BuildEvent event)

  Empty implementation to satisfy the BuildListener interface.

  Specified by:
    `targetStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getTarget()`

### targetFinished

    public void targetFinished(BuildEvent event)

  Empty implementation to satisfy the BuildListener interface.

  Specified by:
    `targetFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getException()`

### taskStarted

    public void taskStarted(BuildEvent event)

  Empty implementation to satisfy the BuildListener interface.

  Specified by:
    `taskStarted` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getTask()`

### taskFinished

    public void taskFinished(BuildEvent event)

  Empty implementation to satisfy the BuildListener interface.

  Specified by:
    `taskFinished` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getException()`

### messageLogged

    public void messageLogged(BuildEvent event)

  Empty implementation to satisfy the BuildListener interface.

  Specified by:
    `messageLogged` in interface `BuildListener`
  Parameters:
    `event` - An event with any relevant extra information. Must not be `null`.
  See Also:
    `BuildEvent.getMessage()`, `BuildEvent.getPriority()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.