commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jakarta-commons Wiki] Update of "Betwixt/TipsAndHints/Java5Enums" by JesseSweetland
Date Wed, 09 Aug 2006 19:02:55 GMT
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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message