commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression MethodUpdater.java
Date Tue, 27 Apr 2004 20:01:10 GMT
rdonkin     2004/04/27 13:01:10

  Modified:    betwixt/src/java/org/apache/commons/betwixt/expression Tag:
                        REFACTORING-BRANCH_2004-01-13 MethodUpdater.java
  Log:
  Added support for array property setters
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.11.2.1  +18 -5     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/MethodUpdater.java
  
  Index: MethodUpdater.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/expression/MethodUpdater.java,v
  retrieving revision 1.11
  retrieving revision 1.11.2.1
  diff -u -r1.11 -r1.11.2.1
  --- MethodUpdater.java	9 Oct 2003 20:52:04 -0000	1.11
  +++ MethodUpdater.java	27 Apr 2004 20:01:10 -0000	1.11.2.1
  @@ -60,7 +60,9 @@
    */ 
   package org.apache.commons.betwixt.expression;
   
  +import java.lang.reflect.Array;
   import java.lang.reflect.Method;
  +import java.util.Collection;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -131,7 +133,18 @@
                       return;
                   }
   */                
  -            }                    
  +            }
  +            // special case for collection objects into arrays                    
  +            if (newValue instanceof Collection && valueType.isArray()) {
  +                Collection valuesAsCollection = (Collection) newValue;
  +                Class componentType = valueType.getComponentType();
  +                if (componentType != null) {
  +                    Object[] valuesAsArray = 
  +                        (Object[]) Array.newInstance(componentType, valuesAsCollection.size());
  +                    newValue = valuesAsCollection.toArray(valuesAsArray);
  +                }
  +            }
  +            
               Object[] arguments = { newValue };
               try {
                   if ( log.isDebugEnabled() ) {
  
  
  

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