org.oddjob.arooa
Class ArooaRuntime

java.lang.Object
  extended byorg.oddjob.arooa.ArooaRuntime
All Implemented Interfaces:
RuntimeConfiguration

public class ArooaRuntime
extends java.lang.Object
implements RuntimeConfiguration

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


Constructor Summary
ArooaRuntime(java.lang.Object wrappedObject, java.lang.String elementTag)
          Constructor for creating a wrapper wthout a context.
ArooaRuntime(java.lang.Object wrappedObject, java.lang.String elementTag, ArooaContext context)
          Constructor for creating a wrapper for the specified object.
 
Method Summary
 void addChild(RuntimeConfiguration child)
          Adds a child element to the wrapped element.
 void addConfigurationListener(ConfigurationListener l)
           
 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 strictSubstitution)
          Configures the wrapped element.
protected  void fireConfigurationComplete()
           
 java.lang.String getAttribute(java.lang.String name)
          Get the text 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 isLeaveProxy()
          leaveProxy isn't set in the context until after this RTC is created.
 boolean isStrictSubstituation()
           
 void link(RuntimeConfiguration link)
          Link a to child component.
 void removeConfigurationListener(ConfigurationListener l)
           
 void setAttribute(java.lang.String name, RuntimeConfiguration rtc)
          Set an attribute to a runtime configurable
 void setAttribute(java.lang.String name, java.lang.String value)
          Set an attribute to a given value
 void setConfigured(boolean configured)
          Set this runtime as configured.
 void setMappedProperty(java.lang.String name, java.lang.String key, RuntimeConfiguration rtc)
          Set a mapped property.
 void setStrictSubstituation(boolean value)
           
 java.lang.String toString()
           
 RuntimeConfiguration unlink(java.lang.Object linkedComponent)
          Remove a linked runtime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArooaRuntime

public ArooaRuntime(java.lang.Object wrappedObject,
                    java.lang.String elementTag,
                    ArooaContext context)
Constructor for creating a wrapper for the specified object.

The Context is provided then the following will affect how the object is configured at runtime.

Parameters:
wrappedObject - The element to configure. Must not be null.
elementTag - The tag name generating this element. Should not be null.
context - A Context, may not be null.

ArooaRuntime

public ArooaRuntime(java.lang.Object wrappedObject,
                    java.lang.String elementTag)
Constructor for creating a wrapper wthout a context.

Parameters:
wrappedObject - 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.

isLeaveProxy

public boolean isLeaveProxy()
leaveProxy isn't set in the context until after this RTC is created. Find it's value when it's first required.

Returns:
leave proxy values unresolved. true/false.

setStrictSubstituation

public void setStrictSubstituation(boolean value)

isStrictSubstituation

public boolean isStrictSubstituation()

setConfigured

public void setConfigured(boolean configured)
Set this runtime as configured. This will typically be after a restore so all the configuration doesn't get called again.

Parameters:
configured -

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.

setMappedProperty

public void setMappedProperty(java.lang.String name,
                              java.lang.String key,
                              RuntimeConfiguration rtc)
Set a mapped property.

Parameters:
name - The name of the mapped property.
key - The mapped properties key.

setAttribute

public void setAttribute(java.lang.String name,
                         RuntimeConfiguration rtc)
Set an attribute to a runtime configurable

Parameters:
name - the name of the attribute.

getAttribute

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

Specified by:
getAttribute in interface RuntimeConfiguration
Parameters:
name - The attribute name.
Returns:
The attributes text. Null if it's inline.

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.

link

public void link(RuntimeConfiguration link)
Link a to child component. Linked components are child components that arn't independent.


unlink

public RuntimeConfiguration unlink(java.lang.Object linkedComponent)
Remove a linked runtime. This will happen when a wrapper is taking responsiblilty for configuring a child.

Parameters:
linkedComponent - The linked component.
Returns:
The linked runtime.

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 strictSubstitution)
               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.

addConfigurationListener

public void addConfigurationListener(ConfigurationListener l)

removeConfigurationListener

public void removeConfigurationListener(ConfigurationListener l)

fireConfigurationComplete

protected void fireConfigurationComplete()

toString

public java.lang.String toString()