org.apache.tapestry.spec
Class ComponentSpecification

java.lang.Object
  extended by org.apache.tapestry.util.BasePropertyHolder
      extended by org.apache.tapestry.spec.LocatablePropertyHolder
          extended by org.apache.tapestry.spec.ComponentSpecification
All Implemented Interfaces:
org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, IComponentSpecification, IPropertyHolder

public class ComponentSpecification
extends LocatablePropertyHolder
implements IComponentSpecification

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.

Author:
Howard Lewis Ship
See Also:
IComponent, IContainedComponent, IPageLoader

Field Summary
protected  java.util.Map _assets
          Keyed on asset name, value is IAssetSpecification.
protected  java.util.Map _beans
          Defines all helper beans.
protected  java.util.Map _components
          Keyed on component id, value is IContainedComponent.
protected  java.util.Map _parameters
          Defines all formal parameters.
protected  java.util.Set _reservedParameterNames
          The names of all reserved informal parameter names (as lower-case).
 
Constructor Summary
ComponentSpecification()
           
 
Method Summary
 void addAsset(java.lang.String name, IAssetSpecification asset)
           
 void addBeanSpecification(java.lang.String name, IBeanSpecification specification)
           
 void addComponent(java.lang.String id, IContainedComponent component)
           
 void addInjectSpecification(InjectSpecification spec)
          Adds a InjectSpecification.
 void addParameter(IParameterSpecification spec)
          Adds the parameter.
 void addPropertySpecification(IPropertySpecification spec)
          Adds a new property specification.
 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).
 IAssetSpecification getAsset(java.lang.String name)
          Returns the IAssetSpecificationwith the given name, or null if no such specification exists.
 java.util.List getAssetNames()
          Returns a List of the String names of all assets, in alphabetical order
 java.util.Collection getBeanNames()
          Returns an unmodifiable collection of the names of all beans.
 IBeanSpecification getBeanSpecification(java.lang.String name)
          Returns the IBeanSpecificationfor the given name, or null if not such specification exists.
 IContainedComponent 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()
          Returns the class name to be used when instantiating the component, or null if no class name was provided in the specification (in which case, a system of defaults will be used to determine the class name).
 java.util.List getComponentIds()
          Returns an List of the String names of the IContainedComponents for this component.
 java.lang.String getDescription()
          Returns the documentation for this component.
 java.util.List getInjectSpecifications()
          Returns the list of InjectSpecification.
 IParameterSpecification getParameter(java.lang.String name)
          Returns the specification of a parameter with the given name, or null if no such parameter exists.
 java.util.List getParameterNames()
          Returns a List of of String names of all parameters.
 IPropertySpecification getPropertySpecification(java.lang.String name)
          Returns the named IPropertySpecification, or null if no such specification exist.
 java.util.List getPropertySpecificationNames()
          Returns a sorted, immutable list of the names of all IPropertySpecifications.
 java.lang.String getPublicId()
          Returns the XML Public Id for the specification file, or null if not applicable.
 java.util.Collection getRequiredParameters()
          Returns an unordered collection of IParameterSpecification, for all parameters that are required.
 java.util.Set getReservedParameterNames()
          Returns a Set of Strings; the reserved parameter names for the component.
 org.apache.hivemind.Resource getSpecificationLocation()
           
 boolean isDeprecated()
          Returns true if the component is deprecated.
 boolean isPageSpecification()
          Returns true if the specification is known to be a page specification and not a component specification.
 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 setDeprecated(boolean deprecated)
           
 void setDescription(java.lang.String description)
          Sets the documentation for this component.
 void setPageSpecification(boolean pageSpecification)
           
 void setPublicId(java.lang.String publicId)
           
 void setSpecificationLocation(org.apache.hivemind.Resource specificationLocation)
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.tapestry.spec.LocatablePropertyHolder
getLocation, setLocation
 
Methods inherited from class org.apache.tapestry.util.BasePropertyHolder
getProperty, getPropertyNames, removeProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.util.IPropertyHolder
getProperty, getPropertyNames, removeProperty, setProperty
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Field Detail

_components

protected java.util.Map _components
Keyed on component id, value is IContainedComponent.


