commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1066835 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
Date Thu, 03 Feb 2011 15:45:58 GMT
Author: simonetripodi
Date: Thu Feb  3 15:45:58 2011
New Revision: 1066835

URL: http://svn.apache.org/viewvc?rev=1066835&view=rev
Log:
added (type,converter) binding implementation 

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java?rev=1066835&r1=1066834&r2=1066835&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
Thu Feb  3 15:45:58 2011
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.digester3.rulesbinder.BackToLinkedRuleBuilder;
 import org.apache.commons.digester3.rulesbinder.BeanPropertySetterBuilder;
 import org.apache.commons.digester3.rulesbinder.CallMethodBuilder;
@@ -40,6 +41,7 @@ import org.apache.commons.digester3.rule
 import org.apache.commons.digester3.spi.ObjectCreationFactory;
 import org.apache.commons.digester3.spi.RuleProvider;
 import org.apache.commons.digester3.spi.Rules;
+import org.apache.commons.digester3.spi.TypeConverter;
 
 /**
  * The Digester EDSL implementation.
@@ -808,8 +810,23 @@ final class RulesBinderImpl implements R
     /**
      * {@inheritDoc}
      */
-    public <T> ConverterBuilder<T> convert(Class<T> type) {
-        return null;
+    public <T> ConverterBuilder<T> convert(final Class<T> type) {
+        if (type == null) {
+            this.addError(new IllegalArgumentException("NULL type is not allowed to be converted"));
+        }
+        return new ConverterBuilder<T>() {
+
+            public void withConverter(TypeConverter<T> typeConverter) {
+                if (typeConverter == null) {
+                    addError(new IllegalArgumentException(
+                            String.format("NULL TypeConverter is not allowed for converting
'%s' type",
+                                    type.getName())));
+                }
+
+                ConvertUtils.register(new BeanUtilsConverterFacade(typeConverter), type);
+            }
+
+        };
     }
 
 }



Mime
View raw message