org.oddjob.ant
Class AntJobRtc

java.lang.Object
  extended byorg.oddjob.ant.AntJobRtc
All Implemented Interfaces:
RuntimeConfiguration, java.io.Serializable

public class AntJobRtc
extends java.lang.Object
implements RuntimeConfiguration, java.io.Serializable

Wrapper class that holds the attributes of an element, its children, and any text within it. It then takes care of configuring that element at runtime.

Based on an original by Stefan Bodewig

See Also:
Serialized Form

Constructor Summary
AntJobRtc(org.apache.tools.ant.Project project, java.lang.Object proxy, java.lang.String elementTag)
          Sole constructor creating a wrapper for the specified object.
 
Method Summary
 void addChild(RuntimeConfiguration child)
          Adds a child element to the wrapped element.
 void addText(char[] buf, int start, int count)
          Adds characters from #PCDATA areas to the wrapped element.
 void addText(java.lang.String data)
          Adds characters from #PCDATA areas to the wrapped element.
 void configure()
          Configure with preset or no properties.
 void configure(RegistryLookup registry, boolean nullAllowed)
          Configures the wrapped element.
 java.lang.String getAttribute(java.lang.String name)
          Get the PropertyHelper for an attribute.
 java.util.Hashtable getAttributeMap()
          Return the attribute map.
 java.util.Enumeration getChildren()
          Returns an enumeration of all child wrappers.
 java.lang.String getElementTag()
          Returns the tag name of the wrapped element.
 RegistryLookup getRegistryLookup()
           
 java.lang.StringBuffer getText()
          Get the text content of this element.
 java.lang.Object getWrappedObject()
          Get the object for which this RuntimeConfigurable holds the configuration information
 boolean isNullAllowed()
           
 void setAttribute(java.lang.String name, java.lang.String value)
          Set an attribute to a given value
 void setNullAllowed(boolean value)
           
 void setRegistryLookup(RegistryLookup registry)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AntJobRtc

public AntJobRtc(org.apache.tools.ant.Project project,
                 java.lang.Object proxy,
                 java.lang.String elementTag)
Sole constructor creating a wrapper for the specified object.

Parameters:
proxy - The element to configure. Must not be null.
elementTag - The tag name generating this element. Should not be null.
Method Detail

getWrappedObject

public java.lang.Object getWrappedObject()
Get the object for which this RuntimeConfigurable holds the configuration information

Specified by:
getWrappedObject in interface RuntimeConfiguration
Returns:
the object whose configure is held by this instance.

setNullAllowed

public void setNullAllowed(boolean value)

isNullAllowed

public boolean isNullAllowed()

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Set an attribute to a given value

Parameters:
name - the name of the attribute.
value - the attribute's value.

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Get the PropertyHelper for an attribute.

Specified by:
getAttribute in interface RuntimeConfiguration
Parameters:
name - The attribute name.
Returns:
The attribute's PropertyHelper.

getAttributeMap

public java.util.Hashtable getAttributeMap()
Return the attribute map.

Returns:
Attribute name to attribute value map

addChild

public void addChild(RuntimeConfiguration child)
Adds a child element to the wrapped element.

Specified by:
addChild in interface RuntimeConfiguration
Parameters:
child - The child element wrapper to add to this one. Must not be null.

getChildren

public java.util.Enumeration getChildren()
Returns an enumeration of all child wrappers.

Specified by:
getChildren in interface RuntimeConfiguration
Returns:
an enumeration of the child wrappers.

addText

public void addText(java.lang.String data)
Adds characters from #PCDATA areas to the wrapped element.

Parameters:
data - Text to add to the wrapped element. Should not be null.

addText

public void addText(char[] buf,
                    int start,
                    int count)
Adds characters from #PCDATA areas to the wrapped element.

Specified by:
addText in interface RuntimeConfiguration
Parameters:
buf - A character array of the text within the element. Must not be null.
start - The start element in the array.
count - The number of characters to read from the array.

getText

public java.lang.StringBuffer getText()
Get the text content of this element. Various text chunks are concatenated, there is no way ( currently ) of keeping track of multiple fragments.

Returns:
the text content of this element.

getElementTag

public java.lang.String getElementTag()
Returns the tag name of the wrapped element.

Specified by:
getElementTag in interface RuntimeConfiguration
Returns:
The tag name of the wrapped element. This is unlikely to be null, but may be.

configure

public void configure()
               throws ArooaException
Configure with preset or no properties.

Specified by:
configure in interface RuntimeConfiguration
Throws:
ArooaException - If it can't be configured.

configure

public void configure(RegistryLookup registry,
                      boolean nullAllowed)
               throws ArooaException
Configures the wrapped element. The attributes and text for the wrapped element are configured. Each time the wrapper is configured, the attributes and text for it are reset. If the element has an id attribute, a reference is added to the project as well.

Specified by:
configure in interface RuntimeConfiguration
Throws:
ArooaException - if the configuration fails, for instance due to invalid attributes or children, or text being added to an element which doesn't accept it.

getRegistryLookup

public RegistryLookup getRegistryLookup()
Returns:
Returns the properties.

setRegistryLookup

public void setRegistryLookup(RegistryLookup registry)