Class ValueData
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.di.tags.ValueData
-
public class ValueData extends Object
A data class for holding all information required for creating a value.
Some tag handler classes support the creation of a constant value. Such a value is defined by the value object itself and optionally by a target class used for type conversion. This class supports all properties required for defining a value. The value is passed to the
valueattribute. Its target class can be specified using thevalueClass,valueClassName, andvalueClassLoaderattributes (which gather the data supported by aClassDescriptionobject. There are also some helper methods for validating the passed in data and creating a constant bean provider.Tag handler implementations that need to support a value definition can define a member variable of this type. Then they have to define set methods for the attributes determining the value and its class and delegate to the corresponding set methods of this class.
Implementation note: This class is not thread-safe.
- Version:
- $Id: ValueData.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description ValueData(org.apache.commons.jelly.Tag owningTag)Creates a new instance ofValueData.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstantBeanProvidercreateValueProvider()Creates the bean provider for the specified value.ConstantBeanProvidercreateValueProvider(ClassDescription defClass)Creates the bean provider for the specified value using the given default class description.org.apache.commons.jelly.TaggetOwner()Returns a reference to the owning tag.ObjectgetValue()Returns the value for a constant dependency.ClassDescDatagetValueClassData()Returns theClassDescDataobject that defines the target class of the value.booleanisValueDefined()Returns a flag whether the value is defined.static Class<?>resolveClassDescData(org.apache.commons.jelly.JellyContext context, ClassDescData cdata)Resolves the specifiedClassDescDataobject.static Class<?>resolveClassDescription(org.apache.commons.jelly.JellyContext context, ClassDescription cd)Resolves the specifiedClassDescription.voidsetValue(Object value)Set method of the value attribute.voidsetValueClass(Class<?> c)Set method for the valueClass attribute.voidsetValueClassLoader(String s)Set method for the valueClassLoader attribute.voidsetValueClassName(String s)Set method for the valueClassName attribute.
-
-
-
Constructor Detail
-
ValueData
public ValueData(org.apache.commons.jelly.Tag owningTag)
Creates a new instance ofValueData.- Parameters:
owningTag- the tag that owns this object (must not be null)- Throws:
IllegalArgumentException- if the reference to the owner is null
-
-
Method Detail
-
getOwner
public org.apache.commons.jelly.Tag getOwner()
Returns a reference to the owning tag.- Returns:
- the owner
-
getValueClassData
public ClassDescData getValueClassData()
Returns theClassDescDataobject that defines the target class of the value.- Returns:
- the target class data of the value
-
getValue
public Object getValue()
Returns the value for a constant dependency.- Returns:
- the value
-
setValue
public void setValue(Object value)
Set method of the value attribute. Here the actual value can be set.- Parameters:
value- the attribute's value
-
setValueClass
public void setValueClass(Class<?> c)
Set method for the valueClass attribute. This attribute allows defining the class of the value. When creating the value bean provider a conversion to this type will be performed.- Parameters:
c- the attribute's value
-
setValueClassName
public void setValueClassName(String s)
Set method for the valueClassName attribute. This is analogous tosetValueClass(), but the value's class can be specified by name.- Parameters:
s- the attribute's value
-
setValueClassLoader
public void setValueClassLoader(String s)
Set method for the valueClassLoader attribute. If the value class is specified by name, with this property a class loader can be selected, which is to be used for resolving the actual value class.- Parameters:
s- the attribute's value
-
isValueDefined
public boolean isValueDefined()
Returns a flag whether the value is defined. Defined means that thesetValue(Object)method has been called at least once - even if a value of null was passed. This makes it possible to set null values.- Returns:
- a flag whether a value for this tag was specified
-
createValueProvider
public ConstantBeanProvider createValueProvider() throws org.apache.commons.jelly.JellyTagException
Creates the bean provider for the specified value. If necessary, type conversion is performed.- Returns:
- the bean provider managing the constant value specified for this tag
- Throws:
org.apache.commons.jelly.JellyTagException- if the target class for a conversion is ambiguousIllegalArgumentException- if type conversion fails
-
createValueProvider
public ConstantBeanProvider createValueProvider(ClassDescription defClass) throws org.apache.commons.jelly.JellyTagException
Creates the bean provider for the specified value using the given default class description. If a class of the value is specified using the properties of this instance, this class will be used. Otherwise the passed in class description (if defined) will be used.- Parameters:
defClass- the default class description- Returns:
- the bean provider managing the constant value specified for this tag
- Throws:
org.apache.commons.jelly.JellyTagException- if the target class for a conversion is ambiguousIllegalArgumentException- if type conversion fails
-
resolveClassDescData
public static Class<?> resolveClassDescData(org.apache.commons.jelly.JellyContext context, ClassDescData cdata) throws org.apache.commons.jelly.JellyTagException
Resolves the specifiedClassDescDataobject. This method obtains an optionalClassDescriptionfrom the class data object (this may be null if the class is undefined or throw an exception if the class definition is ambiguous). ThenresolveClassDescription()is invoked.- Parameters:
context- the Jelly contextcdata- the class description data object- Returns:
- the resolved class (can be null if no class is defined)
- Throws:
org.apache.commons.jelly.JellyTagException- if the class description is invalid
-
resolveClassDescription
public static Class<?> resolveClassDescription(org.apache.commons.jelly.JellyContext context, ClassDescription cd)
Resolves the specifiedClassDescription. This method obtains theClassLoaderProviderfrom theobject found in the passed in Jelly context and uses it to obtain the target class from the class description. The passed in description can be null, then result will also be null.DIBuilderData- Parameters:
context- the Jelly contextcd- the class description to resolve (can be null)- Returns:
- the class the class description refers to
-
-