_assets

protected java.util.Map _assets
Keyed on asset name, value is IAssetSpecification.


_parameters

protected java.util.Map _parameters
Defines all formal parameters. Keyed on parameter name, value is IParameterSpecification.


_beans

protected java.util.Map _beans
Defines all helper beans. Keyed on name, value is IBeanSpecification.

Since:
1.0.4

_reservedParameterNames

protected java.util.Set _reservedParameterNames
The names of all reserved informal parameter names (as lower-case). This allows the page loader to filter out any informal parameters during page load, rather than during render.

Since:
1.0.5
Constructor Detail

ComponentSpecification

public ComponentSpecification()
Method Detail

addAsset

public void addAsset(java.lang.String name,
                     IAssetSpecification asset)
Specified by:
addAsset in interface IComponentSpecification
Throws:
org.apache.hivemind.ApplicationRuntimeException - if the name already exists.

addComponent

public void addComponent(java.lang.String id,
                         IContainedComponent component)
Specified by:
addComponent in interface IComponentSpecification
Throws:
org.apache.hivemind.ApplicationRuntimeException - if the id is already defined.

addParameter

public void addParameter(IParameterSpecification spec)
Adds the parameter. The name is added as a reserved name.

Specified by:
addParameter in interface IComponentSpecification
Throws:
org.apache.hivemind.ApplicationRuntimeException - 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.

Specified by:
getAllowBody in interface IComponentSpecification
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.

Specified by:
getAllowInformalParameters in interface IComponentSpecification
See Also:
setAllowInformalParameters(boolean)

getAsset

public IAssetSpecification getAsset(java.lang.String name)
Returns the IAssetSpecificationwith the given name, or null if no such specification exists.

Specified by:
getAsset in interface IComponentSpecification
See Also:
addAsset(String,IAssetSpecification)

getAssetNames

public java.util.List getAssetNames()
Returns a List of the String names of all assets, in alphabetical order

Specified by:
getAssetNames in interface IComponentSpecification

getComponent

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

Specified by:
getComponent in interface IComponentSpecification
See Also:
addComponent(String, IContainedComponent)

getComponentClassName

public java.lang.String getComponentClassName()
Description copied from interface: IComponentSpecification
Returns the class name to be used when instantiating the component, or null if no class name was provided in the specification (in which case, a system of defaults will be used to determine the class name).

Specified by:
getComponentClassName in interface IComponentSpecification

getComponentIds

public java.util.List getComponentIds()
Returns an List of the String names of the IContainedComponents for this component.

Specified by:
getComponentIds in interface IComponentSpecification
See Also:
addComponent(String, IContainedComponent)

getParameter

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

Specified by:
getParameter in interface IComponentSpecification
See Also:
#addParameter(String, IParameterSpecification)

getRequiredParameters

public java.util.Collection getRequiredParameters()
Description copied from interface: IComponentSpecification
Returns an unordered collection of IParameterSpecification, for all parameters that are required. This includes only "real" parameters, not aliases.

Specified by:
getRequiredParameters in interface IComponentSpecification

getParameterNames

public java.util.List getParameterNames()
Returns a List of of String names of all parameters. This list is in alphabetical order.

Specified by:
getParameterNames in interface IComponentSpecification
See Also:
#addParameter(String, IParameterSpecification)

setAllowBody

public void setAllowBody(boolean value)
Specified by:
setAllowBody in interface IComponentSpecification

setAllowInformalParameters

public void setAllowInformalParameters(boolean value)
Specified by:
setAllowInformalParameters in interface IComponentSpecification

setComponentClassName

public void setComponentClassName(java.lang.String value)
Specified by:
setComponentClassName in interface IComponentSpecification

addBeanSpecification

public void addBeanSpecification(java.lang.String name,
                                 IBeanSpecification specification)
Specified by:
addBeanSpecification in interface IComponentSpecification
Throws:
org.apache.hivemind.ApplicationRuntimeException - if the bean already has a specification.
Since:
1.0.4

getBeanSpecification

public IBeanSpecification getBeanSpecification(java.lang.String name)
Returns the IBeanSpecificationfor the given name, or null if not such specification exists.

