- Use a separate method for checking primitives. I'll keep the check for now since...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Nov 2006 21:10:40 +0000 (21:10 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 29 Nov 2006 21:10:40 +0000 (21:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@480713 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/lang/ELSupport.java
java/org/apache/jasper/compiler/Validator.java

index 3ecbd99..cebbd04 100644 (file)
@@ -316,6 +316,25 @@ public class ELSupport {
         }
     }
 
+    public final static void checkType(final Object obj, final Class type)
+        throws IllegalArgumentException {
+        if (String.class.equals(type)) {
+            coerceToString(obj);
+        }
+        if (ELArithmetic.isNumberType(type)) {
+            coerceToNumber(obj, type);
+        }
+        if (Character.class.equals(type) || Character.TYPE == type) {
+            coerceToCharacter(obj);
+        }
+        if (Boolean.class.equals(type) || Boolean.TYPE == type) {
+            coerceToBoolean(obj);
+        }
+        if (type.isEnum()) {
+            coerceToEnum(obj, type);
+        }
+    }
+
     public final static Object coerceToType(final Object obj, final Class type)
             throws IllegalArgumentException {
         if (type == null || Object.class.equals(type)) {
index ff53186..21c111d 100644 (file)
@@ -1075,7 +1075,7 @@ class Validator {
                                     }
                                     // Check casting
                                     try {
-                                        ELSupport.coerceToType(attrs.getValue(i), expectedClass);
+                                        ELSupport.checkType(attrs.getValue(i), expectedClass);
                                     } catch (Exception e) {
                                         err.jspError
                                             (n, "jsp.error.coerce_to_type",