Class EntryKeyTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.di.tags.DependencyTag
-
- net.sf.jguiraffe.gui.builder.di.tags.EntryKeyTag
-
- All Implemented Interfaces:
ValueSupport
,org.apache.commons.jelly.Tag
public class EntryKeyTag extends DependencyTag
A tag handler class for defining the key of an
.EntryTag
When defining maps with the dependency injection framework the
MapTag
together with theEntryTag
are used. However if the map uses complex objects as keys, it is not directly possible to set the key value with theEntryTag
(for the value this is no problem because an arbitrary dependency - including anAbstractBeanTag
in the body of theEntryTag
- can be defined for specifying the desired value).With this tag the same is possible for the key. When it gets executed the tag checks whether its parent is an
EntryTag
. By inheriting fromDependencyTag
all possibilities of defining values are supported, including the usage of complex value tags in this tag's body. The following example shows how an entry for a map can be created whose key is a list:<map> <entry value="42"> <entryKey> <list elementClass="java.lang.Integer"> <element value="10"/> <element value="20"/> </list> </entryKey> </entry> </map>
Of course it is possible defining both the key and the value as complex objects in the body of theEntryTag
. The next fragment shows the definition of an entry with a list as key and a set as value:<entry> <entryKey> <list elementClass="java.lang.Integer"> <element value="10"/> <element value="20"/> </list> </entryKey> <set> <element value="ten"/> <element value="twenty"/> </set> </entry>
No matter how (either directly using the
value
attribute or by a tag in the body), a value has to be defined for this tag, otherwise an exception will be thrown. The following table lists all attributes supported by this tag (these are the typical attributes of aDependencyTag
:Attribute Description Optional value With this attribute the value can be directly set. If the value is specified as a string constant and a value class is defined, an automatic type conversion will be performed. yes valueClass Here the class of the value can be specified. The tag will try to convert the value to this class if necessary. yes valueClassName This attribute has the same effect as valueClass
, but the name of the value class is specified rather than the class object itself.yes valueClassLoader If the name of the value class is specified, with this attribute a class loader for resolving the class can be defined. The name specified here will be passed to the current ClassLoaderProvider
for obtaining the desired class loader.yes refName With this attribute another bean can be referenced by its name. This bean will be resolved and become the value of this tag. yes refClass It is possible to refer to another bean by its class (for this purpose there should only be a single bean with this class so there are no ambiguities). The class of this bean can be specified by this attribute. yes refClassName This attribute has the same meaning as the refClass
attribute, but the class of the bean that is referenced can be specified by its name.yes refClassLoader If the refClassName
attribute is used for specifying the class of a bean referenced, with this attribute a class loader can be determined for resolving the class.yes - Version:
- $Id: EntryKeyTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description EntryKeyTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doTag(org.apache.commons.jelly.XMLOutput output)
Executes this tag.-
Methods inherited from class net.sf.jguiraffe.gui.builder.di.tags.DependencyTag
createDependency, createValueDependency, getDependency, getRefClassData, getRefName, getValueData, getVar, hasDependency, processDependencyDefinitions, setDependency, setRefClass, setRefClassLoader, setRefClassName, setRefName, setValue, setValueClass, setValueClassLoader, setValueClassName, setVar
-
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
-
doTag
public void doTag(org.apache.commons.jelly.XMLOutput output) throws org.apache.commons.jelly.JellyTagException
Executes this tag. Checks whether the parent tag is an
. If this is the case, the key value will be set based on the attributes defined for this tag.EntryTag
- Parameters:
output
- the output object- Throws:
org.apache.commons.jelly.JellyTagException
- if the tag is incorrectly used or an error occurs
-
-