commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r410382 - in /jakarta/commons/proper/betwixt/trunk: src/java/org/apache/commons/betwixt/digester/ElementRule.java xdocs/tasks.xml
Date Tue, 30 May 2006 21:38:41 GMT
Author: rdonkin
Date: Tue May 30 14:38:41 2006
New Revision: 410382

URL: http://svn.apache.org/viewvc?rev=410382&view=rev
Log:
Support for polymorphic list properties.

Modified:
    jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/ElementRule.java
    jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml

Modified: jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/ElementRule.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/ElementRule.java?rev=410382&r1=410381&r2=410382&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/ElementRule.java
(original)
+++ jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/ElementRule.java
Tue May 30 14:38:41 2006
@@ -25,6 +25,7 @@
 import org.apache.commons.betwixt.XMLBeanInfo;
 import org.apache.commons.betwixt.XMLUtils;
 import org.apache.commons.betwixt.expression.ConstantExpression;
+import org.apache.commons.betwixt.expression.Expression;
 import org.apache.commons.betwixt.expression.IteratorExpression;
 import org.apache.commons.betwixt.expression.MethodExpression;
 import org.apache.commons.betwixt.expression.MethodUpdater;
@@ -324,17 +325,34 @@
 
         // choose response from property type
 
+        final MethodExpression methodExpression = new MethodExpression(readMethod);
         if (getXMLIntrospector().isPrimitiveType(type)) {
             elementDescriptor
-                    .setTextExpression(new MethodExpression(readMethod));
+                    .setTextExpression(methodExpression);
 
         } else if (getXMLIntrospector().isLoopType(type)) {
             log.trace("Loop type ??");
 
             // don't wrap this in an extra element as its specified in the
             // XML descriptor so no need.
-            elementDescriptor.setContextExpression(new IteratorExpression(
-                    new MethodExpression(readMethod)));
+            Expression expression = methodExpression;
+            
+            // Support collectives with standard property setters (not adders)
+            // that use polymorphism to read objects.
+            boolean standardProperty = false;
+            if (updateMethodName != null && writeMethod != null && writeMethod.getName().equals(updateMethodName))
{
+                final Class[] parameters = writeMethod.getParameterTypes();
+                if (parameters.length == 1) {
+                    Class setterType = parameters[0];
+                    if (type.equals(setterType)) {
+                        standardProperty = true;
+                    }
+                }
+            }
+            if (!standardProperty) {
+                expression = new IteratorExpression(methodExpression);
+            }
+            elementDescriptor.setContextExpression(expression);
             elementDescriptor.setHollow(true);
 
             writeMethod = null;
@@ -355,8 +373,7 @@
         } else {
             log.trace("Standard property");
             elementDescriptor.setHollow(true);
-            elementDescriptor.setContextExpression(new MethodExpression(
-                    readMethod));
+            elementDescriptor.setContextExpression(methodExpression);
         }
 
         // see if we have a custom method update name

Modified: jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml?rev=410382&r1=410381&r2=410382&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml (original)
+++ jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml Tue May 30 14:38:41 2006
@@ -200,6 +200,9 @@
     <subsection name='Since 0.7'>            
         <ul>
           <li>
+Added strategies for suppression of attributes and elements at introspection time.
+          </li>
+          <li>
 Improved support for natural polymorphic mappings of collection subclasses.
           </li>
           <li>



---------------------------------------------------------------------
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