From 303fa310e80cffb885764e4fa55068cef21c0dca Mon Sep 17 00:00:00 2001 From: remm Date: Wed, 29 Nov 2006 21:10:40 +0000 Subject: [PATCH] - Use a separate method for checking primitives. I'll keep the check for now since I have the impression it's tested. 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 | 19 +++++++++++++++++++ java/org/apache/jasper/compiler/Validator.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/java/org/apache/el/lang/ELSupport.java b/java/org/apache/el/lang/ELSupport.java index 3ecbd9980..cebbd04ad 100644 --- a/java/org/apache/el/lang/ELSupport.java +++ b/java/org/apache/el/lang/ELSupport.java @@ -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)) { diff --git a/java/org/apache/jasper/compiler/Validator.java b/java/org/apache/jasper/compiler/Validator.java index ff53186c5..21c111df8 100644 --- a/java/org/apache/jasper/compiler/Validator.java +++ b/java/org/apache/jasper/compiler/Validator.java @@ -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", -- 2.11.0