Class CollectionTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.di.tags.AbstractBeanTag
-
- net.sf.jguiraffe.gui.builder.di.tags.CollectionTag
-
- All Implemented Interfaces:
org.apache.commons.jelly.Tag
public abstract class CollectionTag extends AbstractBeanTag
A base tag handler class for defining collections in bean builder scripts.
This base class provides basic functionality for maintaining a collection with the dependencies representing the elements of the collection to be created. It defines an
addElement()
method to be called by tags in the body of this tag for adding new element dependencies to the collection. The type of the elements to add can be specified by attributes in this class. When adding new elements a type conversion will be performed if necessary. It is also possible to override the data type when adding a new element. This way collections with heterogeneous content can be created. However, the logic for type conversions is implemented by the tag handler classes that invoke theaddElement()
method. This base class also supports aname
attribute. So both named and anonymous beans can be created.- Version:
- $Id: CollectionTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CollectionTag()
Creates a new instance ofCollectionTag
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addElement(Dependency dep)
Adds a new element to the collection managed by this tag.ClassDescData
getElementClassData()
Returns the object with the class definition data of the collection's elements.ClassDescription
getElementClassDesc()
Returns the class description for the elements of the represented collection.Collection<Dependency>
getElementDependencies()
Returns a collection with the dependencies for the elements of the collection created by this tag.String
getName()
Returns the name of the bean produced by this tag.protected void
processBeforeBody()
Performs tag-specific actions before the body gets executed.void
setElementClass(Class<?> cls)
Set method for the elementClass attribute.protected void
setElementClassDesc(ClassDescription cdesc)
Sets the class description for the elements of this collection.void
setElementClassLoader(String loader)
Set method for the elementClassLoader attribute.void
setElementClassName(String clsName)
Set method for the elementClassName attribute.void
setName(String name)
Set method of thename
attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.di.tags.AbstractBeanTag
createBeanProvider, doTag, getBeanStoreTag, getStore, getTargetDependency, isAnonymous, process, setBeanStoreTag, setStore, store
-
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
-
-
-
-
Method Detail
-
getName
public String getName()
Returns the name of the bean produced by this tag.- Overrides:
getName
in classAbstractBeanTag
- Returns:
- the bean name
-
setName
public void setName(String name)
Set method of thename
attribute.- Parameters:
name
- the attribute's value
-
getElementClassData
public ClassDescData getElementClassData()
Returns the object with the class definition data of the collection's elements. This object is filled by the set methods for the attributes related to the element class.- Returns:
- the class definition data for the element class of the collection
-
getElementClassDesc
public ClassDescription getElementClassDesc()
Returns the class description for the elements of the represented collection. This object is available during execution of this tag's body if the element class is defined. Otherwise null is returned.- Returns:
- the class description for the collection's elements
-
setElementClass
public void setElementClass(Class<?> cls)
Set method for the elementClass attribute. With this attribute the class of the collection elements can be set directly.- Parameters:
cls
- the class of the elements of this collection
-
setElementClassName
public void setElementClassName(String clsName)
Set method for the elementClassName attribute. With this attribute the class of the collection elements can be specified by name.- Parameters:
clsName
- the name of the class of the elements of this collection
-
setElementClassLoader
public void setElementClassLoader(String loader)
Set method for the elementClassLoader attribute. This attribute defines the class loader to be used for loading the class of the collection's elements.- Parameters:
loader
- the name of the class loader
-
getElementDependencies
public Collection<Dependency> getElementDependencies()
Returns a collection with the dependencies for the elements of the collection created by this tag. This information is required when creating the bean provider representing the final collection.- Returns:
- the dependencies for the collection elements
-
addElement
public void addElement(Dependency dep)
Adds a new element to the collection managed by this tag. This method is intended to be called by tags in the body of this tag. It adds the givenDependency
to the internal list of element dependencies.- Parameters:
dep
- the dependency to be added (must not be null)- Throws:
IllegalArgumentException
- if the dependency is null
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagException
Performs tag-specific actions before the body gets executed. This implementation validates the class description for the elements of the collection.- Overrides:
processBeforeBody
in classAbstractBeanTag
- Throws:
org.apache.commons.jelly.JellyTagException
- if the tag is incorrectly used
-
setElementClassDesc
protected void setElementClassDesc(ClassDescription cdesc)
Sets the class description for the elements of this collection. This method is called byprocessBeforeBody()
with a class description derived from the attribute values.- Parameters:
cdesc
- the class description of the collection elements
-
-