Specified by:
getBeanSpecification in interface IComponentSpecification
Since:
1.0.4

getBeanNames

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

Specified by:
getBeanNames in interface IComponentSpecification

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.

Specified by:
addReservedParameterName in interface IComponentSpecification
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.

Specified by:
isReservedParameterName in interface IComponentSpecification
Since:
1.0.5

toString

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

getDescription

public java.lang.String getDescription()
Returns the documentation for this component.

Specified by:
getDescription in interface IComponentSpecification
Since:
1.0.9

setDescription

public void setDescription(java.lang.String description)
Sets the documentation for this component.

Specified by:
setDescription in interface IComponentSpecification
Since:
1.0.9

getPublicId

public java.lang.String getPublicId()
Returns the XML Public Id for the specification file, or null if not applicable.

This method exists as a convienience for the Spindle plugin. A previous method used an arbitrary version string, the public id is more useful and less ambiguous.

Specified by:
getPublicId in interface IComponentSpecification
Since:
2.2

setPublicId

public void setPublicId(java.lang.String publicId)
Specified by:
setPublicId in interface IComponentSpecification
Since:
2.2 *

isPageSpecification

public boolean isPageSpecification()
Returns true if the specification is known to be a page specification and not a component specification. Earlier versions of the framework did not distinguish between the two, but starting in 2.2, there are seperate XML entities for pages and components. Pages omit several attributes and entities related to parameters, as parameters only make sense for components.

Specified by:
isPageSpecification in interface IComponentSpecification
Since:
2.2

setPageSpecification

public void setPageSpecification(boolean pageSpecification)
Specified by:
setPageSpecification in interface IComponentSpecification
Since:
2.2 *

getSpecificationLocation

public org.apache.hivemind.Resource getSpecificationLocation()
Specified by:
getSpecificationLocation in interface IComponentSpecification
Since:
3.0 *

setSpecificationLocation

public void setSpecificationLocation(org.apache.hivemind.Resource specificationLocation)
Specified by:
setSpecificationLocation in interface IComponentSpecification
Since:
3.0 *

addPropertySpecification

public void addPropertySpecification(IPropertySpecification spec)
Adds a new property specification. The name of the property must not already be defined (and must not change after being added).

Specified by:
addPropertySpecification in interface IComponentSpecification
Since:
3.0

getPropertySpecificationNames

public java.util.List getPropertySpecificationNames()
Returns a sorted, immutable list of the names of all IPropertySpecifications.

Specified by:
getPropertySpecificationNames in interface IComponentSpecification
Since:
3.0

getPropertySpecification

public IPropertySpecification getPropertySpecification(java.lang.String name)
Returns the named IPropertySpecification, or null if no such specification exist.

Specified by:
getPropertySpecification in interface IComponentSpecification
Since:
3.0
See Also:
addPropertySpecification(IPropertySpecification)

addInjectSpecification

public void addInjectSpecification(InjectSpecification spec)
Description copied from interface: IComponentSpecification
Adds a InjectSpecification.

Specified by:
addInjectSpecification in interface IComponentSpecification

getInjectSpecifications

public java.util.List getInjectSpecifications()
Description copied from interface: IComponentSpecification
Returns the list of InjectSpecification. Will return an empty list if no specifications have been added.

Specified by:
getInjectSpecifications in interface IComponentSpecification

isDeprecated

public boolean isDeprecated()
Description copied from interface: IComponentSpecification
Returns true if the component is deprecated. Deprecated components generate a warning when used.

Specified by:
isDeprecated in interface IComponentSpecification
Since:
4.0

setDeprecated

public void setDeprecated(boolean deprecated)
Specified by:
setDeprecated in interface IComponentSpecification
Since:
4.0

getReservedParameterNames

public java.util.Set getReservedParameterNames()
Description copied from interface: IComponentSpecification
Returns a Set of Strings; the reserved parameter names for the component. This combines explicit reserved names with formal parameter names. Each parameter name in the Set will be all lower case (to facilitate a caseless comparison).

Specified by:
getReservedParameterNames in interface IComponentSpecification