Commits

Anonymous committed beee92d

Handle type conversion from Object[] to collection.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@303e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork/util/XWorkBasicConverter.java

             }
         }
 
-        if (value instanceof String[]) {
-            String[] sa = (String[]) value;
+        if (toType.isAssignableFrom(value.getClass())) {
+            // no need to do anything
+            result = (Collection) value;
+        } else if (value.getClass().isArray()) {
+            Object[] objArray = (Object[]) value;
 
             if (toType == Set.class) {
-                result = new HashSet(sa.length);
+                result = new HashSet(objArray.length);
             } else if (toType == SortedSet.class) {
                 result = new TreeSet();
             } else {
-                result = new XWorkList(memberType, sa.length);
+                result = new XWorkList(memberType, objArray.length);
             }
 
             TypeConverter converter = Ognl.getTypeConverter(context);
 
-            for (int i = 0; i < sa.length; i++) {
-                result.add(converter.convertValue(context, o, member, prop, sa[i], memberType));
+            for (int i = 0; i < objArray.length; i++) {
+                result.add(converter.convertValue(context, o, member, prop, objArray[i], memberType));
             }
-        } else if (toType.isAssignableFrom(value.getClass())) {
-            result = (Collection) value;
         } else if (Collection.class.isAssignableFrom(value.getClass())) {
             Collection col = (Collection) value;