com.primix.tapestry.spec
Class ComponentSpecification

java.lang.Object
  |
  +--com.primix.tapestry.util.BasePropertyHolder
        |
        +--com.primix.tapestry.spec.ComponentSpecification
All Implemented Interfaces:
IPropertyHolder

public class ComponentSpecification
extends BasePropertyHolder

A specification for a component, as read from an XML specification file.

A specification consists of

From this information, an actual component may be instantiated and initialized. Instantiating a component is usually a recursive process, since to initialize a container component, it is necessary to instantiate and initialize its contained components as well.

Version:
$Id: ComponentSpecification.java,v 1.9 2001/08/24 21:38:48 hship Exp $
Author:
Howard Ship
See Also:
IComponent, ContainedComponent, IPageLoader

Constructor Summary
ComponentSpecification()
           
 
Method Summary
 void addAsset(java.lang.String name, AssetSpecification asset)
           
 void addBeanSpecification(java.lang.String name, BeanSpecification specification)
           
 void addComponent(java.lang.String id, ContainedComponent component)
           
 void addParameter(java.lang.String name, ParameterSpecification spec)
          Adds the parameter.
 void addReservedParameterName(java.lang.String value)
          Adds the value as a reserved name.
 boolean getAllowBody()
          Returns true if the component is allowed to wrap other elements (static HTML or other components).
 boolean getAllowInformalParameters()
          Returns true if the component allows informal parameters (parameters not formally defined).
 AssetSpecification getAsset(java.lang.String name)
          Returns the AssetSpecification with the given name, or null if no such specification exists.
 java.util.Collection getAssetNames()
          Returns an unmodifiable Collection of the String names of all assets.
 java.util.Collection getBeanNames()
          Returns an unmodifiable collection of the names of all beans.
 BeanSpecification getBeanSpecification(java.lang.String name)
          Returns the BeanSpecification for the given name, or null if not such specification exists.
 ContainedComponent getComponent(java.lang.String id)
          Returns the specification of a contained component with the given id, or null if no such contained component exists.
 java.lang.String getComponentClassName()
           
 java.util.Collection getComponentIds()
          Returns an umodifiable Collection of the String names of the ContainedComponents for this component.
 ParameterSpecification getParameter(java.lang.String name)
          Returns the specification of a parameter with the given name, or null if no such parameter exists.
 java.util.Collection getParameterNames()
          Returns an umodifiable Collection of String names of all parameters.
 java.lang.String getSpecificationResourcePath()
          Returns the String used to identify the resource parsed to form this ComponentSpecification.
 boolean isReservedParameterName(java.lang.String value)
          Returns true if the value specified is in the reserved name list.
 void setAllowBody(boolean value)
           
 void setAllowInformalParameters(boolean value)
           
 void setComponentClassName(java.lang.String value)
           
 void setSpecificationResourcePath(java.lang.String value)
           
 java.lang.String toString()
           
 
Methods inherited from class com.primix.tapestry.util.BasePropertyHolder
getProperty, getPropertyNames, removeProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComponentSpecification

public ComponentSpecification()
Method Detail

addAsset

public void addAsset(java.lang.String name,
                     AssetSpecification asset)
Throws:
java.lang.IllegalArgumentException - if the name already exists.

addComponent

public void addComponent(java.lang.String id,
                         ContainedComponent component)
Throws:
java.lang.IllegalArgumentException - if the id is already defined.

addParameter

public void addParameter(java.lang.String name,
                         ParameterSpecification spec)
Adds the parameter. The name is added as a reserved name.
Throws:
java.lang.IllegalArgumentException - if the name already exists.

getAllowBody

public boolean getAllowBody()
Returns true if the component is allowed to wrap other elements (static HTML or other components). The default is true.
See Also:
setAllowBody(boolean)

getAllowInformalParameters

public boolean getAllowInformalParameters()
Returns true if the component allows informal parameters (parameters not formally defined). Informal parameters are generally used to create additional HTML attributes for an HTML tag rendered by the component. This is often used to specify JavaScript event handlers or the class of the component (for Cascarding Style Sheets).

The default value is true.

See Also:
setAllowInformalParameters(boolean)

getAsset

public AssetSpecification getAsset(java.lang.String name)
Returns the AssetSpecification with the given name, or null if no such specification exists.
See Also:
addAsset(String,AssetSpecification)

getAssetNames

public java.util.Collection getAssetNames()
Returns an unmodifiable Collection of the String names of all assets.

getComponent

public ContainedComponent getComponent(java.lang.String id)
Returns the specification of a contained component with the given id, or null if no such contained component exists.
See Also:
addComponent(String, ContainedComponent)

getComponentClassName

public java.lang.String getComponentClassName()

getComponentIds

public java.util.Collection getComponentIds()
Returns an umodifiable Collection of the String names of the ContainedComponents for this component.
See Also:
addComponent(String, ContainedComponent)

getParameter

public ParameterSpecification getParameter(java.lang.String name)
Returns the specification of a parameter with the given name, or null if no such parameter exists.
See Also:
addParameter(String, ParameterSpecification)

getParameterNames

public java.util.Collection getParameterNames()
Returns an umodifiable Collection of String names of all parameters.
See Also:
addParameter(String, ParameterSpecification)

getSpecificationResourcePath

public java.lang.String getSpecificationResourcePath()
Returns the String used to identify the resource parsed to form this ComponentSpecification.

setAllowBody

public void setAllowBody(boolean value)

setAllowInformalParameters

public void setAllowInformalParameters(boolean value)

setComponentClassName

public void setComponentClassName(java.lang.String value)

setSpecificationResourcePath

public void setSpecificationResourcePath(java.lang.String value)

addBeanSpecification

public void addBeanSpecification(java.lang.String name,
                                 BeanSpecification specification)
Throws:
java.lang.IllegalArgumentException - if the bean already has a specification.
Since:
1.0.4

getBeanSpecification

public BeanSpecification getBeanSpecification(java.lang.String name)
Returns the BeanSpecification for the given name, or null if not such specification exists.
Since:
1.0.4

getBeanNames

public java.util.Collection getBeanNames()
Returns an unmodifiable collection of the names of all beans.

addReservedParameterName

public void addReservedParameterName(java.lang.String value)
Adds the value as a reserved name. Reserved names are not allowed as the names of informal parameters. Since the comparison is caseless, the value is converted to lowercase before being stored.
Since:
1.0.5

isReservedParameterName

public boolean isReservedParameterName(java.lang.String value)
Returns true if the value specified is in the reserved name list. The comparison is caseless. All formal parameters are automatically in the reserved name list, as well as any additional reserved names specified in the component specification. The latter refer to HTML attributes generated directly by the component.
Since:
1.0.5

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object