Anonymous avatar Anonymous committed 9572d23

* file upload example
* type converter will now stop if there is no need to convert

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

Comments (0)

Files changed (1)

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

 package com.opensymphony.xwork.util;
 
 import com.opensymphony.util.TextUtils;
-
 import com.opensymphony.xwork.ActionContext;
 import com.opensymphony.xwork.XworkException;
-
 import ognl.DefaultTypeConverter;
 import ognl.Ognl;
 import ognl.TypeConverter;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Member;
-
 import java.math.BigDecimal;
 import java.math.BigInteger;
-
 import java.text.DateFormat;
 import java.text.NumberFormat;
 import java.text.ParseException;
-
 import java.util.*;
 
 
     public Object convertValue(Map context, Object o, Member member, String s, Object value, Class toType) {
         Object result = null;
 
+        if (value.getClass().isAssignableFrom(toType)) {
+            // no need to convert at all, right?
+            return value;
+        }
+
         if (toType == String.class) {
             result = doConvertToString(context, value);
         } else if (toType == boolean.class) {
     /**
      * Creates a Collection of the specified type.
      *
-     * @param toType the type of Collection to create
+     * @param toType     the type of Collection to create
      * @param memberType the type of object elements in this collection must be
-     * @param size the initial size of the collection (ignored if 0 or less)
+     * @param size       the initial size of the collection (ignored if 0 or less)
      * @return a Collection of the specified type
      */
     private Collection createCollection(Class toType, Class memberType, int size) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.