Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification.
The following page has been changed by JesseSweetland: http://wiki.apache.org/jakarta-commons/Betwixt/TipsAndHints/Java5Enums ------------------------------------------------------------------------------ {{{ import org.apache.commons.betwixt.strategy.*; + /** + * @author Jesse Sweetland + */ public class EnumTypeBindingStrategy extends TypeBindingStrategy { public TypeBindingStrategy.BindingType bindingType(Class type) { TypeBindingStrategy.BindingType bindingType = null; @@ -28, +31 @@ Once the TypeBindingStrategy class has been created, configure the Betwixt BeanWriter to use it: {{{ - StringWriter sw = new StirngWriter(); + StringWriter sw = new StringWriter(); BeanWriter bw = new BeanWriter(sw); bw.getXMLIntrospector().getConfiguration().setTypeBindingStrategy(new EnumTypeBindingStrategy()); }}} @@ -38, +41 @@ {{{ import org.apache.commons.betwixt.expression.*; import org.apache.commons.betwixt.strategy.*; + /** + * @author Jesse Sweetland + */ public class EnumObjectStringConverter extends ObjectStringConverter { public String objectToString(Object object, Class type, Context context) { String value = null; @@ -64, +70 @@ Now, configure the converter on the BeanWriter: {{{ - StringWriter sw = new StirngWriter(); + StringWriter sw = new StringWriter(); BeanWriter bw = new BeanWriter(sw); bw.getXMLIntrospector().getConfiguration().setTypeBindingStrategy(new EnumTypeBindingStrategy()); bw.getBindingConfiguration().setObjectStringConverter(new EnumObjectStringConverter()); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
