On 1/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Is there any way to support a JDK 5.0 Enum in Betwixt? At the moment it jus
> defines:
> <entityType>
> <declaringClass>net......EntityType</declaringClass>
> </entityType>
>
> without any of the selected value.
I think, a converter will help you there:
for reading:
BeanReader reader = ...
reader.getBindingConfiguration().setObjectStringConverter(new
EnumStringConverter());
for writing:
BeanWriter writer = ...
writer.getBindingConfiguration().setObjectStringConverter(new
EntityTypeStringConverter());
and the converter itself something like:
public class EntityTypeStringConverter extends ConvertUtilsObjectStringConverter
{
public String objectToString(Object object, Class type, Context context)
{
return EntityType.class.equals(type) ?
((EntityType)object).name() :
super.objectToString(object, type, context);
}
public Object stringToObject(String value, Class type, Context context) {
return EntityType.class.equals(type) ?
Enum.valueOf(EntityType.class, value) :
super.stringToObject(value, type, context);
}
}
To use this, I think you have to define a .betwixt file or a mapping
file and map the property returning the enum to an XML attribute.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]