FWIW, I've handled this by hiding the enum properties and creating accessors that take and return integer values. I'm sure the solution below is better, but I thought I'd offer the alternative.
Doug Thomas Dudziak <[EMAIL PROTECTED]> 01/07/2006 01:28 PM Please respond to "Jakarta Commons Users List" <[email protected]> To Jakarta Commons Users List <[email protected]> cc Subject Re: [Betwixt] Java 5.0 enum 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]
